|
|
|
|
@ -8,6 +8,7 @@ pub struct SongMetadata
|
|
|
|
|
pub artist: String,
|
|
|
|
|
pub album: String,
|
|
|
|
|
pub art_url: String,
|
|
|
|
|
pub is_playing: bool,
|
|
|
|
|
}
|
|
|
|
|
impl SongMetadata
|
|
|
|
|
{
|
|
|
|
|
@ -18,6 +19,7 @@ impl SongMetadata
|
|
|
|
|
artist: "NONE".to_string(),
|
|
|
|
|
album: "NONE".to_string(),
|
|
|
|
|
art_url: "NONE".to_string(),
|
|
|
|
|
is_playing: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -32,6 +34,10 @@ pub fn get_song_metadata() -> SongMetadata
|
|
|
|
|
|
|
|
|
|
let result = run_command(&command);
|
|
|
|
|
|
|
|
|
|
let command = format!("{} {}", COM_START, "status");
|
|
|
|
|
let status = run_command(&command).to_ascii_lowercase();
|
|
|
|
|
let status = status.trim();
|
|
|
|
|
|
|
|
|
|
let mut sm = SongMetadata::new();
|
|
|
|
|
|
|
|
|
|
let split: Vec<&str> = result.split(',').collect();
|
|
|
|
|
@ -46,6 +52,12 @@ pub fn get_song_metadata() -> SongMetadata
|
|
|
|
|
sm.album = split[2].to_string();
|
|
|
|
|
sm.art_url = split[3].to_string();
|
|
|
|
|
sm.art_url = sm.art_url.trim().to_string();
|
|
|
|
|
sm.is_playing = if status == "paused" {
|
|
|
|
|
false
|
|
|
|
|
} else {
|
|
|
|
|
true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let test_url = sm.art_url.trim_start_matches("file://").to_string();
|
|
|
|
|
// let test_url = test_url.trim();
|
|
|
|
|
@ -90,6 +102,18 @@ pub fn next_track()
|
|
|
|
|
let _ = run_command(&command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn play()
|
|
|
|
|
{
|
|
|
|
|
let command = format!("{} {}", COM_START, "play");
|
|
|
|
|
let _ = run_command(&command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn pause()
|
|
|
|
|
{
|
|
|
|
|
let command = format!("{} {}", COM_START, "pause");
|
|
|
|
|
let _ = run_command(&command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn run_command(command: &str) -> String
|
|
|
|
|
{
|
|
|
|
|
|