using System.Diagnostics;\r
using System.Runtime.InteropServices;\r
using System.IO;\r
-using AxQTOControlLib;\r
+using Handbrake.EncodeQueue;\r
using Handbrake.Functions;\r
using QTOControlLib;\r
using QTOLibrary;\r
{\r
\r
QueryGenerator hb_common_func = new QueryGenerator();\r
- Encode process = new Encode();\r
+ EncodeAndQueueHandler process = new EncodeAndQueueHandler();\r
private delegate void UpdateUIHandler();\r
String currently_playing = "";\r
readonly frmMain mainWindow;\r
- private Process hbProc;\r
private Thread player;\r
private Boolean noQT;\r
\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show(mw, "It would appear QuickTime 7 is not installed. QuickTime preview functionality will be disabled! \n\n Debug Info:\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show(mw, "It would appear QuickTime 7 is not installed or not accessible. QuickTime preview functionality will be disabled! \n\n Debug Info:\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
btn_playQT.Enabled = false;\r
noQT = true;\r
}\r
btn_playQT.Enabled = false;\r
btn_playVLC.Enabled = false;\r
lbl_status.Text = "Encoding Sample for (VLC) ...";\r
- String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
+ int duration;\r
+ int.TryParse(cb_duration.Text, out duration);\r
+ String query = hb_common_func.generateCLIQuery(mainWindow, duration, cb_preview.Text);\r
ThreadPool.QueueUserWorkItem(procMonitor, query);\r
}\r
private void btn_playQT_Click(object sender, EventArgs e)\r
{\r
- lbl_status.Visible = true;\r
- try\r
+ if (mainWindow.text_destination.Text.Contains(".mkv"))\r
{\r
- QTControl.URL = "";\r
- if (File.Exists(currently_playing))\r
- File.Delete(currently_playing);\r
+ MessageBox.Show(this,\r
+ "The QuickTime Control does not support MKV files, It is recommended you use VLC option instead.",\r
+ "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
- catch (Exception)\r
+ else\r
{\r
- MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
- }\r
+ lbl_status.Visible = true;\r
+ try\r
+ {\r
+ QTControl.URL = "";\r
+ if (File.Exists(currently_playing))\r
+ File.Delete(currently_playing);\r
+ }\r
+ catch (Exception)\r
+ {\r
+ MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ }\r
\r
- btn_playQT.Enabled = false;\r
- btn_playVLC.Enabled = false;\r
- lbl_status.Text = "Encoding Sample for (QT) ...";\r
- String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
- ThreadPool.QueueUserWorkItem(procMonitor, query);\r
+ btn_playQT.Enabled = false;\r
+ btn_playVLC.Enabled = false;\r
+ lbl_status.Text = "Encoding Sample for (QT) ...";\r
+ int duration;\r
+ int.TryParse(cb_duration.Text, out duration);\r
+ String query = hb_common_func.generateCLIQuery(mainWindow, duration, cb_preview.Text);\r
+\r
+ ThreadPool.QueueUserWorkItem(procMonitor, query);\r
+ }\r
}\r
private void procMonitor(object state)\r
{\r
// Make sure we are not already encoding and if we are then display an error.\r
- if (hbProc != null)\r
+ if (process.hbProcess != null)\r
MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
{\r
- hbProc = process.runCli((string)state);\r
- hbProc.WaitForExit();\r
- hbProc = null;\r
+ process.RunCli((string)state);\r
+ if (process.hbProcess != null)\r
+ {\r
+ process.hbProcess.WaitForExit();\r
+ process.hbProcess = null;\r
+ }\r
encodeCompleted();\r
}\r
}\r
\r
// Get the sample filename\r
if (mainWindow.text_destination.Text != "")\r
- currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".mkv", "_sample.mkv");;\r
+ currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".mkv", "_sample.mkv"); ;\r
\r
// Play back in QT or VLC\r
if (playerSelection == "QT")\r
lbl_status.Text = "VLC will now launch.";\r
}\r
else\r
- MessageBox.Show(this, "Unable to detect VLC Player. \nPlease make sure VLC is installed and the directory specified in the program options is correct.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+ MessageBox.Show(this, "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\") ", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
else\r
MessageBox.Show(this, "Unable to find the preview file. Either the file was deleted or the encode failed. Check the activity log for details.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
BeginInvoke(new UpdateUIHandler(OpenMovie));\r
return;\r
}\r
- QTControl.Sizing = QTSizingModeEnum.qtControlFitsMovie;\r
QTControl.URL = currently_playing;\r
- QTControl.Sizing = QTSizingModeEnum.qtMovieFitsControl;\r
+ QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true);\r
+ QTControl.URL = currently_playing;\r
QTControl.Show();\r
\r
this.ClientSize = QTControl.Size;\r