public override SongDto GetNextSong(PlaylistLoopInfo playlist) { _ = playlist ?? throw new ArgumentNullException(nameof(playlist)); if (playlist.Songs.IsEmpty()) { return(SetLastSongPlayed(playlist, null)); } SongDto song; var nextSong = playlist.GetNextSongNotPlayedYet(); if (nextSong is null && LoopStyle != LoopStyle.NoLoop) { playlist.ResetSongsCounter(); return(GetNextSong(playlist)); } if (LoopStyle == LoopStyle.LoopSong) { song = playlist.MarkSongToBePlayed(playlist.LastSongPlayed ??= nextSong); return(song); } song = playlist.MarkSongToBePlayed(nextSong); // looping is disabled. this value can be null or not return(SetLastSongPlayed(playlist, song)); }
public void SetupClass() { var songs = Utils.GenerateSongs(_songPrefix, _nbSongs).ToConcurrentObservableCollection(); _playlist = new PlaylistLoopInfo(new PlaylistDto { Songs = songs }); _noShuffleLoopPlaylist = PlayMode.GetPlayMode(ShuffleStyle.NoShuffle, LoopStyle.LoopPlaylist); _noShuffleLoopSong = PlayMode.GetPlayMode(ShuffleStyle.NoShuffle, LoopStyle.LoopSong); _noShuffleNoLoop = PlayMode.GetPlayMode(ShuffleStyle.NoShuffle, LoopStyle.NoLoop); _shuffleLoopPlaylist = PlayMode.GetPlayMode(ShuffleStyle.Shuffle, LoopStyle.LoopPlaylist); _shuffleLoopSong = PlayMode.GetPlayMode(ShuffleStyle.Shuffle, LoopStyle.LoopSong); _shuffleNoLoop = PlayMode.GetPlayMode(ShuffleStyle.Shuffle, LoopStyle.NoLoop); }