Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPServerHandler(client LLClient) http.Handler
- type Client
- func (c *Client) AudioBitrate() int
- func (c *Client) CurerentFileWithPath() string
- func (c *Client) CurrentFile() string
- func (c *Client) CurrentSpeed() float64
- func (c *Client) CurrentVolume() int
- func (c *Client) Duration() float64
- func (c *Client) FileLoop() error
- func (c *Client) FileSize() int
- func (c *Client) FileUnLoop() error
- func (c *Client) Format() string
- func (c *Client) Fullscreen() error
- func (c *Client) GetBoolProperty(name string) (bool, error)
- func (c *Client) GetFloatProperty(name string) (float64, error)
- func (c *Client) GetProperty(name string) string
- func (c *Client) IsFileLoop() bool
- func (c *Client) IsFullscreen() bool
- func (c *Client) IsIdle() bool
- func (c *Client) IsMute() bool
- func (c *Client) IsPause() bool
- func (c *Client) IsPlayLoop() bool
- func (c *Client) IsShuffle() bool
- func (c *Client) LoadFile(path string, mode string) error
- func (c *Client) LoadList(path string, mode string) error
- func (c *Client) MediaTitle() string
- func (c *Client) Mute() error
- func (c *Client) Pause() error
- func (c *Client) PercentPosition() float64
- func (c *Client) PlayClear() error
- func (c *Client) PlayIndex(n int) error
- func (c *Client) PlayIndexRemove(n int) error
- func (c *Client) PlayLoop() error
- func (c *Client) PlayNext() error
- func (c *Client) PlayPos() int
- func (c *Client) PlayPrev() error
- func (c *Client) PlayRemove() error
- func (c *Client) PlayShuffle() error
- func (c *Client) PlayUnLoop() error
- func (c *Client) PlayUnShuffle() error
- func (c *Client) Playlist() []string
- func (c *Client) PlaylistCount() int
- func (c *Client) Position() float64
- func (c *Client) Quit() error
- func (c *Client) RegisterEvent(eventName string, handle func())
- func (c *Client) Seek(n int) error
- func (c *Client) SetProperty(name string, value interface{}) error
- func (c *Client) Shuffle() error
- func (c *Client) Speed(n float64) error
- func (c *Client) Stop() error
- func (c *Client) TimeRemaining() float64
- func (c *Client) VideoBitrate() int
- func (c *Client) Volume(level int) error
- type IPCClient
- type JSONRequest
- type JSONResponse
- type LLClient
- type RPCClient
- type RPCServer
- type Response
Constants ¶
const ( LoadFileModeReplace = "replace" LoadFileModeAppend = "append" LoadFileModeAppendPlay = "append-play" // Starts if nothing is playing )
Mode options for Loadfile
const ( SeekModeRelative = "relative" SeekModeAbsolute = "absolute" )
Mode options for Seek
const ( LoadListModeReplace = "replace" LoadListModeAppend = "append" )
Mode options for LoadList
const ( EventStartFile = "start-file" EventTracksChanged = "tracks-changed" EventMetadataUpdate = "metadata-update" EventAudioReconfig = "audio-reconfig" EventVideoReconfig = "video-reconfig" EventFileLoaded = "file-loaded" EventPlayBackRestart = "playback-restart" EventEndFile = "end-file" EventSeek = "seek" EventShutDown = "shutdown" EventLogMessage = "log-message" EventIdle = "idle" EventClientMessage = "client-message" EventPropertyChange = "property-change" )
Variables ¶
var ( ErrTimeoutSend = errors.New("Timeout while sending command") ErrTimeoutRecv = errors.New("Timeout while receiving response") )
Timeout errors while communicating via IPC
var ErrInvalidType = errors.New("Invalid type")
ErrInvalidType is returned if the response data does not match the methods return type. Use GetProperty or find matching type in mpv docs.
Functions ¶
func HTTPServerHandler ¶
HTTPServerHandler returns a http.Handler to access a client via a lowlevel json-api. Register as route on your server:
http.Handle("/mpv", mpv.HTTPHandler(lowlevelclient)
Use api:
POST http://host/lowlevel Body: { "command": ["get_property", "fullscreen"] }
Result:
{"error":"success","data":false}
Types ¶
type Client ¶
type Client struct {
LLClient
}
Client is a more comfortable higher level interface to LLClient. It can use any LLClient implementation.
func (*Client) CurerentFileWithPath ¶
Path returns the currently playing path
func (*Client) CurrentFile ¶
Filename returns the currently playing filename
func (*Client) CurrentSpeed ¶
Speed returns the current playback speed.
func (*Client) CurrentVolume ¶
Volume returns the current volume level.
func (*Client) Fullscreen ¶
SetFullscreen activates/deactivates the fullscreen mode.
func (*Client) GetBoolProperty ¶
GetBoolProperty reads a bool property and returns the data as a boolean.
func (*Client) GetFloatProperty ¶
GetFloatProperty reads a float property and returns the data as a float64.
func (*Client) GetProperty ¶
GetProperty reads a property by name and returns the data as a string.
func (*Client) IsFullscreen ¶
Fullscreen returns true if the player is in fullscreen mode.
func (*Client) LoadFile ¶
Loadfile loads a file, it either replaces the currently playing file (LoadFileModeReplace), appends to the current playlist (LoadFileModeAppend) or appends to playlist and plays if nothing is playing right now (LoadFileModeAppendPlay)
func (*Client) LoadList ¶
LoadList loads a playlist from path. It can either replace the current playlist (LoadListModeReplace) or append to the current playlist (LoadListModeAppend).
func (*Client) PercentPosition ¶
PercentPosition returns the current playback position in percent.
func (*Client) PlayIndexRemove ¶
Remove the specified playlistitem
func (*Client) PlayPrev ¶
PlaylistPrevious plays the previous playlistitem or NOP if no item is available.
func (*Client) RegisterEvent ¶
Register Event HandFunc
func (*Client) SetProperty ¶
SetProperty sets the value of a property.
type IPCClient ¶
type IPCClient struct {
// contains filtered or unexported fields
}
IPCClient is a low-level IPC client to communicate with the mpv player via socket.
func NewIPCClient ¶
NewIPCClient creates a new IPCClient connected to the given socket.
func (*IPCClient) Exec ¶
Exec executes a command via ipc and returns the response. A request can timeout while sending or while waiting for the response. An error is only returned if there was an error in the communication. The client has to check for `response.Error` in case the server returned an error.
func (*IPCClient) RegisterEvent ¶
Register Event Handle Function
type JSONRequest ¶
type JSONRequest struct {
Command []interface{} `json:"command"`
}
JSONRequest send to the server.
type JSONResponse ¶
type JSONResponse struct { Err string `json:"error"` Data interface{} `json:"data"` // May contain float64, bool or string }
JSONResponse send from the server.
type LLClient ¶
type LLClient interface { Exec(command ...interface{}) (*Response, error) RegisterEvent(name string, handle func()) }
LLClient is the most low level interface
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient represents a LLClient over RPC.
func NewRPCClient ¶
NewRPCClient creates a new RPCClient based on rpc.Client
func (*RPCClient) RegisterEvent ¶
type RPCServer ¶
type RPCServer struct {
// contains filtered or unexported fields
}
RPCServer publishes a LLClient over RPC.
func NewRPCServer ¶
NewRPCServer creates a new RPCServer based on lowlevel client.