BackgroundAudioTask.MyBackgroundAudioTask.PlaybackList_CurrentItemChanged C# (CSharp) Method

PlaybackList_CurrentItemChanged() private method

Raised when playlist changes to a new track
private PlaybackList_CurrentItemChanged ( MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args ) : void
sender MediaPlaybackList
args CurrentMediaPlaybackItemChangedEventArgs
return void
        void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            //Uri s =    GetCurrentTrackId();

            // Get the new item
            var item = args.NewItem;
            Debug.WriteLine("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : Convert.ToString(GetTrackId(item))));

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            Uri currentTrackId = null;
            if (item != null)
            {
                string trackIdKey = item.Source.CustomProperties[TrackIdKey].ToString();
                currentTrackId = new Uri(trackIdKey);
            }

            ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.TrackId, currentTrackId == null ? null : currentTrackId.ToString());
            MessageService.SendMessageToForeground(new TrackChangedMessage(currentTrackId));
        }