Documentation
¶
Index ¶
- Variables
- type AudioDevice
- type Equalizer
- type EqualizerBand
- type EqualizerCurve
- type ISO15BandEqualizer
- type LoopMode
- type MediaInfo
- type Player
- func (p *Player) AppendFile(url string) error
- func (p *Player) ClearPlayQueue() error
- func (p *Player) Destroy()
- func (p *Player) Equalizer() Equalizer
- func (p *Player) GetLoopMode() LoopMode
- func (p *Player) GetMediaInfo() (MediaInfo, error)
- func (p *Player) GetStatus() Status
- func (p *Player) GetVolume() int
- func (p *Player) Init(maxCacheMB int) error
- func (p *Player) IsSeeking() bool
- func (p *Player) ListAudioDevices() ([]AudioDevice, error)
- func (p *Player) OnPaused(cb func())
- func (p *Player) OnPlaying(cb func())
- func (p *Player) OnSeek(cb func())
- func (p *Player) OnStopped(cb func())
- func (p *Player) OnTrackChange(cb func(int64))
- func (p *Player) PlayFile(url string) error
- func (p *Player) PlayFromBeginning() error
- func (p *Player) PlayPause() error
- func (p *Player) PlayTrackAt(idx int) error
- func (p *Player) RemoveTrackAt(idx int) error
- func (p *Player) Seek(target string, mode SeekMode) error
- func (p *Player) SeekBackOrPrevious() error
- func (p *Player) SeekNext() error
- func (p *Player) SetAudioDevice(deviceName string) error
- func (p *Player) SetAudioExclusive(tf bool)
- func (p *Player) SetEqualizer(eq Equalizer) error
- func (p *Player) SetLoopMode(mode LoopMode) error
- func (p *Player) SetNextLoopMode() error
- func (p *Player) SetReplayGainOptions(options ReplayGainOptions) error
- func (p *Player) SetVolume(vol int) error
- func (p *Player) Stop() error
- type ReplayGainMode
- type ReplayGainOptions
- type SeekMode
- type State
- type Status
- type WidthType
Constants ¶
This section is empty.
Variables ¶
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 ¶ added in v0.4.0
type Equalizer interface { IsEnabled() bool Preamp() float64 Curve() EqualizerCurve Type() string // Returns the band frequencies as strings friendly for display BandFrequencies() []string }
type EqualizerBand ¶ added in v0.4.0
func (EqualizerBand) String ¶ added in v0.4.0
func (e EqualizerBand) String() string
type EqualizerCurve ¶ added in v0.4.0
type EqualizerCurve []EqualizerBand
func (EqualizerCurve) String ¶ added in v0.4.0
func (e EqualizerCurve) String() string
type ISO15BandEqualizer ¶ added in v0.4.0
func (*ISO15BandEqualizer) BandFrequencies ¶ added in v0.4.0
func (*ISO15BandEqualizer) BandFrequencies() []string
func (*ISO15BandEqualizer) Curve ¶ added in v0.4.0
func (i *ISO15BandEqualizer) Curve() EqualizerCurve
func (*ISO15BandEqualizer) IsEnabled ¶ added in v0.4.0
func (i *ISO15BandEqualizer) IsEnabled() bool
func (*ISO15BandEqualizer) Preamp ¶ added in v0.4.0
func (i *ISO15BandEqualizer) Preamp() float64
func (*ISO15BandEqualizer) Type ¶ added in v0.4.0
func (*ISO15BandEqualizer) Type() string
type LoopMode ¶ added in v0.4.0
type LoopMode int
The playback loop mode (LoopNone, LoopAll, LoopOne).
type MediaInfo ¶ added in v0.4.0
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 ¶
Same as New, but sets the application name that mpv reports to the system audio API.
func (*Player) AppendFile ¶
Appends the given file to the play queue. Note that the Player API does not provide methods to read the play queue. Clients are expected to maintain their own play queue model.
func (*Player) ClearPlayQueue ¶
Clears the play queue, except for the currently playing file.
func (*Player) GetLoopMode ¶ added in v0.4.0
Get the loop mode of the player.
func (*Player) GetMediaInfo ¶ added in v0.4.0
func (*Player) Init ¶
Initializes the Player and makes it ready for playback. Most Player functions will return ErrUnitialized if called before Init.
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 ¶
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) PlayFromBeginning ¶
Start playback from the first track in the play queue.
func (*Player) PlayPause ¶
Begins playback if there is anything in the play queue and player is stopped or paused. If player is playing, pauses playback.
func (*Player) PlayTrackAt ¶
Start playback from the specified track index in the play queue.
func (*Player) RemoveTrackAt ¶
Removes the item at the given index from the internal playqueue.
func (*Player) Seek ¶
Seeks within the currently playing track. See MPV seek command documentation for more details.
func (*Player) SeekBackOrPrevious ¶
Seeks to the beginning of the current track if:
- The current track is the first track in the play queue, or
- The current time is more than 3 seconds past the beginning of the track.
Else seeks to the beginning of the previous track.
func (*Player) SetAudioDevice ¶
func (*Player) SetAudioExclusive ¶
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 ¶ added in v0.4.0
func (*Player) SetLoopMode ¶ added in v0.4.0
Set the loop mode of the player.
func (*Player) SetNextLoopMode ¶ added in v0.4.0
Change the loop mode of the player to the next one. Useful for toggling UI elements, to change modes without knowing the current player mode.
func (*Player) SetReplayGainOptions ¶
func (p *Player) SetReplayGainOptions(options 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.
type ReplayGainMode ¶
type ReplayGainMode string
One of "no", "track", or "album"
const ( ReplayGainNone ReplayGainMode = "no" ReplayGainTrack ReplayGainMode = "track" ReplayGainAlbum ReplayGainMode = "album" )
type ReplayGainOptions ¶
type ReplayGainOptions struct { Mode ReplayGainMode PreampGain float64 PreventClipping bool }
Replay Gain options (argument to SetReplayGainOptions).
type SeekMode ¶
type SeekMode int
Argument to Seek function (SeekAbsolute, SeekRelative, SeekAbsolutePercent, SeekRelativePercent).