Exemplo n.º 1
0
            internal async void OnSongChange(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args = null)
            {
                var props = await session.TryGetMediaPropertiesAsync();

                string song = $"{props.Title} | {props.Artist}";

                //This is needed because for some reason this method is invoked twice every song change
                if (LastSong != song && !(String.IsNullOrWhiteSpace(props.Title) && String.IsNullOrWhiteSpace(props.Artist)))
                {
                    LastSong = song;
                    OnSongChanged?.Invoke(this, props);
                }
            }
Exemplo n.º 2
0
 private static void SmtcOnMediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
 {
     _mediaProperties = sender.TryGetMediaPropertiesAsync().GetAwaiter().GetResult();
     MainWindow.Window.Dispatcher?.InvokeAsync(UpdateMediaProperties);
 }
Exemplo n.º 3
0
        private void OnMediaPropertiesChanged(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args = null)
        {
            SimpleLogger.DefaultLog("MediaSessionManager::OnMediaPropertiesChanged called...");
            try {
                if (CurrentSessions.ContainsKey(session))
                {
                    var   props    = session.TryGetMediaPropertiesAsync().GetAwaiter().GetResult();
                    var   title    = props.Title;
                    var   artist   = props.Artist;
                    Image albumArt = null;
                    if (props.Thumbnail != null)
                    {
                        using (var winStream = props.Thumbnail.OpenReadAsync().GetAwaiter().GetResult()) {
                            using (var stream = winStream.AsStream()) {
                                if (session.SourceAppUserModelId.ToLower().Contains("spotify"))
                                {
                                    using (var image = Image.FromStream(stream)) {
                                        using (var bitmap = new Bitmap(image)) {
                                            albumArt = bitmap.Clone(new Rectangle(33, 0, 234, 234), bitmap.PixelFormat);
                                        }
                                    }
                                }
                                else
                                {
                                    albumArt = Image.FromStream(stream);
                                }
                            }
                        }
                    }

                    var data = CurrentSessions[session];
                    if (data.Title != title || data.Artist != artist || data.AlbumArt != albumArt)
                    {
                        data.Title               = title;
                        data.Artist              = artist;
                        data.AlbumArt            = albumArt;
                        CurrentSessions[session] = data;
                        UpdateCurrentSong();
                    }
                }
            } catch (Exception e) {
                SimpleLogger.DefaultLog($"MediaSessionManager::OnMediaPropertiesChanged - Exception - {e.Message}\n{e.StackTrace}");
            }
            SimpleLogger.DefaultLog("MediaSessionManager::OnMediaPropertiesChanged DONE");
        }
Exemplo n.º 4
0
 private async void GSMTCSession_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args)
 {
     await Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
     {
         UpdateSessionInfo(session);
     }));
 }
Exemplo n.º 5
0
        private async void CurrentSession_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
        {
            Console.WriteLine("Media properties changed.");

            var newMediaInfo = await GetMediaInfo();

            OnMediaInfoChanged(new MediaInfoChangedEventArgs()
            {
                MediaInfo = newMediaInfo
            });
        }
Exemplo n.º 6
0
        private async void Session_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
        {
            properties = await session.TryGetMediaPropertiesAsync();

            string status = "[MediaPropertiesChanged] Artist: " + properties.Artist + ", Title: " + properties.Title;

            Debug.WriteLine(status);
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Status.Text = status; });
        }
 private async void MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
 {
     await Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
     {
         UpdateMediaProperties();
     }));
 }
Exemplo n.º 8
0
 private void OnMediaChanged(MediaControlSession sender, MediaPropertiesChangedEventArgs args)
 {
     mediaProperties = sender.TryGetMediaPropertiesAsync().GetAwaiter().GetResult();
     CurrentMediaChanged(sender, MediaInfo.FromMediaProperties(mediaProperties));
 }
Exemplo n.º 9
0
 public async void UpdateMediaProperties(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args)
 {
     await Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
     {
         if (session != null && session.GetPlaybackInfo() != null)
         {
             UpdateSessionInfo(session);
         }
     }));
 }
Exemplo n.º 10
0
 private static async void Session_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
 {
     MusicName = (await sender.TryGetMediaPropertiesAsync()).Title;
     await UUID.MiBand2Service.Music.SetMusicName(MusicName);
 }
 private void SpotifySession_MediaPropertiesChanged(object sender, MediaPropertiesChangedEventArgs args)
 {
     HandleSpotifyStateChanged();
 }
Exemplo n.º 12
0
 private void MainPage_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
 {
     WriteCurrentlyPlayingAsync();
 }
Exemplo n.º 13
0
 private void GSMTCSession_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         UpdateSessionInfo(session);
     });
 }
Exemplo n.º 14
0
 private static void GlobalSystemMediaTransportControlsSession_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
 {
     SetPlaybackInfoMediaProperties();
 }