summaryrefslogtreecommitdiffstats
path: root/win/C#/Experimental/frmPreviewAX.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/Experimental/frmPreviewAX.cs')
-rw-r--r--win/C#/Experimental/frmPreviewAX.cs134
1 files changed, 25 insertions, 109 deletions
diff --git a/win/C#/Experimental/frmPreviewAX.cs b/win/C#/Experimental/frmPreviewAX.cs
index bbcc8202e..89ccceccd 100644
--- a/win/C#/Experimental/frmPreviewAX.cs
+++ b/win/C#/Experimental/frmPreviewAX.cs
@@ -7,18 +7,15 @@ using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
+using System.Runtime.InteropServices;
+using QTOControlLib;
+using QTOLibrary;
namespace Handbrake
{
public partial class frmPreviewAX : Form
{
- // !!!!!!!!!!!! WARNING !!!!!!!!!!!!
- // This code may cause a Blue Screen of Death if run.
- // This usually happens after the VLC active X control has been playing video for a short period
- // and the user tries to close the window. Calling vlc_player.dispose() also causes this I believe.
- // Patches to fix this would be very welcome!
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Handbrake.QueryGenerator hb_common_func = new Handbrake.QueryGenerator();
Functions.Encode process = new Functions.Encode();
@@ -26,100 +23,48 @@ namespace Handbrake
String currently_playing = "";
frmMain mainWindow;
private Process hbProc;
- Boolean playing = false;
- int window_height;
- int window_width;
-
- public frmPreviewAX(frmMain mw, int w, int h)
+ public frmPreviewAX(frmMain mw)
{
InitializeComponent();
-
- this.Width = w;
- this.Height = h + statusStrip.Height + toolBar.Height;
this.mainWindow = mw;
-
- resizeWindowUntilCorrect(w, h);
-
- vlc_player.Height = h;
- vlc_player.Width = w;
+ cb_preview.SelectedIndex = 0;
+ cb_duration.SelectedIndex = 1;
}
- private void resizeWindowUntilCorrect(int w, int h)
- {
- // This needs fixed. It makes the window seriously slow to load.
- while (vlc_player.Width != w || vlc_player.Height != h)
- {
- if (vlc_player.Width < w)
- this.Width++;
-
- if (vlc_player.Width > w)
- this.Width--;
-
- if (vlc_player.Height < h)
- this.Height++;
-
- if (vlc_player.Height > h)
- this.Height--;
- }
- window_height = this.Height;
- window_width = this.Width;
- }
- private void btn_reset_Click(object sender, EventArgs e)
- {
- this.WindowState = FormWindowState.Normal;
- this.Width = window_width;
- this.Height = window_height;
- }
-
- // Playback Controls
private void btn_play_Click(object sender, EventArgs e)
{
- // Get the Destination of the sample video.
- currently_playing = "";
if (mainWindow.text_destination.Text != "")
currently_playing = mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm");
- if (currently_playing != "" && playing != true)
- {
- vlc_player.playlist.clear();
- vlc_player.playlist.add(currently_playing, null, null);
- vlc_player.playlist.play();
- }
+ OpenMovie(currently_playing);
+
+ this.Width = QTControl.Width + 5;
+ this.Height = QTControl.Height + 90;
+ }
- if (playing == false)
+ private void OpenMovie(string url)
+ {
+ try
{
- btn_play.Text = "Pause";
- btn_play.Image = Handbrake.Properties.Resources.Pause;
- playing = true;
+ QTControl.URL = url;
+ QTControl.Show();
}
- else
+ catch (COMException ex)
{
- vlc_player.playlist.togglePause();
- btn_play.Text = "Play";
- btn_play.Image = Handbrake.Properties.Resources.Play;
- playing = false;
+ QTUtils qtu = new QTUtils();
+ MessageBox.Show("Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString());
}
- }
- private void btn_stop_Click(object sender, EventArgs e)
- {
- if (vlc_player.playlist.isPlaying)
+ catch (Exception ex)
{
- vlc_player.playlist.stop();
- vlc_player.playlist.clear();
- //vlc_player.Dispose(); // Causes a BlueScreen of Death!!!
- btn_play.Text = "Play";
- playing = false;
+ MessageBox.Show("Unable to open movie:\n\n" + ex.ToString());
}
}
-
- // Encoding a Sample
+ #region Encode Sample
private void btn_encode_Click(object sender, EventArgs e)
{
- String query;
- query = hb_common_func.GeneratePreviewQuery(mainWindow,"30");
-
+ String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);
ThreadPool.QueueUserWorkItem(procMonitor, query);
}
private void procMonitor(object state)
@@ -134,36 +79,7 @@ namespace Handbrake
hbProc = null;
}
}
-
- protected override void OnClosing(CancelEventArgs e)
- {
-
- /* try
- {
- while (vlc_player.playlist.isPlaying)
- {
- vlc_player.playlist.stop();
- Thread.Sleep(100);
- }
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.ToString());
- }
-
-
- //vlc_player.Dispose();
- while (vlc_player.IsDisposed == false)
- {
- Thread.Sleep(100);
- }
- vlc_player = null;
- */
-
- this.Dispose();
- this.Hide();
- }
-
+ #endregion
}
-}
+} \ No newline at end of file