mprizzle/lib.rs
1#![allow(unused_imports)]
2
3//! # mprizzle
4//! An async library for interacting with mpris over D-Bus.
5//!
6//! # Usage
7//!
8//! ```no_run
9//! use mprizzle::{Mpris, MprisEvent};
10//!
11//! #[tokio::main]
12//! pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
13//! let mut mpris = Mpris::new_without_options().await?;
14//! let shared_players = mpris.players();
15//!
16//! // Start watching for mpris events.
17//! mpris.watch();
18//!
19//! while let Ok(event) = mpris.recv().await? {
20//! match event {
21//! // Player Attached / Detached events.
22//! MprisEvent::PlayerAttached(identity) => println!("NEW PLAYER = {}", identity.short()),
23//! MprisEvent::PlayerDetached(identity) => println!("REMOVED PLAYER = {}", identity.short()),
24//!
25//! // Player properties changed event.
26//! MprisEvent::PlayerPropertiesChanged(identity) => {
27//! let players = shared_players.lock().await;
28//! if let Some(player) = players.iter().find(|p| *p.identity() == identity) {
29//! println!("PLAYER PROP CHANGED: {} = {:#?}", identity.short(), player.metadata().await?);
30//! }
31//! },
32//!
33//! // Player seeked event.
34//! MprisEvent::PlayerSeeked(identity) => {
35//! let players = shared_players.lock().await;
36//! if let Some(_) = players.iter().find(|p| *p.identity() == identity) {
37//! println!("PLAYER SEEKED: {}", identity.short());
38//! }
39//! },
40//!
41//! // Player position event.
42//! MprisEvent::PlayerPosition(identity, position) => {
43//! println!("PLAYER POSITION: {} = {}", identity.short(), position.as_secs());
44//! }
45//! }
46//! }
47//!
48//! Ok(())
49//! }
50//! ```
51
52mod mprizzle;
53pub use mprizzle::*;
54
55mod identity;
56pub use identity::*;
57
58mod metadata;
59pub use metadata::*;
60
61mod player;
62pub use player::*;
63
64mod status;
65pub use status::*;
66
67mod proxies;