Skip to main content

basic/
basic.rs

1use playerctl_rust_wrapper::Playerctl;
2
3fn main() {
4    // Command the player to play
5    Playerctl::play().unwrap_or_default();
6
7    // Command the player to pause
8    Playerctl::pause().unwrap_or_default();
9
10    // Command the player to toggle between play/pause
11    Playerctl::play_pause().unwrap_or_default();
12
13    // Command the player to seek forward/backward OFFSET in seconds
14    Playerctl::position(10.).unwrap_or_default();
15
16    // Get metadata information for the current track
17    let metadata = Playerctl::metadata().unwrap_or_default();
18
19    println!(
20        "Title: {}\nAlbum: {}\nArtist: {}\nURL: {}\nLength: {}",
21        metadata.title, metadata.album, metadata.artist, metadata.url, metadata.length
22    )
23}