Skip to main content

Crate moosicbox_player

Crate moosicbox_player 

Source
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 Playback and PlaybackHandler
  • 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 albums
  • Player - Trait for implementing custom playback players
  • Playback - Represents an active playback session
  • PlayerError - 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.
ApiPlaybackStatus
API representation of playback status.
PlayableTrack
A track ready for playback with its media source.
Playback
Represents an active playback session.
PlaybackHandler
Manages playback operations for a player.
PlaybackRetryOptions
Configuration for retry behavior during playback operations.
PlaybackStatus
Status response for playback operations.

Enums§

PlaybackType
Specifies the type of playback method to use.
PlayerError
Errors that can occur during player operations.
PlayerSource
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.