Categorygithub.com/xoltia/mpv
repositorypackage
0.0.0-20241206173729-4b56e03bddad
Repository: https://github.com/xoltia/mpv.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go MPV IPC

This is a Go package that provides an interface to the IPC mechanism of the mpv media player.

Installation

To install the package, run:

go get github.com/xoltia/mpv

Requirements

The package requires that the mpv executable is installed on the system and in the PATH, or for the location of mpv to be provided using ProcessOptions.

Usage

Check the documentation for more information. For specific commands and properties not directly implemented, see the mpv IPC documentation and make use of the command and property functions directly.

Here is a simple example of playing a video:

package main

import (
    "fmt"

    "github.com/xoltia/mpv"
)

func main() {
    m := mpv.NewProcess()
    defer m.Close()
	
    c, err := m.OpenClient()
    if err != nil {
        panic(err)
    }
    defer c.Close()
	
    err = c.LoadFile("https://youtu.be/6BfKzQzBe7M", mpv.LoadFileModeReplace)
    if err != nil {
        panic(err)
    }
	
    err = c.Play()
    if err != nil {
        panic(err)
    }

    select {}
}

[!NOTE] This example also requires that yt-dlp is installed on the system.

For a more complete example, see the example directory. An IPC connection can be opened with an existing mpv process by using the OpenClient function directly.