Documentation
¶
Overview ¶
Package librespot manages the lifecycle of an external librespot subprocess: spawning it with the configured bitrate, backend, and device name; watching stdout for connection/state events; piping PCM audio to the audio package when backend=="pipe"; and invoking user-supplied callbacks on reconnect and inactivity.
Process is the single orchestrator. Start launches the binary and begins log scanning; Stop sends SIGTERM and waits. OnReconnect fires after librespot re-registers with Spotify (used to transfer playback back to the preferred device); OnInactive fires when the device has been idle long enough that the UI may want to release it.
Index ¶
Constants ¶
const ( DefaultBackend = "pipe" DefaultDeviceName = "tuify" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BinaryPath string // path to librespot binary, default "librespot"
DeviceName string // Spotify Connect device name, default DefaultDeviceName
Bitrate int // 96, 160, or 320; default 320
Backend string // audio backend: DefaultBackend ("pipe"), "pulseaudio", etc.
Username string // Spotify username for direct auth (avoids zeroconf key issues)
CacheDir string // directory for librespot credential/audio cache
}
Config holds librespot launch parameters.
type Process ¶
type Process struct {
OnReconnect func() // called when librespot authenticates (initial or restart)
OnInactive func() // called when librespot reports device became inactive
OnStdout func(io.ReadCloser) // called with the stdout pipe in launch(); for pipe backend audio
// contains filtered or unexported fields
}
Process manages a librespot child process with automatic restart on crash.
func NewProcess ¶
NewProcess creates a new Process with the given configuration.