Made repository methods asynchronous. Simplified playlist repository. Use playlist manager in the app, and left playlist repository to only be used by the playlist manager.
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Harmonia.Core.Player;
|
||||
public class AudioPlayer : IAudioPlayer
|
||||
{
|
||||
private readonly IAudioEngine _audioEngine;
|
||||
private readonly IPlaylistRepository _playlistRepository;
|
||||
private readonly IPlaylistManager _playlistManager;
|
||||
|
||||
private Playlist? _playlist;
|
||||
public Playlist? Playlist
|
||||
@@ -117,13 +117,13 @@ public class AudioPlayer : IAudioPlayer
|
||||
public event EventHandler? PlayingSongChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public AudioPlayer(IAudioEngine audioEngine, IPlaylistRepository playlistRepository)
|
||||
public AudioPlayer(IAudioEngine audioEngine, IPlaylistManager playlistManager)
|
||||
{
|
||||
_audioEngine = audioEngine;
|
||||
_audioEngine.StreamFinished += OnAudioEngineStreamFinished;
|
||||
_audioEngine.StateChanged += OnMusicEngineStateChanged;
|
||||
|
||||
_playlistRepository = playlistRepository;
|
||||
_playlistManager = playlistManager;
|
||||
}
|
||||
|
||||
private async void OnAudioEngineStreamFinished(object? sender, EventArgs e)
|
||||
@@ -231,10 +231,7 @@ public class AudioPlayer : IAudioPlayer
|
||||
{
|
||||
if (Playlist == null || Playlist.Songs.Contains(song) == false)
|
||||
{
|
||||
//Playlist? newPlaylist = _playlistRepository.GetPlaylist(song);
|
||||
|
||||
Playlist? newPlaylist = _playlistRepository.Get().FirstOrDefault(playlist =>
|
||||
playlist.Songs.Contains(song));
|
||||
Playlist? newPlaylist = _playlistManager.GetPlaylist(song);
|
||||
|
||||
if (newPlaylist == null)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user