+ #region Playback\r
+\r
+ /// <summary>\r
+ /// Play the video back in the QuickTime control\r
+ /// </summary>\r
+ private void Play()\r
+ {\r
+ Player = new Thread(OpenMovie) {IsBackground = true};\r
+ Player.Start();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Play the video back in an external VLC Player\r
+ /// </summary>\r
+ private void PlayVLC()\r
+ {\r
+ // Launch VLC and Play video.\r
+ if (CurrentlyPlaying != string.Empty)\r
+ {\r
+ if (File.Exists(CurrentlyPlaying))\r
+ {\r
+ // Attempt to find VLC if it doesn't exist in the default set location.\r
+ string vlcPath;\r
+\r
+ if (8 == IntPtr.Size ||\r
+ (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))\r
+ vlcPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)");\r
+ else\r
+ vlcPath = Environment.GetEnvironmentVariable("ProgramFiles");\r
+\r
+ vlcPath = vlcPath != null\r
+ ? vlcPath + @"\VideoLAN\VLC\vlc.exe"\r
+ : @"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe";\r
+\r
+ if (!File.Exists(Properties.Settings.Default.VLC_Path))\r
+ {\r
+ if (File.Exists(vlcPath))\r
+ {\r
+ Properties.Settings.Default.VLC_Path = "C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe";\r
+ Properties.Settings.Default.Save(); // Save this new path if it does\r
+ }\r
+ else\r
+ {\r
+ MessageBox.Show(this, \r
+ "Unable to detect VLC Player. \nPlease make sure VLC is installed and the directory specified in HandBrake's options is correct. (See: \"Tools Menu > Options > Picture Tab\") ", \r
+ "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ }\r
+ }\r
+\r
+ if (File.Exists(Properties.Settings.Default.VLC_Path))\r
+ {\r
+ string args = "\"" + CurrentlyPlaying + "\"";\r
+ ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.VLC_Path, args);\r
+ System.Diagnostics.Process.Start(vlc);\r
+ }\r
+ }\r
+ else\r
+ MessageBox.Show(this, \r
+ "Unable to find the preview file. Either the file was deleted or the encode failed. Check the activity log for details.", \r
+ "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// QT control - Open the file\r
+ /// </summary>\r
+ [STAThread]\r
+ private void OpenMovie()\r
+ {\r
+ try\r
+ {\r
+ if (InvokeRequired)\r
+ {\r
+ BeginInvoke(new UpdateUIHandler(OpenMovie));\r
+ return;\r
+ }\r
+ QTControl.URL = CurrentlyPlaying;\r
+ QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true);\r
+ QTControl.URL = CurrentlyPlaying;\r
+ QTControl.Show();\r
+\r
+ this.ClientSize = QTControl.Size;\r
+ this.Height += 25;\r
+ }\r
+ catch (COMException ex)\r
+ {\r
+ QTUtils qtu = new QTUtils();\r
+ MessageBox.Show(this, \r
+ "Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") +\r
+ "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode), "QT", \r
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ MessageBox.Show(this, "Unable to open movie:\n\n" + ex, "QT", MessageBoxButtons.OK, \r
+ MessageBoxIcon.Warning);\r
+ }\r
+ }\r
+\r
+ #endregion\r
+\r
+ protected override void OnClosing(System.ComponentModel.CancelEventArgs e)\r
+ {\r
+ Process.EncodeStarted -= Process_EncodeStarted;\r
+ base.OnClosing(e);\r
+ }\r