예제 #1
0
        public static ActionResult InstallLAVFilters(Session session)
        {
            const string LAV_DOWNLOAD_URL        = "http://install.team-mediaportal.com/LAVFilters.exe";
            const string LAV_AUDIO_REGISTRY_PATH = @"CLSID\{E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491}\InprocServer32";
            const string LAV_VIDEO_REGISTRY_PATH = @"CLSID\{EE30215D-164F-4A92-A4EB-9D4C13390F9F}\InprocServer32";

            try
            {
                session.Log("LAVFilters: Checking if LAVFilters are registered");

                // 1. check if LAV Filters are registered
                RegistryKey audioKey = Registry.ClassesRoot.OpenSubKey(LAV_AUDIO_REGISTRY_PATH, false);
                RegistryKey videoKey = Registry.ClassesRoot.OpenSubKey(LAV_VIDEO_REGISTRY_PATH, false);
                if (audioKey != null && videoKey != null)
                {
                    var audioFilterPath = audioKey.GetValue(null) as string;
                    var videoFilterPath = videoKey.GetValue(null) as string;
                    if (!string.IsNullOrEmpty(audioFilterPath) && !string.IsNullOrEmpty(videoFilterPath))
                    {
                        if (File.Exists(audioFilterPath) && File.Exists(videoFilterPath))
                        {
                            session.Log("LAVFilters: Found Audio Filter at '{0}'", audioFilterPath);
                            session.Log("LAVFilters: Found Video Filter at '{0}'", videoFilterPath);
                            return(ActionResult.NotExecuted);
                        }
                    }
                }

                // 2. download installer
                string tempLAVFileName = Path.Combine(Path.GetTempPath(), "LAVFilters.exe");
                // if temp file is already present it was probably downloaded earlier - use it
                if (!File.Exists(tempLAVFileName))
                {
                    var client = new CompressionWebClient();
                    session.Log("LAVFilters: Downloading installer...");
                    client.DownloadFile(LAV_DOWNLOAD_URL, tempLAVFileName);
                    client.Dispose();
                }
                if (!File.Exists(tempLAVFileName)) // download must have failed
                {
                    return(ActionResult.NotExecuted);
                }

                // 3. run installer
                session.Log("LAVFilters: Running installer from '{0}'", tempLAVFileName);
                var process = Process.Start(tempLAVFileName, "/SILENT /SP-");
                process.WaitForExit(1000 * 60); // wait max. 1 minute for the installer to finish

                session.Log("LAVFilters: Successfully installed");

                return(ActionResult.Success);
            }
            catch (Exception ex)
            {
                session.Log("LAVFilters: Error: " + ex.Message);
                return(ActionResult.Failure);
            }
        }
 void DownloadThread()
 {
     lock (this) { runningThreads++; }
     try
     {
         string tempFile             = Path.GetTempFileName();
         CompressionWebClient client = new CompressionWebClient();
         int index = -1;
         while (index < onlineFiles.Count && !cancel)
         {
             lock (this)
             {
                 counter++;
                 index = counter;
             }
             if (index >= onlineFiles.Count)
             {
                 return;
             }
             string onlineFile = onlineFiles[index];
             bool   success    = false;
             try
             {
                 client.DownloadFile(onlineFile, tempFile);
                 var extCol = ExtensionCollection.Load(tempFile);
                 lock (this)
                 {
                     MpeCore.MpeInstaller.KnownExtensions.Add(extCol);
                 }
                 success = true;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(string.Format("Error downloading '{0}': {1}", onlineFile, ex.Message));
             }
             Invoke((Action)(() =>
             {
                 progressBar1.Value++;
                 listBox1.Items.Add(string.Format("{0}{1}", success ? "+" : "-", onlineFile));
                 listBox1.SelectedIndex = listBox1.Items.Count - 1;
                 listBox1.SelectedIndex = -1;
             }));
             if (File.Exists(tempFile))
             {
                 File.Delete(tempFile);
             }
         }
     }
     catch { }
     finally
     {
         lock (this)
         {
             runningThreads--;
             if (runningThreads <= 0)
             {
                 MpeCore.MpeInstaller.Save();
                 Invoke((Action)(() =>
                 {
                     DialogResult = cancel ? DialogResult.Cancel : DialogResult.OK;
                     Close();
                 }));
             }
         }
     }
 }
예제 #3
0
    public static ActionResult InstallLAVFilters(Session session)
    {
      const string LAV_DOWNLOAD_URL = "http://install.team-mediaportal.com/LAVFilters.exe";
      const string LAV_AUDIO_REGISTRY_PATH = @"CLSID\{E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491}\InprocServer32";
      const string LAV_VIDEO_REGISTRY_PATH = @"CLSID\{EE30215D-164F-4A92-A4EB-9D4C13390F9F}\InprocServer32";

      try
      {
        session.Log("LAVFilters: Checking if LAVFilters are registered");
        
        // 1. check if LAV Filters are registered
        RegistryKey audioKey = Registry.ClassesRoot.OpenSubKey(LAV_AUDIO_REGISTRY_PATH, false);
        RegistryKey videoKey = Registry.ClassesRoot.OpenSubKey(LAV_VIDEO_REGISTRY_PATH, false);
        if (audioKey != null && videoKey != null)
        {
          var audioFilterPath = audioKey.GetValue(null) as string;
          var videoFilterPath = videoKey.GetValue(null) as string;
          if (!string.IsNullOrEmpty(audioFilterPath) && !string.IsNullOrEmpty(videoFilterPath))
          {
            if (File.Exists(audioFilterPath) && File.Exists(videoFilterPath))
            {
              session.Log("LAVFilters: Found Audio Filter at '{0}'", audioFilterPath);
              session.Log("LAVFilters: Found Video Filter at '{0}'", videoFilterPath);
              return ActionResult.NotExecuted;
            }
          }
        }

        // 2. download installer
        string tempLAVFileName = Path.Combine(Path.GetTempPath(), "LAVFilters.exe");
        // if temp file is already present it was probably downloaded earlier - use it
        if (!File.Exists(tempLAVFileName))
        {
          var client = new CompressionWebClient();
          session.Log("LAVFilters: Downloading installer...");
          client.DownloadFile(LAV_DOWNLOAD_URL, tempLAVFileName);
          client.Dispose();
        }
        if (!File.Exists(tempLAVFileName)) // download must have failed
          return ActionResult.NotExecuted;

        // 3. run installer
        session.Log("LAVFilters: Running installer from '{0}'", tempLAVFileName);
        var process = Process.Start(tempLAVFileName, "/SILENT /SP-");
        process.WaitForExit(1000 * 60); // wait max. 1 minute for the installer to finish

        session.Log("LAVFilters: Successfully installed");

        return ActionResult.Success;
      }
      catch (Exception ex)
      {
        session.Log("LAVFilters: Error: " + ex.Message);
        return ActionResult.Failure;
      }
    }