Updated certain events to have more concrete event arguments. Added try-catch block around playlist save logic. Added DispatchQueue where necessary.
This commit is contained in:
@@ -20,9 +20,13 @@ public class AudioPlayer : IAudioPlayer
|
||||
}
|
||||
protected set
|
||||
{
|
||||
Playlist? oldPlaylist = _playlist;
|
||||
_playlist = value;
|
||||
|
||||
NotifyPropertyChanged(nameof(Playlist));
|
||||
PlaylistChanged?.Invoke(this, new());
|
||||
|
||||
PlaylistChangedEventArgs eventArgs = new(oldPlaylist, value);
|
||||
PlaylistChanged?.Invoke(this, eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +41,13 @@ public class AudioPlayer : IAudioPlayer
|
||||
}
|
||||
protected set
|
||||
{
|
||||
PlaylistSong? oldSong = _playingSong;
|
||||
_playingSong = value;
|
||||
|
||||
NotifyPropertyChanged(nameof(PlayingSong));
|
||||
PlayingSongChanged?.Invoke(this, new());
|
||||
|
||||
PlayingSongChangedEventArgs eventArgs = new(oldSong, value);
|
||||
PlayingSongChanged?.Invoke(this, eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +123,8 @@ public class AudioPlayer : IAudioPlayer
|
||||
|
||||
protected virtual int PreviousSongSecondsThreshold => 5;
|
||||
|
||||
public event EventHandler? PlaylistChanged;
|
||||
public event EventHandler? PlayingSongChanged;
|
||||
public event EventHandler<PlaylistChangedEventArgs>? PlaylistChanged;
|
||||
public event EventHandler<PlayingSongChangedEventArgs>? PlayingSongChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public AudioPlayer(IAudioEngine audioEngine, IPlaylistManager playlistManager)
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface IAudioPlayer
|
||||
Task PreviousAsync();
|
||||
Task NextAsync();
|
||||
|
||||
event EventHandler PlaylistChanged;
|
||||
event EventHandler PlayingSongChanged;
|
||||
event EventHandler<PlaylistChangedEventArgs> PlaylistChanged;
|
||||
event EventHandler<PlayingSongChangedEventArgs> PlayingSongChanged;
|
||||
event PropertyChangedEventHandler PropertyChanged;
|
||||
}
|
||||
9
Harmonia.Core/Player/PlayingSongChangedEventArgs.cs
Normal file
9
Harmonia.Core/Player/PlayingSongChangedEventArgs.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Harmonia.Core.Playlists;
|
||||
|
||||
namespace Harmonia.Core.Player;
|
||||
|
||||
public class PlayingSongChangedEventArgs(PlaylistSong? oldSong, PlaylistSong? newSong) : EventArgs
|
||||
{
|
||||
public PlaylistSong? OldSong { get; } = oldSong;
|
||||
public PlaylistSong? NewSong { get; } = newSong;
|
||||
}
|
||||
9
Harmonia.Core/Player/PlaylistChangedEventArgs.cs
Normal file
9
Harmonia.Core/Player/PlaylistChangedEventArgs.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Harmonia.Core.Playlists;
|
||||
|
||||
namespace Harmonia.Core.Player;
|
||||
|
||||
public class PlaylistChangedEventArgs(Playlist? oldPlaylist, Playlist? newPlaylist) : EventArgs
|
||||
{
|
||||
public Playlist? OldPlaylist { get; } = oldPlaylist;
|
||||
public Playlist? NewPlaylist { get; } = newPlaylist;
|
||||
}
|
||||
Reference in New Issue
Block a user