win-gsmtc

Crates.iowin-gsmtc
lib.rswin-gsmtc
version0.1.0
sourcesrc
created_at2023-04-30 12:39:41.55055
updated_at2023-04-30 12:39:41.55055
descriptionA wrapper around the Windows.Media.Control namespace (GlobalSystemMediaTransportControls - GSMTC)
homepage
repositoryhttps://github.com/Nerixyz/current-song2
max_upload_size
id852733
size52,454
nerix (Nerixyz)

documentation

README

win-gsmtc

This library is a wrapper around the Windows.Media.Control namespace (aka GlobalSystemMediaTransportControls - GSMTC). It uses tokio to manage internal workers that deliver updates.

Example

use gsmtc::{ManagerEvent::*, SessionUpdateEvent::*};

let mut rx = gsmtc::SessionManager::create().await?;

while let Some(evt) = rx.recv().await {
    match evt {
        SessionCreated {
            session_id,
            mut rx,
            source,
        } => {
            println!("Created session: {{id={session_id}, source={source}}}");
            tokio::spawn(async move {
                while let Some(evt) = rx.recv().await {
                    match evt {
                        Model(model) => {
                            println!("[{session_id}/{source}] Model updated: {model:#?}")
                        }
                        Media(model, image) => println!(
                            "[{session_id}/{source}] Media updated: {model:#?} - {image:?}"
                        ),
                    }
                }
                println!("[{session_id}/{source}] exited event-loop");
            });
        }
        SessionRemoved { session_id } => println!("Session {{id={session_id}}} was removed"),
        CurrentSessionChanged {
            session_id: Some(id),
        } => println!("Current session: {id}"),
        CurrentSessionChanged { session_id: None } => println!("No more current session"),
    }
}
Commit count: 169

cargo fmt