Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPServerHandler(client LLClient) http.Handler
- type AudioTrack
- type Client
- func (c *Client) Cycle(property string) error
- func (c *Client) Duration() (float64, error)
- func (c *Client) Filename() (string, error)
- func (c *Client) Fullscreen() (bool, error)
- func (c *Client) GetBoolProperty(name string) (bool, error)
- func (c *Client) GetFloatProperty(name string) (float64, error)
- func (c *Client) GetProperty(name string) (string, error)
- func (c *Client) Idle() (bool, error)
- func (c *Client) LoadList(path string, mode string) error
- func (c *Client) Loadfile(path string, mode string) error
- func (c *Client) Mute() (bool, error)
- func (c *Client) Path() (string, error)
- func (c *Client) Pause() (bool, error)
- func (c *Client) PercentPosition() (float64, error)
- func (c *Client) PlaybackTime() (float64, error)
- func (c *Client) PlaylistNext() error
- func (c *Client) PlaylistPrevious() error
- func (c *Client) Position() (float64, error)
- func (c *Client) Quit(code int) error
- func (c *Client) Seek(n int, mode string) error
- func (c *Client) SetAudioTrack(ID int) error
- func (c *Client) SetFullscreen(v bool) error
- func (c *Client) SetMute(mute bool) error
- func (c *Client) SetOSD(ok bool) error
- func (c *Client) SetPause(pause bool) error
- func (c *Client) SetProperty(name string, value interface{}) error
- func (c *Client) SetTextTrack(ID int) error
- func (c *Client) SetVideoTrack(ID int) error
- func (c *Client) SetVolume(i int) error
- func (c *Client) SetVolumeGain(i int) error
- func (c *Client) Speed() (float64, error)
- func (c *Client) Stop() error
- func (c *Client) SubAdd(file string, flags ...SubFlag) error
- func (c *Client) SubRemove(id string) error
- func (c *Client) TrackList() ([]Track, error)
- func (c *Client) Volume() (float64, error)
- type IPCClient
- type JSONRequest
- type JSONResponse
- type LLClient
- type RPCClient
- type RPCServer
- type Response
- type SubFlag
- type Track
- type VideoTrack
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
Variables ¶
var ( ErrTimeoutSend = errors.New("Timeout while sending command") ErrTimeoutRecv = errors.New("Timeout while receiving response") )
Timeout errors while communicating via IPC
var ChannelErr = errors.New("Response channel closed")
The client should be restarted
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 AudioTrack ¶
type Client ¶
type Client struct {
LLClient
}
Client is a more comfortable higher level interface to LLClient. It can use any LLClient implementation.
func (*Client) Fullscreen ¶
Fullscreen returns true if the player is in 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) LoadList ¶
LoadList loads a playlist from path. It can either replace the current playlist (LoadListModeReplace) or append to the current playlist (LoadListModeAppend).
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) PercentPosition ¶
PercentPosition returns the current playback position in percent.
func (*Client) PlaybackTime ¶
func (*Client) PlaylistNext ¶
PlaylistNext plays the next playlistitem or NOP if no item is available.
func (*Client) PlaylistPrevious ¶
PlaylistPrevious plays the previous playlistitem or NOP if no item is available.
func (*Client) Seek ¶
Seek seeks to a position in the current file. Use mode to seek relative to current position (SeekModeRelative) or absolute (SeekModeAbsolute).
func (*Client) SetAudioTrack ¶
While playback is active, you can set existing tracks only. (The option allows setting any track ID, and which tracks to enable is chosen at loading time.)
func (*Client) SetFullscreen ¶
SetFullscreen activates/deactivates the fullscreen mode.
func (*Client) SetProperty ¶
SetProperty sets the value of a property.
func (*Client) SetVideoTrack ¶
func (*Client) SetVolumeGain ¶
1 increases the volume by 1 , -1 decreases the volume by 1
func (*Client) Stop ¶
Stop playback and clear playlist. With default settings, this is essentially like quit. Useful for the client API: playback can be stopped without terminating the player.
func (*Client) SubAdd ¶
Load the given subtitle file. It is selected as current subtitle after loading. The flags args is one of the following values:
func (*Client) SubRemove ¶
Remove the given subtitle track. If the id argument is missing, remove the current track. (Works on external subtitle files only.)
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.
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 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
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.
type Response ¶
type Response struct { Err string `json:"error"` Data json.RawMessage `json:"data"` // May contain float64, bool or string Event string `json:"event"` RequestID int `json:"request_id"` }
Response received from mpv. Can be an event or a user requested response.
type SubFlag ¶
type SubFlag string
const ( // Select the subtitle immediately. Select SubFlag = "select" // Don't select the subtitle. // (Or in some special situations, // let the default stream selection mechanism decide.) Auto SubFlag = "auto" // Select the subtitle. If a subtitle with the same filename was // already added, that one is selected, instead of loading a // duplicate entry. (In this case, title/language are ignored, // and if the was changed since it was loaded, these // changes won't be reflected.) Cached SubFlag = "cached" // The title argument sets the track title in the UI. Title SubFlag = "title" // The lang argument sets the track language, and // can also influence stream selection with flags set // to auto. Lang SubFlag = "lang" )
type Track ¶
type Track struct { ID int `json:"id"` // unique wihtin Type Type string `json:"type"` // e.g. audio , video, sub SrcID int `json:"src-id"` Title string `json:"title"` Lang string `json:"lang"` Albumart bool `json:"albumart"` Default bool `json:"default"` Forced bool `json:"forced"` External bool `json:"external"` Selected bool `json:"selected"` FFIndex int `json:"ff-index"` DecoderDesc string `json:"decoder-desc"` Codec string `json:"codec"` Filename string `json:"external-filename"` AudioTrack VideoTrack }