本文整理汇总了C#中Playlist.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Playlist.AddRange方法的具体用法?C# Playlist.AddRange怎么用?C# Playlist.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist.AddRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayerCanBeGivenANewPlaylist
public void PlayerCanBeGivenANewPlaylist()
{
var library = new MemoryLibraryRepository();
var playlist = new Playlist();
var dummyAudio = new DummyAudioInteractor();
var player = new Player(playlist, dummyAudio, null);
var song = "song1";
library.ClearLibrary();
library.AddMusicToLibrary(new MusicInfo[] { new MusicInfo() { FullPath = song } });
playlist.AddRange(library.GetAllMusic());
player.Play();
Assert.AreEqual(song, playlist.CurrentSong.FullPath, "The last song played must be the only one in the library.");
var song2 = "song 2";
library.ClearLibrary();
library.AddMusicToLibrary(new MusicInfo[] { new MusicInfo() { FullPath = song2 } });
playlist.AddRange(library.GetAllMusic());
player.PlayCount = 0;
player.Play();
Assert.AreEqual(song, playlist.PreviousSong.FullPath, "The previous played must be new song in the library.");
Assert.AreEqual(song2, playlist.CurrentSong.FullPath, "The current played must be new song in the library.");
}
示例2: Loop
public void Loop()
{
var song1 = "song1";
var song2 = "song2";
var library = new MemoryLibraryRepository();
library.ClearLibrary();
library.AddMusicToLibrary(
new MusicInfo[] {
new MusicInfo() { FullPath = song1 },
new MusicInfo() { FullPath = song2 }
});
var loopingWatcher = new LoopingPlaylistWatcher();
var playlist = new Playlist(loopingWatcher);
var dummyAudio = new DummyAudioInteractor();
var player = new Player(playlist, dummyAudio, library);
loopingWatcher.AttachToPlaylist(playlist, library);
playlist.AddRange(library.GetAllMusic());
player.MaxPlayCount = 3;
player.Play();
Assert.AreEqual(3, dummyAudio.PlayHistory.Count, "There must be three songs in the history.");
Assert.AreEqual(song1, dummyAudio.PlayHistory[0], "The first song must play first.");
Assert.AreEqual(song2, dummyAudio.PlayHistory[1], "The second song must play second.");
Assert.AreEqual(song1, dummyAudio.PlayHistory[2], "The first song must play third.");
Assert.AreEqual(2, playlist.RemainingSongs, "After playing three songs there must still be 2 songs in the playlist.");
}
示例3: AttachToPlaylist
public void AttachToPlaylist(Playlist playlist, ILibraryRepository library)
{
_playlist = playlist;
_library = library;
if (_playlist.Count == 0)
{
Console.WriteLine("Attaching");
_playlist.AddRange(_library.GetAllMusic().Shuffle(_random).Take(PLAYLIST_SIZE));
}
}