player

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSampleRate   = beep.SampleRate(44100)
	SpeakerBufferSize   = time.Millisecond * 250
	NetworkReadSize     = 4096
	SampleChannelSize   = 8192
	MaxRetries          = 3
	RetryDelay          = time.Second * 2
	VolumeCurveExponent = 0.5
	MinVolumeDB         = -10.0
	ReadTimeout         = 10 * time.Second
	MaxErrorsToKeep     = 10 // Limit error accumulation during retries
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Player

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

Player handles audio streaming and playback for SomaFM radio stations. It manages the audio pipeline including network streaming, decoding, buffering, and volume control.

func NewPlayer

func NewPlayer(bufferSeconds int) *Player

NewPlayer creates a new Player with the specified buffer size in seconds.

func (*Player) GetBufferFillPercent

func (p *Player) GetBufferFillPercent() int

func (*Player) GetBufferHealth

func (p *Player) GetBufferHealth() int

GetBufferHealth returns the current buffer fill level as a percentage (0-100).

func (*Player) GetCurrentStation

func (p *Player) GetCurrentStation() *station.Station

func (*Player) GetCurrentTrack

func (p *Player) GetCurrentTrack() string

func (*Player) GetLastError

func (p *Player) GetLastError() string

func (*Player) GetRetryInfo

func (p *Player) GetRetryInfo() (current, max int)

func (*Player) GetSessionDuration

func (p *Player) GetSessionDuration() time.Duration

func (*Player) GetState

func (p *Player) GetState() PlayerState

func (*Player) GetStreamInfo

func (p *Player) GetStreamInfo() StreamInfo

func (*Player) IsPaused

func (p *Player) IsPaused() bool

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

func (*Player) Play

func (p *Player) Play(s *station.Station) error

func (*Player) PlayWithRetry

func (p *Player) PlayWithRetry(s *station.Station, maxRetries int) error

func (*Player) SetInitialTrack

func (p *Player) SetInitialTrack(track string)

func (*Player) SetVolume

func (p *Player) SetVolume(volumePercent int)

func (*Player) Stop

func (p *Player) Stop()

func (*Player) TogglePause

func (p *Player) TogglePause()

type PlayerState

type PlayerState int
const (
	StateIdle PlayerState = iota
	StateBuffering
	StatePlaying
	StatePaused
	StateReconnecting
	StateError
)

func (PlayerState) String

func (s PlayerState) String() string

type StreamInfo

type StreamInfo struct {
	Format     string
	Quality    string
	Bitrate    int
	SampleRate int
}

StreamInfo contains metadata about the current audio stream.

Jump to

Keyboard shortcuts

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