Workstream C: extract player settings and queue-manipulation commands into submodules
- commands/player/settings.rs: audio/video settings commands (4). - commands/player/queue.rs: queue add/remove/move/skip + by-id commands (6) and their request DTOs. - Make check_for_local_download and get_queue_status pub(super) for reuse. - mod.rs now ~1834 lines (from 2720); invoke_handler unchanged, all tests pass.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
//! Audio and video playback settings commands.
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use super::{PlayerStateWrapper, VideoSettingsWrapper};
|
||||
use crate::player::AutoplaySettings;
|
||||
use crate::settings::{AudioSettings, VideoSettings};
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn player_set_audio_settings(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
settings: AudioSettings,
|
||||
) -> Result<AudioSettings, String> {
|
||||
let mut controller = player.0.lock().await;
|
||||
controller
|
||||
.set_audio_settings(&settings)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(controller.audio_settings())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn player_get_audio_settings(
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
) -> Result<AudioSettings, String> {
|
||||
let controller = player.0.lock().await;
|
||||
Ok(controller.audio_settings())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn player_set_video_settings(
|
||||
video_settings: State<'_, VideoSettingsWrapper>,
|
||||
player: State<'_, PlayerStateWrapper>,
|
||||
settings: VideoSettings,
|
||||
) -> Result<VideoSettings, String> {
|
||||
let validated = settings.with_countdown_clamped();
|
||||
{
|
||||
let mut current = video_settings.0.lock().map_err(|e| e.to_string())?;
|
||||
*current = validated.clone();
|
||||
} // Drop MutexGuard before await
|
||||
|
||||
// Sync to PlayerController's autoplay settings so on_playback_ended() uses current values
|
||||
let controller = player.0.lock().await;
|
||||
controller.set_autoplay_settings(AutoplaySettings {
|
||||
enabled: validated.auto_play_next_episode,
|
||||
countdown_seconds: validated.auto_play_countdown_seconds,
|
||||
max_episodes: validated.auto_play_max_episodes,
|
||||
});
|
||||
|
||||
Ok(validated)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn player_get_video_settings(
|
||||
video_settings: State<'_, VideoSettingsWrapper>,
|
||||
) -> Result<VideoSettings, String> {
|
||||
let current = video_settings.0.lock().map_err(|e| e.to_string())?;
|
||||
Ok(current.clone())
|
||||
}
|
||||
Reference in New Issue
Block a user