player

package
v0.3.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 4 Imported by: 0

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

func IsAvailable(mpvPath string) bool

IsAvailable checks if MPV is available on the system. This is a convenience function for checking availability.

func Play

func Play(streamURL, mpvPath string) error

Play launches MPV to play the given URL. This is a convenience function that uses the default player.

func PlayMultiple

func PlayMultiple(streamURLs []string, mpvPath string) error

PlayMultiple launches MPV to play multiple URLs sequentially. This is a convenience function that uses the default player.

func PlayMultipleWithOptions added in v0.2.2

func PlayMultipleWithOptions(streamURLs []string, mpvPath string, opts PlaybackOptions) error

PlayMultipleWithOptions launches MPV with custom options.

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

func NewMPVPlayer(path string) *MPVPlayer

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

func (p *MPVPlayer) IsAvailable() bool

IsAvailable checks if mpv is available on the system.

func (*MPVPlayer) Play added in v0.2.2

func (p *MPVPlayer) Play(ctx context.Context, url string) error

Play plays a single media URL.

func (*MPVPlayer) PlayMultiple added in v0.2.2

func (p *MPVPlayer) PlayMultiple(ctx context.Context, urls []string) error

PlayMultiple plays multiple URLs as a playlist. Users can navigate between items using 'n' (next) in mpv.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL