2026-02-26 19:58:37 +01:00
|
|
|
//! État partagé du renderer (backend ↔ pipeline)
|
2026-02-09 07:18:13 +01:00
|
|
|
|
|
|
|
|
use parking_lot::RwLock;
|
2026-04-05 10:52:54 +02:00
|
|
|
use serde_json::Value;
|
2026-02-09 07:18:13 +01:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2026-02-26 19:58:37 +01:00
|
|
|
use crate::messages::PlaybackState;
|
2026-02-09 07:18:13 +01:00
|
|
|
|
|
|
|
|
/// État temps-réel du renderer (partagé backend ↔ navigateur)
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct RendererState {
|
|
|
|
|
pub playback_state: PlaybackState,
|
|
|
|
|
pub current_uri: Option<String>,
|
|
|
|
|
pub current_metadata: Option<String>,
|
2026-02-21 10:16:49 +01:00
|
|
|
pub next_uri: Option<String>,
|
|
|
|
|
pub next_metadata: Option<String>,
|
2026-02-09 07:18:13 +01:00
|
|
|
pub position: Option<String>,
|
|
|
|
|
pub duration: Option<String>,
|
|
|
|
|
pub volume: u16,
|
|
|
|
|
pub mute: bool,
|
2026-04-05 10:52:54 +02:00
|
|
|
/// Commande en attente pour le player frontend (polled via /command)
|
|
|
|
|
pub player_command: Option<Value>,
|
2026-02-09 07:18:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for RendererState {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
playback_state: PlaybackState::Stopped,
|
|
|
|
|
current_uri: None,
|
|
|
|
|
current_metadata: None,
|
2026-02-21 10:16:49 +01:00
|
|
|
next_uri: None,
|
|
|
|
|
next_metadata: None,
|
2026-02-09 07:18:13 +01:00
|
|
|
position: None,
|
|
|
|
|
duration: None,
|
|
|
|
|
volume: 100,
|
|
|
|
|
mute: false,
|
2026-04-05 10:52:54 +02:00
|
|
|
player_command: None,
|
2026-02-09 07:18:13 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Alias pour l'état partagé
|
|
|
|
|
pub type SharedState = Arc<RwLock<RendererState>>;
|