本文整理汇总了C#中PlayList.Shuffle方法的典型用法代码示例。如果您正苦于以下问题:C# PlayList.Shuffle方法的具体用法?C# PlayList.Shuffle怎么用?C# PlayList.Shuffle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayList
的用法示例。
在下文中一共展示了PlayList.Shuffle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadPlayList
protected void LoadPlayList(string strPlayList)
{
IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
if (loader == null)
return;
PlayList playlist = new PlayList();
if (!loader.Load(playlist, strPlayList))
{
ShowDialogOk(Translation.Playlist, new string[] { GUILocalizeStrings.Get(477) });
return;
}
if (_playlistPlayer == null)
{
_playlistPlayer = PlayListPlayer.SingletonPlayer;
_playlistPlayer.PlaylistAutoPlay = DBOption.GetOptions(DBOption.cPlaylistAutoPlay);
_playlistPlayer.RepeatPlaylist = DBOption.GetOptions(DBOption.cRepeatPlaylist);
}
_playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList);
if (playlist.Count == 1 && _playlistPlayer.PlaylistAutoPlay)
{
// If the file is an image file, it should be mounted before playing
string filename = playlist[0].FileName;
if (Helper.IsImageFile(filename))
{
if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename))
{
return;
}
}
MPTVSeriesLog.Write(string.Format("GUITVSeriesPlaylist: play single playlist item - {0}", playlist[0].FileName));
if (g_Player.Play(filename))
{
if (MediaPortal.Util.Utils.IsVideo(filename))
{
g_Player.ShowFullScreenWindow();
}
}
return;
}
// clear current playlist
_playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Clear();
// add each item of the playlist to the playlistplayer
for (int i = 0; i < playlist.Count; ++i)
{
PlayListItem playListItem = playlist[i];
_playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Add(playListItem);
}
// if we got a playlist
if (_playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Count > 0)
{
playlist = _playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES);
// autoshuffle on load
if (_playlistPlayer.PlaylistAutoShuffle)
{
playlist.Shuffle();
}
// then get 1st item
PlayListItem item = playlist[0];
// and activate the playlist window
ShowPlaylistWindow();
// and start playing it
if (_playlistPlayer.PlaylistAutoPlay)
{
_playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES;
_playlistPlayer.Reset();
_playlistPlayer.Play(0);
}
}
}
示例2: LoadPlayList
protected void LoadPlayList(string strPlayList, bool startPlayback, bool isAsynch, bool defaultLoad)
{
IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
if (loader == null)
{
return;
}
PlayList playlist = new PlayList();
if (!Util.Utils.FileExistsInCache(strPlayList))
{
Log.Info("Playlist: Skipping non-existing Playlist file: {0}", strPlayList);
return;
}
if (!loader.Load(playlist, strPlayList))
{
if (isAsynch && defaultLoad) // we might not be in GUI yet! we have asynch and default load because we might want to use asynch loading from gui button too, later!
throw new Exception(string.Format("Unable to load Playlist file: {0}", strPlayList)); // exception is handled in backgroundworker
else
TellUserSomethingWentWrong();
return;
}
if (_autoShuffleOnLoad)
{
playlist.Shuffle();
}
playlistPlayer.CurrentPlaylistName = Path.GetFileNameWithoutExtension(strPlayList);
if (playlist.Count == 1 && startPlayback)
{
Log.Info("GUIMusic:Play: play single playlist item - {0}", playlist[0].FileName);
// Default to type Music, when a playlist has been selected from My Music
g_Player.Play(playlist[0].FileName, g_Player.MediaType.Music);
return;
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
// clear current playlist
//playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC).Clear();
Song song = new Song();
PlayList newPlaylist = new PlayList();
// add each item of the playlist to the playlistplayer
for (int i = 0; i < playlist.Count; ++i)
{
if (null != bw && isAsynch && bw.CancellationPending)
return;
PlayListItem playListItem = playlist[i];
m_database.GetSongByFileName(playListItem.FileName, ref song);
MusicTag tag = new MusicTag();
tag = song.ToMusicTag();
playListItem.MusicTag = tag;
if (Util.Utils.FileExistsInCache(playListItem.FileName) ||
playListItem.Type == PlayListItem.PlayListItemType.AudioStream)
{
newPlaylist.Add(playListItem);
}
else
{
Log.Info("Playlist: File {0} no longer exists. Skipping item.", playListItem.FileName);
}
}
if (null != bw && isAsynch && bw.CancellationPending)
return;
ReplacePlaylist(newPlaylist);
if (startPlayback)
StartPlayingPlaylist();
}
示例3: LoadPlayList
/// <summary>
/// Load Playlist file
/// </summary>
/// <param name="strPlayList"></param>
protected void LoadPlayList(string strPlayList)
{
IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);
if (loader == null)
return;
PlayList playlist = new PlayList();
if (!loader.Load(playlist, strPlayList))
{
TellUserSomethingWentWrong();
return;
}
playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList);
if (playlist.Count == 1 && playlistPlayer.PlaylistAutoPlay)
{
logger.Info(string.Format("GUImvCentralPlaylist: play single playlist item - {0}", playlist[0].FileName));
// If the file is an image file, it should be mounted before playing
string filename = playlist[0].FileName;
if (mvCentralUtils.IsImageFile(filename))
{
if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename, true))
{
return;
}
}
if (g_Player.Play(filename))
{
if (MediaPortal.Util.Utils.IsVideo(filename))
{
if (mvCentralCore.Settings.AutoFullscreen)
g_Player.ShowFullScreenWindow();
}
}
return;
}
// clear current playlist
playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL).Clear();
// add each item of the playlist to the playlistplayer
for (int i = 0; i < playlist.Count; ++i)
{
PlayListItem playListItem = playlist[i];
playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL).Add(playListItem);
}
// if we got a playlist
if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL).Count > 0)
{
playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL);
// autoshuffle on load
if (playlistPlayer.PlaylistAutoShuffle)
{
playlist.Shuffle();
}
// then get 1st item
PlayListItem item = playlist[0];
// and start playing it
if (playlistPlayer.PlaylistAutoPlay)
{
playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL;
playlistPlayer.Reset();
playlistPlayer.Play(0);
}
// and activate the playlist window if its not activated yet
if (GetID == GUIWindowManager.ActiveWindow)
{
GUIWindowManager.ActivateWindow(GetID);
}
}
}