Workstream C: extract player sleep-timer/autoplay and session commands into submodules

- commands/player/timers.rs: sleep-timer + autoplay commands (8).
- commands/player/session.rs: media session get/dismiss commands (2).
- Make create_media_item and get_player_status pub(super) so the submodules can
  reuse them. mod.rs shrinks from ~2720 to ~2229 lines; invoke_handler unchanged.
This commit is contained in:
2026-06-20 16:32:29 +02:00
parent 8ddad497bf
commit d1e5ba4c5d
3 changed files with 281 additions and 254 deletions
+43
View File
@@ -0,0 +1,43 @@
//! Media session state commands.
//!
//! Read and dismiss the current media session (the Now Playing surface backing
//! lockscreen/notification controls).
use tauri::State;
use super::{MediaSessionManagerWrapper, PlayerStateWrapper};
use crate::player::PlayerStatusEvent;
/// Get the current media session state
#[tauri::command]
pub async fn player_get_session(
session: State<'_, MediaSessionManagerWrapper>,
) -> Result<crate::player::session::MediaSessionType, String> {
let manager = session.0.lock().map_err(|e| e.to_string())?;
Ok(manager.current().clone())
}
/// Dismiss the current media session (returns to Idle)
#[tauri::command]
pub async fn player_dismiss_session(
session: State<'_, MediaSessionManagerWrapper>,
player: State<'_, PlayerStateWrapper>,
) -> Result<(), String> {
log::info!("[Session] Dismissing current media session");
// Dismiss the session
{
let mut manager = session.0.lock().map_err(|e| e.to_string())?;
manager.dismiss();
}
// Emit session changed event
if let Some(emitter) = player.0.lock().await.event_emitter() {
let manager = session.0.lock().map_err(|e| e.to_string())?;
emitter.emit(PlayerStatusEvent::SessionChanged {
session: manager.current().clone(),
});
}
Ok(())
}