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) 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 Event
- type EventType
- type PlaylistItem
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Events chan Event
// contains filtered or unexported fields
}
Client handles concurrent-safe IPC communication over an mpv Unix socket.
func ConnectWithRetry ¶
func ConnectWithRetry(ctx context.Context, socketPath string, interval time.Duration) (*Client, error)
ConnectWithRetry repeatedly attempts to connect until the socket appears or context is canceled.
func (*Client) Close ¶
Close gracefully shuts down the client connection and cleans up pending requests.
func (*Client) Command ¶
func (c *Client) Command(args ...any) (json.RawMessage, error)
Command sends a synchronous JSON command and blocks until a response is received.
func (*Client) CommandContext ¶
CommandContext sends a synchronous JSON command respecting the provided context.
func (*Client) DroppedEvents ¶
DroppedEvents returns the count of events dropped due to a full buffer.
func (*Client) GetPlaylist ¶
func (c *Client) GetPlaylist() ([]PlaylistItem, int, error)
GetPlaylist queries the current playlist and returns the active track index (-1 if none).
func (*Client) ObserveProperties ¶
ObserveProperties registers property change notifications required by the TUI client.
func (*Client) RemoveIndex ¶
RemoveIndex removes a track from the playlist by its index.
func (*Client) SeekRelative ¶
SeekRelative performs a relative seek by the specified number of seconds.
func (*Client) Send ¶ added in v0.1.1
Send writes an asynchronous JSON command without waiting for a response.
func (*Client) TogglePause ¶
TogglePause toggles the playback state between pause and play.
type Event ¶ added in v0.2.0
Event encapsulates an mpv event with helper methods to avoid manual type assertions.
func (Event) PropertyBool ¶ added in v0.2.3
PropertyBool safely extracts the value of a boolean property.
func (Event) PropertyChange ¶ added in v0.2.0
PropertyChange extracts the property name and its value if the event is a property-change.
func (Event) PropertyFloat ¶ added in v0.2.3
PropertyFloat safely extracts the value of a numeric property as a float64.
type EventType ¶ added in v0.2.0
type EventType string
EventType represents the type of event received from mpv.
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 lifecycle.
func StartServer ¶
StartServer removes any stale socket if it exists and launches mpv in background IPC mode.