Add player interpret and track

This commit is contained in:
2024-03-24 14:49:40 +01:00
parent 9d93976d85
commit e44fa474d9
3 changed files with 40 additions and 0 deletions

View File

@@ -1,3 +1,17 @@
mod player;
use mpris::PlayerFinder;
fn main() {
println!("Hello, world!");
let player = PlayerFinder::new()
.expect("Could not connect to D-Bus")
.find_active()
.expect("Could not find any player");
let metadata = player.get_metadata().expect("Could not find metadata");
if let (Some(title), Some(artists)) = (metadata.title(), metadata.artists()) {
let artist = artists.join(", ");
println!("Current track: {artist} - {title}");
}
}