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


C# PlayList.Add方法代码示例

本文整理汇总了C#中PlayList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PlayList.Add方法的具体用法?C# PlayList.Add怎么用?C# PlayList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayList的用法示例。


在下文中一共展示了PlayList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllPlayedReturnsTrueWhenAllArePlayed

    public void AllPlayedReturnsTrueWhenAllArePlayed()
    {
      PlayList pl = new PlayList();
      PlayListItem item = new PlayListItem("my song", "myfile.mp3");
      item.Played = true;
      pl.Add(item);

      item = new PlayListItem("my 2:d song", "myfile2.mp3");
      item.Played = true;
      pl.Add(item);

      Assert.IsTrue(pl.AllPlayed());
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:13,代码来源:PlayListTest.cs

示例2: Load

    public bool Load(PlayList playlist, string fileName)
    {
      playlist.Clear();
      XmlNodeList nodeEntries;

      if (!LoadXml(fileName, out nodeEntries))
        return false;

      try
      {
        string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
        foreach (XmlNode node in nodeEntries)
        {
          string file = ReadFileName(node);

          if (file == null)
            return false;

          string infoLine = ReadInfoLine(node, file);
          int duration = ReadLength(node);

          SetupTv.Utils.GetQualifiedFilename(basePath, ref file);
          PlayListItem newItem = new PlayListItem(infoLine, file, duration);
          playlist.Add(newItem);
        }
        return true;
      }
      catch (Exception)
      {
        return false;
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:32,代码来源:PlayListB4sIO.cs

示例3: ResetSetsAllItemsToFalse

    public void ResetSetsAllItemsToFalse()
    {
      PlayList pl = new PlayList();
      PlayListItem item = new PlayListItem("my song", "myfile.mp3");
      pl.Add(item);

      PlayListItem item2 = new PlayListItem("my 2:d song", "myfile2.mp3");
      pl.Add(item2);

      pl[0].Played = true;
      pl[1].Played = true;

      pl.ResetStatus();

      Assert.IsFalse(pl[0].Played);
      Assert.IsFalse(pl[1].Played);
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:17,代码来源:PlayListTest.cs

示例4: NewlyAddedSongsAreNotMarkedPlayed

    public void NewlyAddedSongsAreNotMarkedPlayed()
    {
      PlayList pl = new PlayList();
      PlayListItem item = new PlayListItem("my song", "myfile.mp3");
      pl.Add(item);

      Assert.IsFalse(pl.AllPlayed());
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:8,代码来源:PlayListTest.cs

示例5: RemoveReallyRemovesASong

    public void RemoveReallyRemovesASong()
    {
      PlayList pl = new PlayList();
      PlayListItem item = new PlayListItem("my song", "myfile.mp3");
      pl.Add(item);

      pl.Remove("myfile.mp3");

      Assert.AreEqual(0, pl.Count);
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:10,代码来源:PlayListTest.cs

示例6: Load

        public bool Load(PlayList playlist, string fileName)
        {
            playlist.Clear();

              try
              {
            string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
            XmlDocument doc = new XmlDocument();
            doc.Load(fileName);
            if (doc.DocumentElement == null)
            {
              return false;
            }
            XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/asx");
            if (nodeRoot == null)
            {
              return false;
            }
            XmlNodeList nodeEntries = nodeRoot.SelectNodes("entry");
            foreach (XmlNode node in nodeEntries)
            {
              XmlNode srcNode = node.SelectSingleNode("ref");
              if (srcNode != null)
              {
            XmlNode url = srcNode.Attributes.GetNamedItem("href");
            if (url != null)
            {
              if (url.InnerText != null)
              {
                if (url.InnerText.Length > 0)
                {
                  fileName = url.InnerText;
                  if (!(fileName.ToLowerInvariant().StartsWith("http") || fileName.ToLowerInvariant().StartsWith("mms") || fileName.ToLowerInvariant().StartsWith("rtp")))
                    continue;

                  PlayListItem newItem = new PlayListItem(fileName, fileName, 0);
                  newItem.Type = PlayListItem.PlayListItemType.Audio;
                  playlist.Add(newItem);
                }
              }
            }
              }
            }
            return true;
              }
              catch (Exception ex)
              {
            Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
              }
              return false;
        }
开发者ID:puenktchen,项目名称:RadioTime,代码行数:51,代码来源:PlayListASXIO.cs

示例7: SaveB4s

    public void SaveB4s()
    {
      PlayList playlist = new PlayList();
      IPlayListIO saver = new PlayListB4sIO();
      playlist.Add(new PlayListItem("mytuneMp3", "mytune.mp3"));
      playlist.Add(new PlayListItem("mytuneOgg", "mytune.ogg", 123));
      playlist.Add(new PlayListItem("mytuneWav", "mytune.wav"));
      playlist.Add(new PlayListItem("mytuneWav", "mytune.wav", 666));
      saver.Save(playlist, "test.b4s");

      string newXml;
      string oldXml;
      using (StreamReader reader = new StreamReader("test.b4s"))
      {
        newXml = reader.ReadToEnd();
      }

      using (StreamReader reader = new StreamReader("Core\\Playlists\\TestData\\testSave.b4s"))
      {
        oldXml = reader.ReadToEnd();
      }

      Assert.AreEqual(oldXml, newXml);
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:24,代码来源:PlayListB4STest.cs

示例8: Load

    public bool Load(PlayList playlist, string fileName)
    {
      playlist.Clear();

      try
      {
        string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
        XmlDocument doc = new XmlDocument();
        doc.Load(fileName);
        if (doc.DocumentElement == null)
        {
          return false;
        }
        XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq");
        if (nodeRoot == null)
        {
          return false;
        }
        XmlNodeList nodeEntries = nodeRoot.SelectNodes("media");
        foreach (XmlNode node in nodeEntries)
        {
          XmlNode srcNode = node.Attributes.GetNamedItem("src");
          if (srcNode != null)
          {
            if (srcNode.InnerText != null)
            {
              if (srcNode.InnerText.Length > 0)
              {
                fileName = srcNode.InnerText;
                Util.Utils.GetQualifiedFilename(basePath, ref fileName);
                PlayListItem newItem = new PlayListItem(fileName, fileName, 0);
                newItem.Type = PlayListItem.PlayListItemType.Audio;
                string description;
                description = Path.GetFileName(fileName);
                newItem.Description = description;
                playlist.Add(newItem);
              }
            }
          }
        }
        return true;
      }
      catch (Exception ex)
      {
        Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
      }
      return false;
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:48,代码来源:PlayListWPLIO.cs

示例9: Load

    public bool Load(PlayList playlist, string playlistFileName)
    {
      playlist.Clear();

      try
      {
        var doc = new XmlDocument();
        doc.Load(playlistFileName);
        if (doc.DocumentElement == null)
          return false;
        XmlNode nodeRoot = doc.DocumentElement.SelectSingleNode("/smil/body/seq");
        if (nodeRoot == null)
          return false;
        XmlNodeList nodeEntries = nodeRoot.SelectNodes("media");
        if (nodeEntries != null)
          foreach (XmlNode node in nodeEntries)
          {
            XmlNode srcNode = node.Attributes.GetNamedItem("src");
            if (srcNode != null)
            {
              if (srcNode.InnerText != null)
              {
                if (srcNode.InnerText.Length > 0)
                {
                  var playlistUrl = srcNode.InnerText;
                  var newItem = new PlayListItem(playlistUrl, playlistUrl, 0)
                                  {
                                    Type = PlayListItem.PlayListItemType.Audio
                                  };
                  string description = Path.GetFileName(playlistUrl);
                  newItem.Description = description;
                  playlist.Add(newItem);
                }
              }
            }
          }
        return true;
      }
      catch (Exception e)
      {
        Log.Error(e.StackTrace);
      }
      return false;
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:44,代码来源:PlayListWPLIO.cs

示例10: Load

        public bool Load(PlayList playlist, string fileName)
        {
            playlist.Clear();
            XmlNodeList nodeEntries;

            if (!LoadXml(fileName, out nodeEntries))
            {
                return false;
            }

            try
            {
                string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
                foreach (XmlNode node in nodeEntries)
                {
                    string file = ReadFileName(node);

                    if (file == null)
                    {
                        return false;
                    }

                    string infoLine = ReadInfoLine(node, file);
                    int duration = ReadLength(node);

                    file = PathUtil.GetAbsolutePath(basePath, file);
                    PlayListItem newItem = new PlayListItem(infoLine, file, duration);
                    playlist.Add(newItem);
                }
                return true;
            }
            catch (Exception ex)
            {
                Log.Info("exception loading playlist {0} err:{1} stack:{2}", fileName, ex.Message, ex.StackTrace);
                return false;
            }
        }
开发者ID:puenktchen,项目名称:MPExtended,代码行数:37,代码来源:PlayListB4sIO.cs

示例11: saveSmartDJPlaylist

        /// <summary>
        /// Save the current playlist
        /// </summary>
        private void saveSmartDJPlaylist()
        {
            string playlistFileName = string.Empty;
              if (GetKeyboard(ref playlistFileName))
              {
            string playListPath = string.Empty;
            // Have we out own playlist folder configured
            if (!string.IsNullOrEmpty(mvCentralCore.Settings.PlayListFolder.Trim()))
              playListPath = mvCentralCore.Settings.PlayListFolder;
            else
            {
              // No, so use my videos location
              using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
              {
            playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty);
            playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);
              }

              playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath);
            }

            // check if Playlist folder exists, create it if not
            if (!Directory.Exists(playListPath))
            {
              try
              {
            Directory.CreateDirectory(playListPath);
              }
              catch (Exception e)
              {
            logger.Info("Error: Unable to create Playlist path: " + e.Message);
            return;
              }
            }

            string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

            fullPlayListPath += ".mvplaylist";
            if (playListPath.Length != 0)
            {
              fullPlayListPath = playListPath + @"\" + fullPlayListPath;
            }
            PlayList playlist = new PlayList();
            for (int i = 0; i < facadeLayout.Count; ++i)
            {
              GUIListItem listItem = facadeLayout[i];
              PlayListItem playListItem = new PlayListItem();
              DBTrackInfo mv = (DBTrackInfo)listItem.MusicTag;
              playListItem.Track = mv;
              playlist.Add(playListItem);
            }
            PlayListIO saver = new PlayListIO();
            saver.Save(playlist, fullPlayListPath);
              }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:58,代码来源:GUISmartDJ.cs

示例12: 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

示例13: Load

    public bool Load(PlayList playlist, string fileName, string label)
    {
      string basePath = String.Empty;
      Stream stream;

      if (fileName.ToLowerInvariant().StartsWith("http"))
      {
        // We've got a URL pointing to a pls
        WebClient client = new WebClient();
        client.Proxy.Credentials = CredentialCache.DefaultCredentials;
        byte[] buffer = client.DownloadData(fileName);
        stream = new MemoryStream(buffer);
      }
      else
      {
        // We've got a plain pls file
        basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
        stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
      }

      playlist.Clear();
      playlist.Name = Path.GetFileName(fileName);
      Encoding fileEncoding = Encoding.Default;
      StreamReader file = new StreamReader(stream, fileEncoding, true);
      try
      {
        if (file == null)
        {
          return false;
        }

        string line;
        line = file.ReadLine();
        if (line == null)
        {
          file.Close();
          return false;
        }

        string strLine = line.Trim();


        //CUtil::RemoveCRLF(strLine);
        if (strLine != START_PLAYLIST_MARKER)
        {
          if (strLine.StartsWith("http") || strLine.StartsWith("HTTP") ||
              strLine.StartsWith("mms") || strLine.StartsWith("MMS") ||
              strLine.StartsWith("rtp") || strLine.StartsWith("RTP"))
          {
            PlayListItem newItem = new PlayListItem(strLine, strLine, 0);
            newItem.Type = PlayListItem.PlayListItemType.AudioStream;
            playlist.Add(newItem);
            file.Close();
            return true;
          }
          fileEncoding = Encoding.Default;
          stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
          file = new StreamReader(stream, fileEncoding, true);

          //file.Close();
          //return false;
        }

        string infoLine = "";
        string durationLine = "";
        fileName = "";
        line = file.ReadLine();
        while (line != null)
        {
          strLine = line.Trim();
          //CUtil::RemoveCRLF(strLine);
          int equalPos = strLine.IndexOf("=");
          if (equalPos > 0)
          {
            string leftPart = strLine.Substring(0, equalPos);
            equalPos++;
            string valuePart = strLine.Substring(equalPos);
            leftPart = leftPart.ToLowerInvariant();
            if (leftPart.StartsWith("file"))
            {
              if (valuePart.Length > 0 && valuePart[0] == '#')
              {
                line = file.ReadLine();
                continue;
              }

              if (fileName.Length != 0)
              {
                PlayListItem newItem = new PlayListItem(infoLine, fileName, 0);
                playlist.Add(newItem);
                fileName = "";
                infoLine = "";
                durationLine = "";
              }
              fileName = valuePart;
            }
            if (leftPart.StartsWith("title"))
            {
              infoLine = valuePart;
            }
//.........这里部分代码省略.........
开发者ID:hkjensen,项目名称:MediaPortal-1,代码行数:101,代码来源:PlayListPLSIO.cs

示例14: OnSavePlayList

    private void OnSavePlayList()
    {
      currentSelectedItem = facadeLayout.SelectedListItemIndex;
      string playlistFileName = string.Empty;
      if (GetKeyboard(ref playlistFileName))
      {
        string playListPath = string.Empty;
        using (Profile.Settings xmlreader = new Profile.MPSettings())
        {
          playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty);
          playListPath = Util.Utils.RemoveTrailingSlash(playListPath);
        }

        string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

        fullPlayListPath += ".m3u";
        if (playListPath.Length != 0)
        {
          fullPlayListPath = playListPath + @"\" + fullPlayListPath;
        }
        PlayList playlist = new PlayList();
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem listItem = facadeLayout[i];
          PlayListItem playListItem = new PlayListItem();
          playListItem.FileName = listItem.Path;
          playListItem.Description = listItem.Label;
          playListItem.Duration = listItem.Duration;
          playListItem.Type = PlayListItem.PlayListItemType.Video;
          playlist.Add(playListItem);
        }
        PlayListM3uIO saver = new PlayListM3uIO();
        saver.Save(playlist, fullPlayListPath);
      }
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:35,代码来源:GUIVideoPlaylist.cs

示例15: AddItemToPlayList

        public void AddItemToPlayList(GUIListItem pItem, ref PlayList playList,VideoInfo qa)
        {
            if (playList == null || pItem == null)
            return;
              string PlayblackUrl = "";

              YouTubeEntry vid;

              LocalFileStruct file = pItem.MusicTag as LocalFileStruct;
              if (file != null)
              {
            Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId);
            Video video = Youtube2MP.request.Retrieve<Video>(videoEntryUrl);
            vid = video.YouTubeEntry;

              }
              else
              {
            vid = pItem.MusicTag as YouTubeEntry;
              }

              if (vid != null)
              {
              if (vid.Media.Contents.Count > 0)
              {
              PlayblackUrl = string.Format("http://www.youtube.com/v/{0}", Youtube2MP.getIDSimple(vid.Id.AbsoluteUri));
              }
              else
              {
              PlayblackUrl = vid.AlternateUri.ToString();
              }

              PlayListItem playlistItem = new PlayListItem();
              playlistItem.Type = PlayListItem.PlayListItemType.VideoStream;// Playlists.PlayListItem.PlayListItemType.Audio;
              qa.Entry = vid;
              playlistItem.FileName = PlayblackUrl;
              playlistItem.Description = pItem.Label;
              playlistItem.Duration = pItem.Duration;
              playlistItem.MusicTag = qa;
              playList.Add(playlistItem);
              }
        }
开发者ID:andrewjswan,项目名称:youtube-fm-for-mediaportal,代码行数:42,代码来源:YoutubeGUIBase.cs


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