private static async Task UpdateMediaControls() { if (MediaControls == null) { return; } MediaControls.PlaybackStatus = (LastPlayStatus.IsPlaying) ? MediaPlaybackStatus.Playing : MediaPlaybackStatus.Paused; MediaControls.DisplayUpdater.MusicProperties.Title = LastPlayStatus.SongName; MediaControls.DisplayUpdater.MusicProperties.AlbumTitle = LastPlayStatus.AlbumName; MediaControls.DisplayUpdater.MusicProperties.Artist = LastPlayStatus.ArtistName; try { var albumArt = await SongImageProvider.GetAlbumArt(LastPlayStatus.AlbumId); if (string.IsNullOrEmpty(albumArt)) { MediaControls.DisplayUpdater.Thumbnail = null; } else { MediaControls.DisplayUpdater.Thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(albumArt)); } } catch { } MediaControls.DisplayUpdater.Update(); }
internal static async void SendPlaybackToLyricsViewer() { if (!isLyricsViewerInstalled) { return; } try { var currentSong = new CurrentPlayingSongInfo { ArtistName = PlayStatusTracker.LastPlayStatus.ArtistName, AlbumName = PlayStatusTracker.LastPlayStatus.AlbumName, SongName = PlayStatusTracker.LastPlayStatus.SongName, AlbumArtUri = await SongImageProvider.GetAlbumArt(PlayStatusTracker.LastPlayStatus.AlbumId), }; await SendPlaybackToLyricsViewer(currentSong); } catch (Exception ex) { logger.Warn("SendPlaybackToLyricsViewer failed: " + ex.ToString()); } }
private async Task Update() { if (ViewModel.ProgressBarValue != ViewModel.ProgressBarMaximum && PlayStatusTracker.LastPlayStatus.ProgressedMilliseconds == ViewModel.ProgressBarMaximum) { // Song just reached the end. refresh status now. RefreshPlayStatus(); } ViewModel.ProgressBarMaximum = PlayStatusTracker.LastPlayStatus.SongLengthMilliseconds; ViewModel.ProgressBarValue = PlayStatusTracker.LastPlayStatus.ProgressedMilliseconds; ViewModel.IsPlaying = PlayStatusTracker.LastPlayStatus.IsPlaying; if (currentSongId != PlayStatusTracker.LastPlayStatus.SongId) { currentSongId = PlayStatusTracker.LastPlayStatus.SongId; if (animationState == AnimationState.None) { if (prevTrackCommandIssued) { prevTrackCommandIssued = false; animationState = AnimationState.HiddenToRightSide; hideToRightStoryboard.Begin(); await Task.Delay(300); } else { hideToLeftStoryboard.Begin(); await Task.Delay(300); } } ViewModel.SongName = PlayStatusTracker.LastPlayStatus.SongName; ViewModel.AlbumName = PlayStatusTracker.LastPlayStatus.AlbumName; ViewModel.ArtistName = PlayStatusTracker.LastPlayStatus.ArtistName; var artistArtUrl = await SongImageProvider.GetArtistArt(PlayStatusTracker.LastPlayStatus.ArtistId); var albumArtUrl = await SongImageProvider.GetAlbumArt(PlayStatusTracker.LastPlayStatus.AlbumId); ViewModel.ArtistArtUri = new Uri(artistArtUrl); ViewModel.AlbumArtUri = new Uri(albumArtUrl); if (animationState == AnimationState.HiddenToRightSide) { showFromLeftStoryboard.Begin(); } else // None or HiddenToLeftSide { showFromRightStoryboard.Begin(); } ViewModel.ProgressRingActive = false; animationState = AnimationState.None; } else if ((DateTime.UtcNow - spinnerShowTime) > maximumSpinnerShowTime && ViewModel.ProgressRingActive) { // Workaround for when prev track gets pushed when no prev track is there, // or in general when a command fails. // (progress ring should not be shown forever!) if (animationState == AnimationState.HiddenToRightSide) { showFromRightStoryboard.Begin(); } else // None or HiddenToLeftSide { showFromLeftStoryboard.Begin(); } ViewModel.ProgressRingActive = false; animationState = AnimationState.None; } }