song insertion state check

This commit is contained in:
krolxon 2024-04-22 14:39:36 +05:30
parent 579b09b61d
commit bc0348ec5b
1 changed files with 4 additions and 3 deletions

View File

@ -1,7 +1,6 @@
use mpd::song::Song;
use mpd::Client;
use mpd::{Client, State};
use simple_dmenu::dmenu;
use std::process::Command;
pub struct Connection {
pub conn: Client,
@ -37,12 +36,14 @@ impl Connection {
}
fn push(&mut self, song: &Song) {
self.conn.push(song).unwrap();
if self.conn.queue().unwrap().is_empty() {
self.conn.push(song).unwrap();
self.conn.play().unwrap();
} else {
self.conn.push(song).unwrap();
if self.conn.status().unwrap().state == State::Stop {
self.conn.play().unwrap();
}
self.conn.next().unwrap();
}
}