question

MarcelLorenz-8156 avatar image
0 Votes"
MarcelLorenz-8156 asked ·

Properly integrate GlobalSystemMediaTransportControlsSession

I use the MediaPlayerElement from Microsoft.Toolkit.Forms.UI.Controls. Now I want to properly integrate the GlobalSystemMediaTransportControlsSession. I can be read out using the GlobalSystemMediaTransportControlsSessionManager but I cannot control the session using for example TryPauseAsync, TryPlayAsync, TrySkipNextAsync, TrySkipPreviousAsync, ... Also I want to set the metadata like Title, Artist, State, and TimelineProperties.

How can I do this?

dotnet-csharp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered ·

Methods such as TryPauseAsync and TryPlayAsync belong to GlobalSystemMediaTransportControlsSession instead of GlobalSystemMediaTransportControlsSessionManager. We should be free to use these methods according to the GlobalSystemMediaTransportControlsSession object.

             GlobalSystemMediaTransportControlsSession currentSession = GlobalSystemMediaTransportControlsSessionManager.RequestAsync().GetAwaiter().GetResult().GetCurrentSession();
             await currentSession.TryPlayAsync();
            //......

How are you using them?

Also I want to set the metadata like Title, Artist, State, and TimelineProperties.

I did not find a way to do this, it seems that the current API does not support this.

Maybe you can refer to the solution in this link and use other packages to do it.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yeah, I know the methods belong to a session and not the session manager. I only said I was able to read out the session but I was not able to control it. I call the methods on the session and nothing happens, also the PlaybackState is not updated, when controlling it inside the application or when using virtual keycodes send from my keyboard and the event for playback info is not called.

Also, it has to be possible because non-UWP apps like Chrome or Spotify support these sessions and can set the metadata.

0 Votes 0 ·

@MarcelLorenz-8156
Could you please provide a piece of code that can reproduce the problem for us to test?

Also, it has to be possible because non-UWP apps like Chrome or Spotify support these sessions and can set the metadata.

What I mean is that the current API may not support setting metadata, because I did not find the relevant methods or properties.
0 Votes 0 ·