use mediactl::{list_players, MediaPlayer};

fn main() {
    match list_players() {
        Ok(players) => {
            println!("Found {} player(s):", players.len());
            for player in &players {
                println!("\n  {}", player.name());
                println!("    bus: {}", player.bus_name());
                if let Ok(status) = player.status() {
                    println!("    status: {:?}", status);
                }
                if let Ok(meta) = player.metadata() {
                    if let Some(title) = &meta.title {
                        println!("    title: {title}");
                    }
                    if let Some(artist) = &meta.artist {
                        println!("    artist: {artist}");
                    }
                    if let Some(album) = &meta.album {
                        println!("    album: {album}");
                    }
                }
            }
        }
        Err(e) => eprintln!("Error: {e}"),
    }
}
