mirror of
https://github.com/figsoda/mmtc
synced 2024-11-22 07:03:05 +00:00
ability to play previous or next song
This commit is contained in:
parent
9c45c782a1
commit
6a4bc936d4
1 changed files with 20 additions and 0 deletions
20
src/main.rs
20
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)
|
||||
|
|
Loading…
Reference in a new issue