Added tracking/capturing/restoration of audio playback state and position.
This commit is contained in:
@@ -13,6 +13,7 @@ public class SessionTracker(
|
||||
{
|
||||
playlistManager.CurrentPlaylistChanged += OnCurrentPlaylistChanged;
|
||||
audioPlayer.PlayingSongChanged += OnPlayingSongChanged;
|
||||
audioPlayer.PropertyChanged += OnAudioPlayerPropertyChanged;
|
||||
}
|
||||
|
||||
private void OnCurrentPlaylistChanged(object? sender, EventArgs e)
|
||||
@@ -26,4 +27,19 @@ public class SessionTracker(
|
||||
AudioPlayerState audioPlayerState = sessionService.Session.Player;
|
||||
audioPlayerState.PlaylistSongUID = e.NewSong?.UID;
|
||||
}
|
||||
|
||||
private void OnAudioPlayerPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(IAudioPlayer.State):
|
||||
sessionService.Session.Player.PlaybackState = audioPlayer.State;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Capture()
|
||||
{
|
||||
sessionService.Session.Player.Position = audioPlayer.Position;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user