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:
@@ -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(())
|
||||
}
|
||||
Reference in New Issue
Block a user