Added tracking/capturing/restoration of audio playback state and position.

This commit is contained in:
2026-08-08 16:37:55 -04:00
parent c262ee4caa
commit 0942e3e5ad
11 changed files with 92 additions and 15 deletions

View File

@@ -225,6 +225,20 @@ public partial class PlayerViewModel : ViewModelBase
_timer.Tick += TickTock;
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
TryRestore();
}
private void TryRestore()
{
if (_audioPlayer.PlayingSong is null)
return;
Song = _audioPlayer.PlayingSong.Song;
Position = _audioPlayer.Position;
CurrentPosition = _audioPlayer.Position;
Task.Run(UpdateImage);
}
#region Event Handlers

View File

@@ -50,6 +50,17 @@ public partial class PlayingSongViewModel : ViewModelBase
_audioBitmapImageCache = audioBitmapImageCache;
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
TryRestore();
}
private void TryRestore()
{
if (_audioPlayer.PlayingSong is null)
return;
Song = _audioPlayer.PlayingSong.Song;
Task.Run(UpdateImage);
}
private void OnAudioPlayerPlayingSongChanged(object? sender, PlayingSongChangedEventArgs e)

View File

@@ -220,6 +220,8 @@ public partial class PlaylistDetailViewModel : ViewModelBase
FilteredPlaylistSongs.CollectionChanged += OnFilteredPlaylistSongsCollectionChanged;
Playlist = _playlistManager.CurrentPlaylist; // Testing
PlayingSong = _audioPlayer.PlayingSong; // Testing
UpdateFilteredSongs();
}