当前位置: 首页>>代码示例>>C#>>正文


C# PlayList.Shuffle方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:MichelZ,项目名称:MP-TVSeries,代码行数:80,代码来源:TVSeriesPlugin.cs

示例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();
    }
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:78,代码来源:GUIMusicBaseWindow.cs

示例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);
            }
              }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:82,代码来源:GUImvPlaylist.cs


注:本文中的PlayList.Shuffle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。