diff --git a/src/main.rs b/src/main.rs index 02b3d5e..1eedd70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,8 @@ enum Command { UpdateQueue, UpdateStatus, TogglePause, + Previous, + Next, Play, Reselect, Down, @@ -129,6 +131,12 @@ async fn run() -> Result<()> { KeyCode::Char('p') => { tx.send(Command::TogglePause).await.unwrap_or_else(die); } + KeyCode::Char('H') => { + tx.send(Command::Previous).await.unwrap_or_else(die); + } + KeyCode::Char('L') => { + tx.send(Command::Next).await.unwrap_or_else(die); + } KeyCode::Enter => { tx.send(Command::Play).await.unwrap_or_else(die); } @@ -202,6 +210,18 @@ async fn run() -> Result<()> { tx.send(Command::UpdateStatus).await?; tx.send(Command::UpdateFrame).await?; } + Command::Previous => { + mpd::command(&mut cl, b"previous\n") + .await.context("Failed to play previous song").unwrap_or_else(die); + tx.send(Command::UpdateStatus).await?; + tx.send(Command::UpdateFrame).await?; + } + Command::Next => { + mpd::command(&mut cl, b"next\n") + .await.context("Failed to play previous song").unwrap_or_else(die); + tx.send(Command::UpdateStatus).await?; + tx.send(Command::UpdateFrame).await?; + } Command::Play => { if selected < queue.len() { mpd::play(&mut cl, selected)