Exemple #1
0
 public static void loadPlayList(string FileName, string supExt, PlFormat format,
     ref List<MediaItem> lContainer, ListBox.ObjectCollection lCollection, ref bool interrupt)
 {
     StreamReader srr = File.OpenText(FileName);
     Regex headText = null;
     switch (format)
     {
         case PlFormat.yspl:
             headText = new Regex("#YAMP Simplified PlayList#");
             break;
         case PlFormat.m3u:
         case PlFormat.m3u8:
             headText = new Regex("#*M3U");
             break;
         case PlFormat.unsupported:
             break;
     }
     if ( headText.IsMatch( srr.ReadLine() ) )
     {
         lContainer.Clear();
         lCollection.Clear();
         string readIn;
         if (format == PlFormat.yspl)
         {
             readIn = srr.ReadLine();
         }
         //bool ok = true;
         do
         {
             readIn = srr.ReadLine();
             if (readIn != null)
             {
                 if (!readIn.Contains("#End ... Written "))
                 {
                     if (!readIn.Contains("#"))
                     {
                         if(readIn.StartsWith(@"\"))
                         {
                             readIn = Environment.GetEnvironmentVariable("%SYSTEMDRIVE%",
                                 EnvironmentVariableTarget.Machine) + readIn;
                         }
                         string[] _file = new string[] { readIn };
                         LoadMultiFiles(ref _file, supExt, ref lContainer, lCollection, ref interrupt);
                     }
                 }
                 else
                     break;
             }
             else
             {
                 break;
                 //ok = false;
             }
         }
         while (true); //(ok);
     }
     else
     {
         MBoxHelper.ShowWarnMsg("Not a valid YAMP PlayList!",
             "Error on playlist load!");
     }
     srr.Close();
 }
Exemple #2
0
 public static void savePlayList(string FileName, PlFormat format, List<MediaItem> Container)
 {
     if (File.Exists(FileName))
     {
         File.Delete(FileName);
     }
     StreamWriter swr = File.CreateText(FileName);
     switch (format)
     {
         case PlFormat.yspl:
             {
                 swr.WriteLine("#YAMP Simplified PlayList#");
                 swr.WriteLine("#Started at " + DateTime.Now + ":" + DateTime.Now.Millisecond + "#");
             }
             break;
         case PlFormat.m3u:
         case PlFormat.m3u8:
             {
                 swr.WriteLine("#EXTM3U");
             }
             break;
         default:
             {
                 swr.WriteLine("# WTF File Extension you want to use??? #");
             }
             break;
     }
     int i = 0;
     foreach (MediaItem writeOut in Container)
     {
         swr.WriteLine(writeOut.getFilePath);
         i++;
     }
     if (format == PlFormat.yspl)
     {
         swr.WriteLine("#End ... Written " + i + " FilePaths with YAMP!#");
         swr.WriteLine("#Closed at " + DateTime.Now + ":" + DateTime.Now.Millisecond + "#");
     }
     swr.Close();
 }