//! Playback-related types for QBZ //! //! This module contains types related to audio playback: //! - Queue track representation //! - Repeat mode //! - Queue state snapshots //! - Playback state use serde::{Deserialize, Serialize}; // ============ Queue Types ============ /// Track info stored in the queue #[derive(Debug, Clone, Serialize, Deserialize)] pub struct QueueTrack { pub id: u64, pub title: String, /// Subtitle/edition info from Qobuz (e.g. "Player's Ball Mix") that /// the frontend renders parenthesized after the title (issue #360). #[serde(default)] pub version: Option, pub artist: String, pub album: String, pub duration_secs: u64, pub artwork_url: Option, #[serde(default)] pub hires: bool, pub bit_depth: Option, pub sample_rate: Option, /// Whether this is a local library track (not from streaming service) #[serde(default)] pub is_local: bool, /// Album ID for navigation pub album_id: Option, /// Artist ID for navigation pub artist_id: Option, /// Whether the track is streamable (false = removed/unavailable) #[serde(default = "default_streamable")] pub streamable: bool, /// Source identifier (e.g., "qobuz", "local", "plex") #[serde(default)] pub source: Option, /// Parental advisory / explicit content #[serde(default)] pub parental_warning: bool, /// Opaque identifier of the Mixtape/Collection item that produced this track, /// used by v2_skip_to_next_item / v2_skip_to_previous_item to detect boundaries. /// For non-Mixtape enqueue paths, set to the track's album_id so boundary /// detection still works for "play album" flows. None is a safe fallback /// (the skip commands fall back to album_id when this is absent). #[serde(default, skip_serializing_if = "Option::is_none")] pub source_item_id_hint: Option, } fn default_streamable() -> bool { true } /// Repeat mode options #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum RepeatMode { Off, All, One, } impl Default for RepeatMode { fn default() -> Self { Self::Off } } /// Queue state snapshot for frontend #[derive(Debug, Clone, Serialize)] pub struct QueueState { pub current_track: Option, pub current_index: Option, pub upcoming: Vec, pub history: Vec, pub shuffle: bool, pub repeat: RepeatMode, pub total_tracks: usize, pub stop_after_track_id: Option, } // ============ Playback State ============ /// Current playback state #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum PlaybackState { /// No track loaded Stopped, /// Track loaded and playing Playing, /// Track loaded but paused Paused, /// Loading/buffering track Loading, } impl Default for PlaybackState { fn default() -> Self { Self::Stopped } } /// Detailed playback status with position and duration #[derive(Debug, Clone, Serialize)] pub struct PlaybackStatus { pub state: PlaybackState, pub track_id: Option, pub position_secs: u64, pub duration_secs: u64, pub volume: f32, /// Sample rate of currently playing track (Hz) pub sample_rate: Option, /// Bit depth of currently playing track pub bit_depth: Option, } impl Default for PlaybackStatus { fn default() -> Self { Self { state: PlaybackState::Stopped, track_id: None, position_secs: 0, duration_secs: 0, volume: 1.0, sample_rate: None, bit_depth: None, } } } // Note: Audio backend types (AudioBackendType, AudioDevice, etc.) are defined // in qbz-audio crate to keep the audio module self-contained and immutable.