mpv

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnitialized error = errors.New("mpv player uninitialized")

Error returned by many Player functions if called before the player has not been initialized.

Functions

This section is empty.

Types

type AudioDevice

type AudioDevice struct {
	// The name of the audio device.
	// This is the string to pass to SetAudioDevice.
	Name string

	// The description of the audio device.
	// This is the friendly string that should be used in UIs.
	Description string
}

Information about a specific audio device. Returned by ListAudioDevices.

type Equalizer

type Equalizer interface {
	IsEnabled() bool
	Preamp() float64
	Curve() EqualizerCurve
	Type() string
	// Returns the band frequencies as strings friendly for display
	BandFrequencies() []string
}

type EqualizerBand

type EqualizerBand struct {
	Frequency int
	Gain      float64
	Width     float64
	WidthType WidthType
}

func (EqualizerBand) String

func (e EqualizerBand) String() string

type EqualizerCurve

type EqualizerCurve []EqualizerBand

func (EqualizerCurve) String

func (e EqualizerCurve) String() string

type ISO15BandEqualizer

type ISO15BandEqualizer struct {
	Disabled  bool
	EQPreamp  float64
	BandGains [15]float64
}

func (*ISO15BandEqualizer) BandFrequencies

func (*ISO15BandEqualizer) BandFrequencies() []string

func (*ISO15BandEqualizer) Curve

func (*ISO15BandEqualizer) IsEnabled

func (i *ISO15BandEqualizer) IsEnabled() bool

func (*ISO15BandEqualizer) Preamp

func (i *ISO15BandEqualizer) Preamp() float64

func (*ISO15BandEqualizer) Type

func (*ISO15BandEqualizer) Type() string

type MediaInfo

type MediaInfo struct {
	// The sample format as string. This uses the same names as used in other places of mpv.
	// NOTE: this is the format that the decoder outputs, NOT necessarily the format of the file.
	Format string

	// Audio samplerate.
	Samplerate int

	// The number of channels.
	ChannelCount int

	// The audio codec.
	Codec string

	// The average bit rate in bits per second.
	Bitrate int
}

Media information about the currently playing media.

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player encapsulates the mpv instance and provides functions to control it and to check its status.

func New

func New() *Player

Returns a new player. Must call Init on the player before it is ready for playback.

func NewWithClientName

func NewWithClientName(c string) *Player

Same as New, but sets the application name that mpv reports to the system audio API.

func (*Player) Continue

func (p *Player) Continue() error

Continue playback and update the player state

func (*Player) Destroy

func (p *Player) Destroy()

Destroy the player.

func (*Player) Equalizer

func (p *Player) Equalizer() Equalizer

func (*Player) GetMediaInfo

func (p *Player) GetMediaInfo() (MediaInfo, error)

func (*Player) GetStatus

func (p *Player) GetStatus() player.Status

Get the current status of the player.

func (*Player) GetVolume

func (p *Player) GetVolume() int

Gets the current volume of the player.

func (*Player) Init

func (p *Player) Init(maxCacheMB int) error

Initializes the Player and makes it ready for playback. Most Player functions will return ErrUnitialized if called before Init.

func (*Player) IsSeeking

func (p *Player) IsSeeking() bool

Returns true if a seek is currently in progress.

func (*Player) ListAudioDevices

func (p *Player) ListAudioDevices() ([]AudioDevice, error)

List available audio devices.

func (*Player) OnPaused

func (p *Player) OnPaused(cb func())

Registers a callback which is invoked when the player transitions to the Paused state.

func (*Player) OnPlaying

func (p *Player) OnPlaying(cb func())

Registers a callback which is invoked when the player transitions to the Playing state.

func (*Player) OnSeek

func (p *Player) OnSeek(cb func())

Registers a callback which is invoked whenever a seek event occurs.

func (*Player) OnStopped

func (p *Player) OnStopped(cb func())

Registers a callback which is invoked when the player transitions to the Stopped state.

func (*Player) OnTrackChange

func (p *Player) OnTrackChange(cb func())

Registers a callback which is invoked when the currently playing track changes, or when playback begins at any time from the Stopped state. Callback is invoked with the index of the currently playing track (zero-based).

func (*Player) Pause

func (p *Player) Pause() error

Pause playback and update the player state

func (*Player) PlayFile

func (p *Player) PlayFile(url string) error

Plays the specified file, clearing the previous play queue, if any.

func (*Player) SeekSeconds

func (p *Player) SeekSeconds(secs float64) error

Seeks within the currently playing track. See MPV seek command documentation for more details.

func (*Player) SetAudioDevice

func (p *Player) SetAudioDevice(deviceName string) error

func (*Player) SetAudioExclusive

func (p *Player) SetAudioExclusive(tf bool)

Sets the audio exclusive option of the player. Unlike most Player functions, SetAudioExclusive can be called before Init, to set the initial option of the player on startup.

func (*Player) SetEqualizer

func (p *Player) SetEqualizer(eq Equalizer) error

func (*Player) SetNextFile

func (p *Player) SetNextFile(url string) error

func (*Player) SetReplayGainOptions

func (p *Player) SetReplayGainOptions(options player.ReplayGainOptions) error

Sets the ReplayGain options of the player. Unlike most Player functions, SetReplayGainOptions can be called before Init, to set the initial replaygain options of the player on startup.

func (*Player) SetVolume

func (p *Player) SetVolume(vol int) error

Sets the volume of the player (0-100). Unlike most Player functions, SetVolume can be called before Init, to set the initial volume of the player on startup.

func (*Player) Stop

func (p *Player) Stop() error

Stops playback and clears the play queue.

type WidthType

type WidthType int
const (
	WidthTypeHz WidthType = iota
	WidthTypeKhz
	WidthTypeQ
	WidthTypeOctave
	WidthTypeSlope
)

func (WidthType) String

func (w WidthType) String() string

Jump to

Keyboard shortcuts

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