Crate gsmtc

Crate gsmtc 

Source
Expand description

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"),
    }
}

Structs§

AlbumModel
Holds information about an album.
Image
An image read from a IRandomAccessStreamWithContentType.
MediaModel
Holds information about the content that the current session has.
PlaybackModel
The object that holds all of the playback information about a session (Play state, playback type etc.).
SessionManager
This is the main worker. It listens to the added/removed sessions.
SessionModel
Represents a playback session from another app providing info about that session.
TimelineModel
Represents the timeline state of the session (Position, seek ranges etc.).

Enums§

AutoRepeatMode
Specifies the auto repeat mode for media playback.
ManagerEvent
Events emitted by a SessionManager.
PlaybackStatus
The different states of playback the session could be in.
PlaybackType
Defines values for the types of media playback.
SessionUpdateEvent
Events emitted by an internal session-worker.