コード例 #1
0
ファイル: Program.cs プロジェクト: hermanho/TsRemux_HK
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new TsRemux());
     }
     else
     {
         TsRemux tsr = new TsRemux(args);
         Form f = null;
         if ((f = tsr.exec()) != null)
             Application.Run(f);
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: antiochus/tsremux
        // Terminate MPlayer.
        private void StopMPlayer()
        {
            lock (_Serializer)
            {
                if (_MPlayerProcess != null)
                {
                    _MPlayerProcess.CancelOutputRead();
                    _MPlayerProcess.Kill();

                    _FormInstance = null;
                    TrimSetTimer.Enabled = false;
                    _MPlayerProcess = null;

                    MPlayerEndUIConfig();
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: antiochus/tsremux
        // Start Mplayer and enable console output capture.
        private void StartMPlayer(string sFileName)
        {
            lock (_Serializer)
            {
                // Wait if the last process signals finish.
                if (_MPlayerProcess != null)
                {
                    MessageBox.Show(
                        this,
                        "MPlayer still running",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }

                MPlayerStartUIConfig();

                // Process related.
                _FormInstance = this;
                _dMPlayerStartTime = -1;
                _dCurrentTrimTime = 0;

                // Find MPlayer executable, either by user setting or in TsRemux.exe dir.
                AppSettingsReader Config = new AppSettingsReader();
                string sMPlayerExe = (string)Config.GetValue("MPlayerExe", typeof(string));
                // Check if configured exe exists.
                if (!File.Exists(sMPlayerExe))
                {
                    // Try to find one in startup dir.
                    sMPlayerExe = Path.Combine(Application.StartupPath, "mplayer.exe");
                    if (!File.Exists(sMPlayerExe))
                    {
                        MessageBox.Show(
                            this,
                            "MPlayer executable missing.",
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        return;
                    }
                }

                // Read user settings ...
                string sMPlayerCmdLine = (string)Config.GetValue("MPlayerCmdLine", typeof(string));

                // Append HWND from our picture box.
                sMPlayerCmdLine += string.Format(" -wid {0}", MPlayerPreview.Handle);

                // Need slave mode for control.
                sMPlayerCmdLine += " -loop 0 -slave";

                // Build file component.
                string sFile = "\"" + sFileName + "\"";

                // Create and configure process.
                try
                {
                    _MPlayerProcess = new Process();
                    _MPlayerProcess.StartInfo.FileName = sMPlayerExe;
                    _MPlayerProcess.StartInfo.Arguments = sMPlayerCmdLine + " " + sFile;
                    _MPlayerProcess.StartInfo.UseShellExecute = false;
                    _MPlayerProcess.StartInfo.CreateNoWindow = true;
                    _MPlayerProcess.StartInfo.RedirectStandardOutput = true;
                    _MPlayerProcess.OutputDataReceived += new DataReceivedEventHandler(CaptureMPlayer);
                    _MPlayerProcess.StartInfo.RedirectStandardInput = true;
                    /*
                    _MPlayerProcess.SynchronizingObject = this;
                    _MPlayerProcess.EnableRaisingEvents = true;
                    _MPlayerProcess.Exited += new EventHandler(MPlayerFinished);
                    */
                    _MPlayerProcess.Start();
                    _MPlayerProcess.BeginOutputReadLine();
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        this,
                        "MPlayer can't be started.",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    _MPlayerProcess = null;
                    return;
                }

                // Start timer to update UI.
                TrimSetTimer.Enabled = true;
            }
        }