From de7e8e8be0c1bd709a9f4381a06e786e75bd574a Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 4 Jan 2009 22:01:06 +0000 Subject: WinGui: - Updated Experimental Preview window to use QuickTime. Plays back video, Encodes samples just fine. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2058 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Experimental/frmPreviewAX.Designer.cs | 179 +++++++++++++-------------- win/C#/Experimental/frmPreviewAX.cs | 134 ++++---------------- win/C#/Experimental/frmPreviewAX.resx | 44 +------ 3 files changed, 118 insertions(+), 239 deletions(-) (limited to 'win/C#') diff --git a/win/C#/Experimental/frmPreviewAX.Designer.cs b/win/C#/Experimental/frmPreviewAX.Designer.cs index 534abaaeb..775e5ebeb 100644 --- a/win/C#/Experimental/frmPreviewAX.Designer.cs +++ b/win/C#/Experimental/frmPreviewAX.Designer.cs @@ -30,48 +30,99 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPreviewAX)); this.toolBar = new System.Windows.Forms.ToolStrip(); + this.lbl_preview = new System.Windows.Forms.ToolStripLabel(); + this.cb_preview = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel(); + this.cb_duration = new System.Windows.Forms.ToolStripComboBox(); this.btn_encode = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.btn_play = new System.Windows.Forms.ToolStripButton(); - this.btn_stop = new System.Windows.Forms.ToolStripButton(); - this.btn_step_fwd = new System.Windows.Forms.ToolStripButton(); - this.btn_step_back = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.btn_reset = new System.Windows.Forms.ToolStripButton(); this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.txt_position = new System.Windows.Forms.ToolStripStatusLabel(); - this.vlc_player = new AxAXVLC.AxVLCPlugin2(); + this.QTControl = new AxQTOControlLib.AxQTControl(); this.toolBar.SuspendLayout(); - this.statusStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.vlc_player)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.QTControl)).BeginInit(); this.SuspendLayout(); // // toolBar // this.toolBar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.lbl_preview, + this.cb_preview, + this.toolStripLabel2, + this.cb_duration, this.btn_encode, this.toolStripSeparator1, - this.btn_play, - this.btn_stop, - this.btn_step_fwd, - this.btn_step_back, - this.toolStripSeparator2, - this.btn_reset}); + this.btn_play}); this.toolBar.Location = new System.Drawing.Point(0, 0); this.toolBar.Name = "toolBar"; this.toolBar.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; - this.toolBar.Size = new System.Drawing.Size(750, 39); + this.toolBar.Size = new System.Drawing.Size(774, 39); this.toolBar.TabIndex = 37; this.toolBar.Text = "toolStrip1"; // + // lbl_preview + // + this.lbl_preview.BackColor = System.Drawing.Color.Transparent; + this.lbl_preview.Name = "lbl_preview"; + this.lbl_preview.Size = new System.Drawing.Size(89, 36); + this.lbl_preview.Text = "Start at Preview:"; + // + // cb_preview + // + this.cb_preview.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cb_preview.DropDownWidth = 75; + this.cb_preview.FlatStyle = System.Windows.Forms.FlatStyle.Standard; + this.cb_preview.Items.AddRange(new object[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10"}); + this.cb_preview.Name = "cb_preview"; + this.cb_preview.Size = new System.Drawing.Size(75, 39); + // + // toolStripLabel2 + // + this.toolStripLabel2.BackColor = System.Drawing.Color.Transparent; + this.toolStripLabel2.Name = "toolStripLabel2"; + this.toolStripLabel2.Size = new System.Drawing.Size(98, 36); + this.toolStripLabel2.Text = "Duration (seconds)"; + // + // cb_duration + // + this.cb_duration.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cb_duration.DropDownWidth = 75; + this.cb_duration.FlatStyle = System.Windows.Forms.FlatStyle.Standard; + this.cb_duration.Items.AddRange(new object[] { + "5", + "10", + "15", + "20", + "25", + "30", + "35", + "40", + "45", + "50", + "55", + "60"}); + this.cb_duration.Margin = new System.Windows.Forms.Padding(0); + this.cb_duration.Name = "cb_duration"; + this.cb_duration.Size = new System.Drawing.Size(75, 39); + // // btn_encode // this.btn_encode.Image = global::Handbrake.Properties.Resources.Play; this.btn_encode.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.btn_encode.ImageTransparentColor = System.Drawing.Color.Magenta; this.btn_encode.Name = "btn_encode"; - this.btn_encode.Size = new System.Drawing.Size(127, 36); + this.btn_encode.Size = new System.Drawing.Size(115, 36); this.btn_encode.Text = "Encode Sample"; this.btn_encode.Click += new System.EventHandler(this.btn_encode_Click); // @@ -86,85 +137,35 @@ this.btn_play.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.btn_play.ImageTransparentColor = System.Drawing.Color.Magenta; this.btn_play.Name = "btn_play"; - this.btn_play.Size = new System.Drawing.Size(64, 36); + this.btn_play.Size = new System.Drawing.Size(63, 36); this.btn_play.Text = "Play"; this.btn_play.Click += new System.EventHandler(this.btn_play_Click); // - // btn_stop - // - this.btn_stop.Image = global::Handbrake.Properties.Resources.stop; - this.btn_stop.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.btn_stop.ImageTransparentColor = System.Drawing.Color.MediumAquamarine; - this.btn_stop.Name = "btn_stop"; - this.btn_stop.Size = new System.Drawing.Size(69, 36); - this.btn_stop.Text = "Stop"; - this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); - // - // btn_step_fwd - // - this.btn_step_fwd.Image = ((System.Drawing.Image)(resources.GetObject("btn_step_fwd.Image"))); - this.btn_step_fwd.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_step_fwd.Name = "btn_step_fwd"; - this.btn_step_fwd.Size = new System.Drawing.Size(64, 36); - this.btn_step_fwd.Text = "Slower"; - // - // btn_step_back - // - this.btn_step_back.Image = ((System.Drawing.Image)(resources.GetObject("btn_step_back.Image"))); - this.btn_step_back.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_step_back.Name = "btn_step_back"; - this.btn_step_back.Size = new System.Drawing.Size(60, 36); - this.btn_step_back.Text = "Faster"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 39); - // - // btn_reset - // - this.btn_reset.Image = global::Handbrake.Properties.Resources.window; - this.btn_reset.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.btn_reset.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_reset.Name = "btn_reset"; - this.btn_reset.Size = new System.Drawing.Size(148, 36); - this.btn_reset.Text = "Reset Window Size"; - this.btn_reset.Click += new System.EventHandler(this.btn_reset_Click); - // // statusStrip // - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.txt_position}); - this.statusStrip.Location = new System.Drawing.Point(0, 438); + this.statusStrip.Location = new System.Drawing.Point(0, 486); this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(750, 23); + this.statusStrip.Size = new System.Drawing.Size(774, 22); this.statusStrip.TabIndex = 38; this.statusStrip.Text = "statusStrip1"; // - // txt_position - // - this.txt_position.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txt_position.Name = "txt_position"; - this.txt_position.Size = new System.Drawing.Size(704, 18); - this.txt_position.Spring = true; - this.txt_position.Text = "DANGER! MAY CAUSE BLUESCREEN OF DEATH!!, SEE CODE FOR COMMENTS"; - // - // vlc_player + // QTControl // - this.vlc_player.Dock = System.Windows.Forms.DockStyle.Fill; - this.vlc_player.Enabled = true; - this.vlc_player.Location = new System.Drawing.Point(0, 39); - this.vlc_player.Name = "vlc_player"; - this.vlc_player.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("vlc_player.OcxState"))); - this.vlc_player.Size = new System.Drawing.Size(750, 399); - this.vlc_player.TabIndex = 39; + this.QTControl.Enabled = true; + this.QTControl.Location = new System.Drawing.Point(0, 42); + this.QTControl.Name = "QTControl"; + this.QTControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("QTControl.OcxState"))); + this.QTControl.Size = new System.Drawing.Size(1920, 1080); + this.QTControl.TabIndex = 39; + this.QTControl.Visible = false; // // frmPreviewAX // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(750, 461); - this.Controls.Add(this.vlc_player); + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(774, 508); + this.Controls.Add(this.QTControl); this.Controls.Add(this.statusStrip); this.Controls.Add(this.toolBar); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -174,9 +175,7 @@ this.TopMost = true; this.toolBar.ResumeLayout(false); this.toolBar.PerformLayout(); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.vlc_player)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.QTControl)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -188,13 +187,11 @@ private System.Windows.Forms.ToolStripButton btn_encode; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton btn_play; - private System.Windows.Forms.ToolStripButton btn_step_fwd; - private System.Windows.Forms.ToolStripButton btn_step_back; - private System.Windows.Forms.ToolStripButton btn_stop; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.ToolStripStatusLabel txt_position; - private System.Windows.Forms.ToolStripButton btn_reset; - private AxAXVLC.AxVLCPlugin2 vlc_player; + private AxQTOControlLib.AxQTControl QTControl; + private System.Windows.Forms.ToolStripComboBox cb_preview; + private System.Windows.Forms.ToolStripLabel lbl_preview; + private System.Windows.Forms.ToolStripLabel toolStripLabel2; + private System.Windows.Forms.ToolStripComboBox cb_duration; } } \ No newline at end of file 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 diff --git a/win/C#/Experimental/frmPreviewAX.resx b/win/C#/Experimental/frmPreviewAX.resx index 6809a5a8e..670acba25 100644 --- a/win/C#/Experimental/frmPreviewAX.resx +++ b/win/C#/Experimental/frmPreviewAX.resx @@ -120,53 +120,19 @@ 17, 17 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL - U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI - VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ - QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 - /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 - cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j - 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR - dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B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