use std::path::PathBuf;
use crossbeam_channel::{Receiver, Sender, bounded};
use super::state::{PlaylistItem, QueueItemId};
#[derive(Debug)]
pub enum PlayerCommand {
Play(QueueItemId),
Pause,
Resume,
Stop,
Seek(u64), NextTrack,
PrevTrack,
AddToPlaylist(Vec<PlaylistItem>),
RemoveFromPlaylist(QueueItemId),
RemoveFromPlaylistBatch(Vec<QueueItemId>),
MoveInPlaylist {
id: QueueItemId,
target: QueueItemId,
after: bool,
},
MoveItemsInPlaylist {
ids: Vec<QueueItemId>,
target: QueueItemId,
after: bool,
},
UpdatePaths(Vec<(QueueItemId, PathBuf)>),
InsertInPlaylist {
items: Vec<PlaylistItem>,
after: QueueItemId,
},
ClearPlaylist,
TrackReady(QueueItemId),
TrackStreamReady(QueueItemId),
DecodeFinished,
Undo,
Redo,
BeginUndoBatch,
EndUndoBatch,
SetOutputDevice(String),
ClearOutputDevice,
}
pub struct CommandChannel {
pub tx: Sender<PlayerCommand>,
pub rx: Receiver<PlayerCommand>,
}
impl Default for CommandChannel {
fn default() -> Self {
Self::new()
}
}
impl CommandChannel {
pub fn new() -> Self {
let (tx, rx) = bounded(16);
Self { tx, rx }
}
}