Documentation
¶
Index ¶
- func StartAndConnect(ctx context.Context, socketPath string, files ...string) (*Server, *Client, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) Command(args ...any) (json.RawMessage, error)
- func (c *Client) CommandContext(ctx context.Context, args ...any) (json.RawMessage, error)
- func (c *Client) Done() <-chan struct{}
- func (c *Client) DroppedEvents() int64
- func (c *Client) GetPlaylist() ([]PlaylistItem, int, error)
- func (c *Client) ObserveProperties() error
- func (c *Client) PlayIndex(idx int) error
- func (c *Client) RemoveIndex(idx int) error
- func (c *Client) SeekRelative(seconds float64) error
- func (c *Client) Send(args ...any) error
- func (c *Client) Shuffle() error
- func (c *Client) TogglePause() error
- type PlaylistItem
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client is a concurrent-safe mpv IPC client over a Unix socket.
func ConnectWithRetry ¶
func ConnectWithRetry(ctx context.Context, socketPath string, interval time.Duration) (*Client, error)
ConnectWithRetry keeps trying until the socket appears or the context is cancelled.
func (*Client) Command ¶
func (c *Client) Command(args ...any) (json.RawMessage, error)
Command sends a JSON command and waits for the matching response.
func (*Client) CommandContext ¶
CommandContext sends a JSON command respecting the provided context.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done returns a channel that is closed when the underlying connection dies.
func (*Client) DroppedEvents ¶
DroppedEvents returns the number of events discarded because the Events channel buffer was full.
func (*Client) GetPlaylist ¶
func (c *Client) GetPlaylist() ([]PlaylistItem, int, error)
GetPlaylist retrieves the current playlist and returns the index of the active item (-1 if none).
func (*Client) ObserveProperties ¶
ObserveProperties registers properties required for a music application or TUI.
func (*Client) RemoveIndex ¶
RemoveIndex removes a track from the playlist by its index.
func (*Client) SeekRelative ¶
SeekRelative seeks forward or backward by the specified number of seconds.
func (*Client) Send ¶ added in v0.1.1
Send sends a JSON command without requesting or waiting for an ID-matched response.
func (*Client) TogglePause ¶
TogglePause toggles between pause and play states.
type PlaylistItem ¶
type PlaylistItem struct {
Filename string `json:"filename"`
Title string `json:"title"`
Current bool `json:"current"`
Playing bool `json:"playing"`
}
PlaylistItem represents an entry within the mpv playlist.
func (PlaylistItem) DisplayName ¶
func (p PlaylistItem) DisplayName() string
DisplayName returns the metadata title or, if unavailable, the base file name.
type Server ¶
type Server struct {
SocketPath string
// contains filtered or unexported fields
}
Server manages the background mpv process.
func StartServer ¶
StartServer removes any stale socket if it exists and launches mpv without a graphical user interface.