Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish win-gsmtc to crates.io? #291

Closed
gyng opened this issue Apr 30, 2023 · 3 comments · Fixed by #292
Closed

Publish win-gsmtc to crates.io? #291

gyng opened this issue Apr 30, 2023 · 3 comments · Fixed by #292

Comments

@gyng
Copy link

gyng commented Apr 30, 2023

I'm toying with GlobalSystemMediaTransportControlsSessionManager and I see you've already put in a bunch of work into getting it usable.

Are there plans to publish it to crates.io as a standalone crate? It seems fairly complete from a quick scan.

@Nerixyz
Copy link
Owner

Nerixyz commented Apr 30, 2023

Yea, I can do that. I'll add some documentation. Keep in mind that it currently depends on tokio. Example usage:

let mut rx = SessionManager::new().await?;
while let Some(evt) = rx.recv().await {
  match evt {
    ManagerEvent::SessionCreated { mut rx, source, .. } => {
      // Sessions have their own stream.
      tokio::spawn(async move {
        while let Some(evt) = rx.recv().await {
          match evt {
              SessionUpdateEvent::Model(model) => {
                  dbg!((&source, &model));
              }
              SessionUpdateEvent::Media(model, image) => {
                  dbg!((&source, &model, &image));
              }
          }
        }
      });
    }
  }
}

There are some design decisions that were made specifically for this project - e.g. SessionUpdateEvent could send the model in an Arc rather than copying it every time.

@Nerixyz
Copy link
Owner

Nerixyz commented Apr 30, 2023

Published as win-gsmtc. While testing, I noticed that on my system, the SessionsChanged event isn't emitted. This seems to be a problem with Windows (ModernFlyouts-Community/ModernFlyouts#29, DubyaDude/WindowsMediaController#6). Maybe there should be a mechanism to manually check for changed sessions.

@gyng
Copy link
Author

gyng commented Apr 30, 2023

Hey, thanks for this! I've cobbled together a toy now playing widget in Tauri using your library: https://github.com/gyng/np-widget/blob/bfd3163d2c769bce2d4a19ec7098c0a970b82f16/np/src/main.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants