Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 public void SetupTest()
 {
     _playlist.ResetSongsCounter();
     _playlist.LastSongPlayed = null;
 }