Windows GlobalSystemMediaTransportControlsSession Events Not Fired in Service

Viewed 80

I'm trying to listen to events dispatched by GlobalSystemMediaTransportControlsSession in a Windows Service (in Rust).

I made a reproduction repository with instructions.

The most important part is this:

session.PlaybackInfoChanged(TypedEventHandler::new(move |_, _| {
  tx.send(()).ok();
  Ok(())
}))

Here a new event handler is created that listens on every open application that emits SMTC metadata for changes to the playback, i.e. play/pause/stop events.

Once the event is fired, the application terminates (rx receives an event).

This works fine in a "regular" executable (e.g. by running cargo run).

However, once I'm running this as a service (through nssm*), no event is emitted (the log-file is not created/written to).

I couldn't find any documentation by Microsoft related to services and events. Is there a workaround, am I doing something wrong or is this known to not be supported?

(*) I'm using nssm here, but the same happens when I'm running the executable as a service. This however would include unnecessary code for managing the service. So I'd guess the problem is that the executable doesn't run with the user-account. Then I'm wondering why I can get the sessions, and even metadata, in the first place and no error is thrown/emitted.

0 Answers
Related