audio

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

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 NewPlayer

func NewPlayer() (*Player, error)

NewPlayer creates the audio output context.

func (*Player) AddVolume

func (p *Player) AddVolume(delta float64) float64

AddVolume nudges the volume by delta and returns the new value.

func (*Player) DurationMS

func (p *Player) DurationMS() int64

DurationMS returns the current track duration (from metadata).

func (*Player) Format

func (p *Player) Format() string

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) LastError

func (p *Player) LastError() string

LastError returns the last playback error message ("" if none).

func (*Player) Pause

func (p *Player) Pause()

Pause halts output, keeping position.

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

func (p *Player) PositionMS() int64

PositionMS returns the approximate playback position.

func (*Player) Resume

func (p *Player) Resume()

Resume continues from a paused state.

func (*Player) SeekMS

func (p *Player) SeekMS(ms int64)

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) State

func (p *Player) State() State

State returns the current playback state.

func (*Player) Stop

func (p *Player) Stop()

Stop ends playback and releases the current player.

func (*Player) TogglePause

func (p *Player) TogglePause()

TogglePause flips between playing and paused.

func (*Player) Volume

func (p *Player) Volume() float64

Volume returns the current volume (0..1).

type State

type State int

State is the player's lifecycle state.

const (
	Stopped State = iota
	Loading
	Playing
	Paused
	Errored
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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