本文整理汇总了C#中Playlist类的典型用法代码示例。如果您正苦于以下问题:C# Playlist类的具体用法?C# Playlist怎么用?C# Playlist使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Playlist类属于命名空间,在下文中一共展示了Playlist类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MPC
public MPC(string host, int port)
{
s = new ServerComponent(host, port);
s.Disconnected += new EventHandler(s_Disconnected);
CurrentStatus = new Status();
CurrentPlaylist = new Playlist();
}
示例2: GetShareCode
public ShareCode GetShareCode(ShareableEntityType entityType, Guid entityId)
{
// TODO: Support sharing other entities.
if (entityType != ShareableEntityType.Playlist)
throw new NotSupportedException("Only Playlist entityType can be shared currently.");
ShareCode shareCode;
try
{
Playlist playlistToCopy = PlaylistDao.Get(entityId);
if (playlistToCopy == null)
{
string errorMessage = string.Format("No playlist found with id: {0}", entityId);
throw new ApplicationException(errorMessage);
}
var shareablePlaylistCopy = new Playlist(playlistToCopy);
PlaylistManager.Save(shareablePlaylistCopy);
shareCode = new ShareCode(shareablePlaylistCopy);
Save(shareCode);
}
catch (Exception exception)
{
Logger.Error(exception);
throw;
}
return shareCode;
}
示例3: DeleteContentOperation
public DeleteContentOperation(IPod dev, Playlist pl, IEnumerable<Track> tracks, bool isAltMode)
: this(dev, isAltMode)
{
_playList = pl;
_tracks = tracks;
}
示例4: CopyAndSave
/// <summary>
/// Copy a playlist. Useful for sharing.
/// </summary>
/// <param name="id">The playlist ID to copy</param>
/// <returns>A new playlist with a new ID which has been saved.</returns>
public Playlist CopyAndSave(Guid id)
{
Playlist copiedPlaylist;
try
{
Playlist playlistToCopy = PlaylistDao.Get(id);
if (playlistToCopy == null)
{
string errorMessage = string.Format("No playlist found with id: {0}", id);
throw new ApplicationException(errorMessage);
}
copiedPlaylist = new Playlist(playlistToCopy);
DoSave(copiedPlaylist);
}
catch (Exception exception)
{
Logger.Error(exception);
throw;
}
return copiedPlaylist;
}
示例5: 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.");
}
示例6: EditPlaylistViewModel
public EditPlaylistViewModel(Playlist playlist, User user)
{
Playlist = playlist;
User = user;
_songRepo = new SongRepository();
_artRepo = new ArtRepository();
_playlistRepo = new PlaylistRepository();
_playlistRepo.Dispose();
Art = new ObservableCollection<string>(_artRepo.GetPlaylistArt());
AllSongs = new ObservableCollection<Song>(_songRepo.GetAllSongs());
PlaceholderSongs = CurrentSongs;
Title = Playlist.Title;
Image = Playlist.Image;
PlaylistUserID = Playlist.UserID;
SelectedImage = Playlist.Image;
// COMMANDS
AddSongToPlaylistCommand = new RelayCommand(new Action<object>(AddSongToPlaylist));
RemoveSongFromPlaylistCommand = new RelayCommand(new Action<object>(RemoveSongFromPlaylist));
CloseEditPlaylistViewCommand = new RelayCommand(new Action<object>(CloseEditPlaylistView));
SavePlaylistChangesCommand = new RelayCommand(new Action<object>(SavePlaylistChanges), Predicate => {
if (TitleRule.TitleRegex.IsMatch(Title))
{
return true;
}
else
{
return false;
}
});
}
示例7: 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.");
}
示例8: WhenThePlayListIsEmpty
public void WhenThePlayListIsEmpty()
{
var dummyPlaylistWatcher = new DummyPlaylistWatcher();
var playlist = new Playlist(dummyPlaylistWatcher);
Assert.IsFalse(playlist.AreMoreSongsAvailable(), "There must not be any songs available.");
}
示例9: Player
public Player(Playlist playlist, IAudioInteractor audioInteractor, ILibraryRepository library)
{
AudioInteractor = audioInteractor;
Playlist = playlist;
_current = this;
Library = library;
}
示例10: PlaylistsCanGoBack
public void PlaylistsCanGoBack()
{
string filename1 = "song1";
string filename2 = "song1";
var music1 = new MusicInfo() { FullPath = filename1 };
var music2 = new MusicInfo() { FullPath = filename2 };
var dummyPlaylistWatcher = new DummyPlaylistWatcher();
var playlist = new Playlist(dummyPlaylistWatcher);
playlist.Enqueue(music1);
playlist.Enqueue(music2);
Assert.AreEqual(2, playlist.Count, "There must be two songs in the playlist.");
MusicInfo song = playlist.CurrentSong;
Assert.AreEqual(filename1, song.FullPath, "The first item in the playlist must be correct.");
playlist.MoveToNextSong();
MusicInfo nextSong = playlist.CurrentSong;
Assert.AreEqual(filename2, nextSong.FullPath, "The second item in the playlist must be correct.");
playlist.MoveBackOneSong();
Assert.AreEqual(filename1, playlist.CurrentSong.FullPath, "Going back one song should go back to the first one.");
}
示例11: AddPlaylist
/// <summary>
/// Adds a playlist to the database.
/// </summary>
public void AddPlaylist(Playlist playlist)
{
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("INSERT INTO playlists VALUES (NULL,{0})", parse(playlist.Name));
ExecuteQuery (sb.ToString ());
}
示例12: Create_Click
protected void Create_Click(object sender, EventArgs e)
{
var playlist = new Playlist()
{
Title = this.Server.HtmlEncode(this.TitleTextBox.Text),
Description = this.Server.HtmlEncode(this.Description.Text),
CreationDate = DateTime.UtcNow,
CreatorId = this.User.Identity.GetUserId()
};
Video video = this.Videos.GetByUrl(this.Server.HtmlEncode(this.Url.Text));
if (video == null)
{
video = new Video()
{
Url = this.Server.HtmlEncode(this.Url.Text)
};
}
Category category = this.Categories.All().Where(c => c.Name == this.CategorySelect.SelectedItem.Text).FirstOrDefault();
playlist.Category = category;
playlist.Videos.Add(video);
this.Playlists.Create(playlist);
this.Playlists.SaveChanges();
}
示例13: Test
public void Test()
{
var song1 = "song1";
var song2 = "song2";
var song3 = "song3";
var song4 = "song4";
_songs = new MusicInfo[] {
new MusicInfo() { FullPath = song1 },
new MusicInfo() { FullPath = song2 },
new MusicInfo() { FullPath = song3 },
new MusicInfo() { FullPath = song4 }
};
var library = new MemoryLibraryRepository();
library.ClearLibrary();
library.AddMusicToLibrary(_songs);
var loopingWatcher = new RandomSongPlaylistWatcher(2);
_playlist = new Playlist(loopingWatcher);
_dummyAudio = new DummyAudioInteractor();
var player = new Player(_playlist, _dummyAudio, library);
loopingWatcher.AttachToPlaylist(_playlist, library);
player.MaxPlayCount = 3;
player.Play();
}
示例14: OnStartup
protected override bool OnStartup(StartupEventArgs eventArgs) {
InitSettings();
SongPlayer = new SongPlayer(ApplicationSettings.Volume);
Playlist = new Playlist();
TransitionMgr = new TransitionManager(SongPlayer, Playlist, ApplicationSettings);
if(eventArgs.CommandLine.Count > 0) {
HandleArgs(eventArgs.CommandLine.ToArray()).Wait();
} else {
LoadStartupSongFiles();
}
SpeechController = new SpeechController(SongPlayer, Playlist, ApplicationSettings);
SpeechController.Init();
Application = new SpeechMusicControllerApp();
Application.InitializeComponent();
var windowMgr = new WindowManager((Hardcodet.Wpf.TaskbarNotification.TaskbarIcon)Application.FindResource(TrayIconResourceName));
windowMgr.Init(ApplicationSettings, SongPlayer, Playlist, SpeechController);
Application.Exiting += (s, a) => {
ApplicationSettings.WriteToDisc();
};
windowMgr.Overlay.DisplayText("SMC Running...", 2000);
Application.Run();
return false;
}
示例15: MainWindow
public MainWindow()
: base(Gtk.WindowType.Toplevel)
{
oXbmc = new XBMC_Communicator();
oXbmc.SetIp("10.0.0.5");
oXbmc.SetConnectionTimeout(4000);
oXbmc.SetCredentials("", "");
oXbmc.Status.StartHeartBeat();
Build ();
this.AllowStaticAccess();
//Create objects used
oPlaylist = new Playlist(this);
oControls = new Controls(this);
oMenuItems = new MenuItems(this);
oContextMenu = new ContextMenu(this);
oShareBrowser = new ShareBrowser(this);
oTrayicon = new SysTrayIcon(this);
oStatusUpdate = new StatusUpdate(this);
oMediaInfo = new MediaInfo(this);
oNowPlaying = new NowPlaying(this);
oGuiConfig = new GuiConfig(this);
nbDataContainer.CurrentPage = 0;
}