Expand description
Audio playback engine for MoosicBox.
This crate provides the core playback functionality for the MoosicBox music player,
handling audio decoding, streaming, and playback control. It supports both local file
playback and remote streaming from various audio sources.
§Features
- Playback session management with
PlaybackandPlaybackHandler - Multiple audio formats (AAC, FLAC, MP3, Opus) via feature flags
- Audio streaming and buffering with configurable quality settings
- Retry logic for robust playback with
PlaybackRetryOptions - Volume control and seeking capabilities
- Support for both local and remote playback sources
§Main Entry Points
PlaybackHandler- Manages playback operations for tracks and albumsPlayer- Trait for implementing custom playback playersPlayback- Represents an active playback sessionPlayerError- Error types for player operations
§Examples
// Create a playback handler with a custom player implementation
let mut handler = PlaybackHandler::new(player);
// Play a track
handler.play_track(
session_id,
profile,
track,
None, // seek position
Some(0.8), // volume
quality,
None, // playback target
None, // retry options
).await?;Modules§
- api
- HTTP API endpoints for playback control.
- local
- Local audio player implementation.
- signal_
chain - Audio signal processing chain for encoding and decoding. Audio signal processing chain for encoding and decoding.
- symphonia
- Asynchronous audio file playback using Symphonia. Asynchronous audio file playback using Symphonia.
- symphonia_
unsync - Synchronous audio decoding using Symphonia. Synchronous audio decoding using Symphonia.
- volume_
mixer - Volume control and mixing utilities. Volume control and mixing utilities.
Structs§
- ApiPlayback
- API representation of a playback session.
- ApiPlayback
Status - API representation of playback status.
- Playable
Track - A track ready for playback with its media source.
- Playback
- Represents an active playback session.
- Playback
Handler - Manages playback operations for a player.
- Playback
Retry Options - Configuration for retry behavior during playback operations.
- Playback
Status - Status response for playback operations.
Enums§
- Playback
Type - Specifies the type of playback method to use.
- Player
Error - Errors that can occur during player operations.
- Player
Source - Identifies the source of playback.
Constants§
- DEFAULT_
PLAYBACK_ RETRY_ OPTIONS - Default retry options for playback operations.
- DEFAULT_
SEEK_ RETRY_ OPTIONS - Default retry options for seek operations.
Statics§
- CLIENT
- Global HTTP client for making requests.
- SERVICE_
PORT - Global service port configuration.
Traits§
- Player
- Trait for implementing custom playback players.
Functions§
- get_
session_ playlist_ id_ from_ session_ id - Retrieves the playlist ID associated with a session ID.
- get_
track_ url - Constructs the URL for streaming a track.
- on_
playback_ event - Registers a callback to be invoked when playback state changes.
- send_
playback_ event - Notifies all registered listeners of a playback event.
- set_
service_ port - Sets the service port for local playback.
- trigger_
playback_ event - Triggers playback events for registered listeners when playback state changes.