Documentation
¶
Overview ¶
Package audio is the oto-backed playback engine: it downloads, decrypts and decodes Deezer streams (MP3 + FLAC) and plays one track at a time with seek, volume and ReplayGain support.
Index ¶
- type Player
- func (p *Player) AddVolume(delta float64) float64
- func (p *Player) DurationMS() int64
- func (p *Player) Format() string
- func (p *Player) LastError() string
- func (p *Player) Pause()
- func (p *Player) Play(plan *deezer.StreamPlan, durationMS int64) error
- func (p *Player) PositionMS() int64
- func (p *Player) ReplayGain() bool
- func (p *Player) Resume()
- func (p *Player) SeekMS(ms int64)
- func (p *Player) SetOnFinish(fn func())
- func (p *Player) SetReplayGain(on bool)
- func (p *Player) State() State
- func (p *Player) Stop()
- func (p *Player) TogglePause()
- func (p *Player) Volume() float64
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player owns a single oto context and plays one track at a time. The whole track is downloaded + Blowfish-decrypted up front into a seekable reader so that scrubbing works (the streaming CDN body is not seekable).
func (*Player) DurationMS ¶
DurationMS returns the current track duration (from metadata).
func (*Player) Format ¶
Format returns the resolved Deezer format of the current/last stream (e.g. "MP3_128", "MP3_320", "FLAC"), or "" if nothing has played.
func (*Player) Play ¶
func (p *Player) Play(plan *deezer.StreamPlan, durationMS int64) error
Play downloads + decrypts the whole track, then decodes and plays it.
func (*Player) PositionMS ¶
PositionMS returns the approximate playback position.
func (*Player) ReplayGain ¶ added in v0.3.0
ReplayGain reports whether loudness normalization is enabled.
func (*Player) SeekMS ¶
SeekMS jumps to an absolute position. The actual decoder seek happens on the audio goroutine (see seekSource.Read), so no player is recreated and the decoder is never accessed concurrently — both of which previously aborted the in-process GUI.
func (*Player) SetOnFinish ¶
func (p *Player) SetOnFinish(fn func())
SetOnFinish registers a callback fired when a track ends naturally.
func (*Player) SetReplayGain ¶ added in v0.3.0
SetReplayGain enables/disables loudness normalization for subsequent tracks (and updates the current track immediately).
func (*Player) TogglePause ¶
func (p *Player) TogglePause()
TogglePause flips between playing and paused.