ability to play previous or next song

This commit is contained in:
figsoda 2020-11-01 19:19:46 -05:00
parent 9c45c782a1
commit 6a4bc936d4

View file

@ -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)