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


C# PlayList.Clear方法代码示例

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


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

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

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

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

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

示例5: Load

        public bool Load(PlayList incomingPlaylist, string playlistFileName)
        {
            if (playlistFileName == null)
                return false;
            
            playlist = incomingPlaylist;
            playlist.Clear();

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(playlistFileName);
            }
            catch (XmlException e)
            {
                MPTVSeriesLog.Write(string.Format("Cannot Load Playlist file: {0}",playlistFileName));
                MPTVSeriesLog.Write(e.Message);
                return false;
            }

            try
            {
                playlist.Name = Path.GetFileName(playlistFileName);
                basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));

                XmlNodeList nodeList = doc.DocumentElement.SelectNodes("/Playlist/Episode");
                if (nodeList == null)
                    return false;

                foreach (XmlNode node in nodeList)
                {
                    if (!AddItem(node.SelectSingleNode("ID").InnerText))
                        return false;
                }        
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write(string.Format("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace));
                return false;
            }
            return true;
        }               
开发者ID:barneh,项目名称:mptvseries,代码行数:42,代码来源:PlayListIO.cs

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

示例7: Load

        public bool Load(PlayList incomingPlaylist, string playlistFileName)
        {
            if (playlistFileName == null)
              {
            return false;
              }
              playlist = incomingPlaylist;
              playlist.Clear();

              try
              {
            playlist.Name = Path.GetFileName(playlistFileName);
            basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));

            using (file = new StreamReader(playlistFileName, Encoding.Default, true))
            {
              if (file == null)
              {
            return false;
              }

              string line = file.ReadLine();
              if (line == null || line.Length == 0)
              {
            return false;
              }

              string trimmedLine = line.Trim();

              if (trimmedLine != M3U_START_MARKER)
              {
            string fileName = trimmedLine;
            if (!AddItem("", 0, fileName))
            {
              return false;
            }
              }

              line = file.ReadLine();
              while (line != null)
              {
            trimmedLine = line.Trim();

            if (trimmedLine != "")
            {
              if (trimmedLine.StartsWith(M3U_INFO_MARKER))
              {
                string songName = null;
                int lDuration = 0;

                if (ExtractM3uInfo(trimmedLine, ref songName, ref lDuration))
                {
                  line = file.ReadLine();
                  if (!AddItem(songName, lDuration, line))
                  {
                    break;
                  }
                }
              }
              else
              {
                if (!AddItem("", 0, trimmedLine))
                {
                  break;
                }
              }
            }
            line = file.ReadLine();
              }
            }
              }
              catch (Exception ex)
              {
            Log.Info("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace);
            return false;
              }
              return true;
        }
开发者ID:puenktchen,项目名称:MPExtended,代码行数:78,代码来源:PlayListM3uIO.cs

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

示例9: Load

    public bool Load(PlayList incomingPlaylist, string playlistFileName)
    {
      if (playlistFileName == null)
        return false;
      playlist = incomingPlaylist;
      playlist.Clear();

      try
      {
        playlist.Name = Path.GetFileName(playlistFileName);
        basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));

        using (file = new StreamReader(playlistFileName))
        {
          if (file == null)
            return false;

          string line = file.ReadLine();
          if (string.IsNullOrEmpty(line))
            return false;

          string trimmedLine = line.Trim();

          if (trimmedLine != M3U_START_MARKER)
          {
            string fileName = trimmedLine;
            if (!AddItem("", 0, fileName))
              return false;
          }

          line = file.ReadLine();
          while (line != null)
          {
            trimmedLine = line.Trim();

            if (trimmedLine != "")
            {
              if (trimmedLine.StartsWith(M3U_INFO_MARKER))
              {
                string songName = null;
                int lDuration = 0;

                if (ExtractM3uInfo(trimmedLine, ref songName, ref lDuration))
                {
                  line = file.ReadLine();
                  if (!AddItem(songName, lDuration, line))
                    break;
                }
              }
              else
              {
                if (!AddItem("", 0, trimmedLine))
                  break;
              }
            }
            line = file.ReadLine();
          }
        }
      }
      catch (Exception)
      {
        return false;
      }
      return true;
    }
开发者ID:Yura80,项目名称:MediaPortal-1,代码行数:65,代码来源:PlayListM3uIO.cs

示例10: Load

        public bool Load(PlayList incomingPlaylist, string playlistFileName)
        {
            if (playlistFileName == null)
                return false;

            playlist = incomingPlaylist;
            playlist.Clear();

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(playlistFileName);
            }
            catch (XmlException e)
            {
                logger.Info(string.Format("Cannot Load Playlist file: {0}", playlistFileName));
                logger.Info(e.Message);
                return false;
            }

            string id = "";
            string title = "";
            string chapterid = "";
            string filename = "";

            try
            {
                playlist.Name = Path.GetFileName(playlistFileName);
                basePath = Path.GetDirectoryName(Path.GetFullPath(playlistFileName));

                XmlNodeList nodeList = doc.DocumentElement.SelectNodes("/Playlist");
                if (nodeList == null)
                    return false;

                foreach (XmlNode node in nodeList)
                {
                    foreach (XmlNode itemNode in node.ChildNodes)
                    {
                        if (itemNode.Name == "Track")
                        {
                            foreach (XmlNode propertyNode in itemNode.ChildNodes)
                            {
                                string Value = propertyNode.InnerText;
                                switch(propertyNode.Name)
                                {
                                    case "ID" :
                                        id = Value;
                                        break;
                                    case "Title":
                                        title = Value;
                                        break;
                                    case "ChapterID":
                                        chapterid = Value;
                                        break;
                                    case "File":
                                        filename = Value;
                                        break;
                                }

                            }
                            if (!AddItem(id, title, chapterid, filename))
                                return false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Info(string.Format("exception loading playlist {0} err:{1} stack:{2}", playlistFileName, ex.Message, ex.StackTrace));
                return false;
            }
            return true;
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:73,代码来源:PlayListIO.cs

示例11: Load

    public bool Load(PlayList playlist, string fileName)
    {
      string extension = Path.GetExtension(fileName);
      extension.ToLowerInvariant();

      playlist.Clear();
      playlist.Name = Path.GetFileName(fileName);
      string basePath = Path.GetDirectoryName(Path.GetFullPath(fileName));
      Encoding fileEncoding = Encoding.Default;
      FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
      StreamReader file = new StreamReader(stream, fileEncoding, true);

      string 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; // No unicode??? rtv
        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);
              infoLine = "";
              durationLine = "";
            }
            fileName = valuePart;
          }
          if (leftPart.StartsWith("title"))
          {
            infoLine = valuePart;
          }
          else
          {
            if (infoLine == "")
              infoLine = Path.GetFileName(fileName);
          }
          if (leftPart.StartsWith("length"))
          {
            durationLine = valuePart;
          }
          if (leftPart == "playlistname")
          {
            playlist.Name = valuePart;
          }

          if (durationLine.Length > 0 && infoLine.Length > 0 && fileName.Length > 0)
          {
            int duration = System.Int32.Parse(durationLine);
            duration *= 1000;

            string tmp = fileName.ToLowerInvariant();
            PlayListItem newItem = new PlayListItem(infoLine, fileName, duration);
            if (tmp.IndexOf("http:") < 0 && tmp.IndexOf("mms:") < 0 && tmp.IndexOf("rtp:") < 0)
            {
              SetupTv.Utils.GetQualifiedFilename(basePath, ref fileName);
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:PlayListPLSIO.cs


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