Documentation
¶
Overview ¶
Package player provides media playback functionality using external players. It supports playing single files or multiple files as a playlist using mpv.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultPath ¶
func GetDefaultPath() string
GetDefaultPath returns the default MPV path for the current platform.
func IsAvailable ¶
IsAvailable checks if MPV is available on the system. This is a convenience function for checking availability.
func Play ¶
Play launches MPV to play the given URL. This is a convenience function that uses the default player.
func PlayMultiple ¶
PlayMultiple launches MPV to play multiple URLs sequentially. This is a convenience function that uses the default player.
Types ¶
type MPVPlayer ¶ added in v0.2.2
type MPVPlayer struct {
// Path is the path to the mpv executable. If empty, "mpv" is used.
Path string
}
MPVPlayer implements the Player interface using mpv media player. It provides high-quality media playback with seeking support.
func NewMPVPlayer ¶ added in v0.2.2
NewMPVPlayer creates a new MPVPlayer with the specified path. If path is empty, the system PATH will be searched for mpv.
func (*MPVPlayer) IsAvailable ¶ added in v0.2.2
IsAvailable checks if mpv is available on the system.
type PlayOutcome ¶ added in v0.3.24
type PlayOutcome struct {
ExitCode int // 0 on clean exit; -1 when killed by a signal
Signal string // signal name when killed by a signal, "" otherwise
ErrorLine string // most relevant stderr line, token-redacted
}
PlayOutcome describes how an mpv run ended, error or not, so callers can spot streams that "played" without ever starting (e.g. an instant EOF that exits 0).
func PlayMultipleWithOptions ¶ added in v0.2.2
func PlayMultipleWithOptions(streamURLs []string, mpvPath string, opts PlaybackOptions) (*PlayOutcome, error)
PlayMultipleWithOptions launches MPV with custom options and reports how the run ended. The outcome is non-nil whenever mpv actually ran, error or not.
type PlaybackError ¶ added in v0.3.24
type PlaybackError struct {
ExitCode int // mpv's exit code; -1 when killed by a signal
Signal string // signal name when killed by a signal, "" otherwise
Detail string // most relevant stderr line, "" if mpv wrote nothing useful
}
PlaybackError reports that mpv exited with one of its documented failure codes (1 = fatal error, 2 = file could not be played, 3 = some files failed) or was killed by a signal. A clean exit — including the user quitting — is not a PlaybackError.
func (*PlaybackError) Error ¶ added in v0.3.24
func (e *PlaybackError) Error() string
type PlaybackOptions ¶ added in v0.2.2
type PlaybackOptions struct {
SocketPath string // IPC socket path for progress tracking (Unix socket or Windows named pipe, empty to disable)
StartPos int // Start position in seconds (0 to start from beginning)
}
PlaybackOptions configures MPV playback behavior.