| Crates.io | async-mpd |
| lib.rs | async-mpd |
| version | 0.6.0 |
| created_at | 2020-05-28 17:47:35.695459+00 |
| updated_at | 2021-08-29 13:16:32.30278+00 |
| description | Async Mpd client library |
| homepage | |
| repository | https://github.com/jkristell/async-mpd |
| max_upload_size | |
| id | 247107 |
| size | 73,909 |
Runtime agnostic Mpd client library for Rust
use tokio as runtime;
// For async-std instead
//use async_std as runtime;
use async_mpd::{MpdClient, cmd};
#[runtime::main]
async fn main() -> Result<(), async_mpd::Error> {
// Connect to server
let mut mpd = MpdClient::new();
mpd.connect("localhost:6600").await?;
// Get all tracks in the play queue and display them
let queue = mpd.queue().await?;
for track in queue {
println!("{:?} - {:?}", track.artist, track.title);
}
// Play track nr 2 in the queue
mpd.playid(2).await?;
// Get and print the current server status using the command api
let status = mpd.exec(cmd::Status).await?;
println!("{:?}", status);
// Set the volume to 50%
mpd.setvol(50).await?;
Ok(())
}