private MediaControlSession CurrentSession() { MediaControlSession session = sessionManager?.GetCurrentSession(); if (currentSession != session) { currentSession = session; if (currentSession == null) { return(null); } currentSession.MediaPropertiesChanged += OnMediaChanged; currentSession.PlaybackInfoChanged += OnPlaybackInfoChanged; //currentSession.TimelinePropertiesChanged += OnTimelinePropertiesChanged; } return(currentSession); }
private void OnPlaybackInfoChanged(MediaControlSession sender, PlaybackInfoChangedEventArgs args) { GlobalSystemMediaTransportControlsSessionPlaybackInfo playbackInfo = CurrentSession()?.GetPlaybackInfo(); PlaybackInfoChanged?.Invoke(sender, playbackInfo); }
private void OnMediaChanged(MediaControlSession sender, MediaPropertiesChangedEventArgs args) { mediaProperties = sender.TryGetMediaPropertiesAsync().GetAwaiter().GetResult(); CurrentMediaChanged(sender, MediaInfo.FromMediaProperties(mediaProperties)); }