[chronojump] Encoder play video in main GUI



commit 396237024f7756e18a96278b6df91d934dd74144
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Feb 8 12:41:17 2015 +0000

    Encoder play video in main GUI

 CesarPlayer/Gui/PlayerBin.cs |    4 +
 glade/chronojump.glade       |  135 ++++++++++++++++++++++++++++++++++++++----
 src/gui/chronojump.cs        |   52 +++++++++++-----
 src/gui/encoder.cs           |   35 +++++++++--
 4 files changed, 189 insertions(+), 37 deletions(-)
---
diff --git a/CesarPlayer/Gui/PlayerBin.cs b/CesarPlayer/Gui/PlayerBin.cs
index c495429..089429a 100644
--- a/CesarPlayer/Gui/PlayerBin.cs
+++ b/CesarPlayer/Gui/PlayerBin.cs
@@ -328,6 +328,10 @@ namespace LongoMatch.Gui
                        controlsbox.Sensitive = false;
                        vscale1.Sensitive = false;                              
                }               
+                       
+               public void SeeControlsBox(bool see){
+                       controlsbox.Visible = see;
+               }
                
 #endregion
                
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 27c1868..7a41cc2 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6416,6 +6416,9 @@ Second Chronopic to platforms.</property>
                                                         <child>
                                                           <placeholder/>
                                                         </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
                                                       </widget>
                                                       <packing>
                                                         <property name="expand">True</property>
@@ -7206,6 +7209,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -8248,6 +8254,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -8931,6 +8940,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -13931,20 +13943,25 @@ on current Chronojump version.</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="position">200</property>
                                                 <child>
-                                                  <widget class="GtkFrame" id="frame16">
+                                                  <widget class="GtkHPaned" id="hpaned2">
                                                     <property name="visible">True</property>
-                                                    <property name="can_focus">False</property>
-                                                    <property name="label_xalign">0</property>
-                                                    <property 
name="label_yalign">0.69999998807907104</property>
-                                                    <property name="shadow_type">none</property>
+                                                    <property name="can_focus">True</property>
+                                                    <property name="position">400</property>
                                                     <child>
-                                                      <widget class="GtkAlignment" id="alignment19">
+                                                      <widget class="GtkFrame" id="frame16">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
-                                                        <property name="left_padding">6</property>
-                                                        <property name="right_padding">6</property>
+                                                        <property name="label_xalign">0</property>
+                                                        <property 
name="label_yalign">0.69999998807907104</property>
+                                                        <property name="shadow_type">none</property>
                                                         <child>
-                                                          <widget class="GtkVBox" id="vbox6">
+                                                          <widget class="GtkAlignment" id="alignment19">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="left_padding">6</property>
+                                                            <property name="right_padding">6</property>
+                                                            <child>
+                                                            <widget class="GtkVBox" id="vbox6">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">2</property>
@@ -14022,19 +14039,66 @@ on current Chronojump version.</property>
                                                             <property name="position">0</property>
                                                             </packing>
                                                             </child>
+                                                            </widget>
+                                                            </child>
+                                                          </widget>
+                                                        </child>
+                                                        <child>
+                                                          <widget class="GtkLabel" id="label75">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Set</property>
+                                                            <property name="use_markup">True</property>
                                                           </widget>
+                                                          <packing>
+                                                            <property name="type">label_item</property>
+                                                          </packing>
                                                         </child>
                                                       </widget>
+                                                      <packing>
+                                                        <property name="resize">False</property>
+                                                        <property name="shrink">True</property>
+                                                      </packing>
                                                     </child>
                                                     <child>
-                                                      <widget class="GtkLabel" id="label75">
+                                                      <widget class="GtkFrame" id="frame2">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
-                                                        <property name="label" 
translatable="yes">Set</property>
-                                                        <property name="use_markup">True</property>
+                                                        <property name="label_xalign">0</property>
+                                                        <property 
name="label_yalign">0.69999998807907104</property>
+                                                        <property name="shadow_type">none</property>
+                                                        <child>
+                                                          <widget class="GtkAlignment" id="alignment25">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="left_padding">6</property>
+                                                            <property name="right_padding">6</property>
+                                                            <child>
+                                                            <widget class="GtkViewport" 
id="viewport_capture_encoder">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            </widget>
+                                                            </child>
+                                                          </widget>
+                                                        </child>
+                                                        <child>
+                                                          <widget class="GtkLabel" id="label123">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Video</property>
+                                                            <property name="use_markup">True</property>
+                                                          </widget>
+                                                          <packing>
+                                                            <property name="type">label_item</property>
+                                                          </packing>
+                                                        </child>
                                                       </widget>
                                                       <packing>
-                                                        <property name="type">label_item</property>
+                                                        <property name="resize">True</property>
+                                                        <property name="shrink">True</property>
                                                       </packing>
                                                     </child>
                                                   </widget>
@@ -19145,6 +19209,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -19736,6 +19803,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -20819,6 +20889,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -20959,6 +21032,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -30402,6 +30478,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -32373,6 +32467,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                 <child>
                                   <placeholder/>
                                 </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -33002,6 +33099,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -35597,6 +35697,9 @@ show elevation as:</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -35852,6 +35955,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -36122,6 +36228,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3b6653b..afcdef9 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -215,6 +215,7 @@ public partial class ChronoJumpWindow
        
        [Widget] Gtk.HBox hbox_video_capture;
        [Widget] Gtk.HBox hbox_video_capture_encoder;
+       [Widget] Gtk.Viewport viewport_capture_encoder;
        [Widget] Gtk.Label label_video_feedback;
        [Widget] Gtk.Label label_video_feedback_encoder;
        [Widget] Gtk.CheckButton checkbutton_video;
@@ -5004,19 +5005,36 @@ LogB.Debug("X");
         */
 
        
-       private bool playVideo(string fileName) {
+       private bool playVideo(string fileName, bool encoder, bool play) 
+       {
                if(File.Exists(fileName)) {
+                       LogB.Information("Play video starting...");
                        PlayerBin player = new PlayerBin();
                        player.Open(fileName);
 
-                       //without these lines works also but has less functionalities (speed, go to ms)
-                       Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
-                       d.Add(player);
-                       d.Modal = true;
-                       d.SetDefaultSize(500,400);
-                       d.ShowAll();
-                       d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); 
player.Dispose();};
-                       player.Play();
+                       //plays at main encoder GUI
+                       if(encoder) {
+                               //don't add to an hbox, it will show halfsized
+                               //hbox_video_capture_encoder_big.Add(player);
+                               //hbox_video_capture_encoder_big.WidthRequest=500;
+                               //hbox_video_capture_encoder_big.HeightRequest=400;
+                               
+                               viewport_capture_encoder.Add(player);
+                               player.SeeControlsBox(true);
+                       } else { //plays in a separate window
+                               //without these lines works also but has less functionalities (speed, go to 
ms)
+                               Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
+                               d.Add(player);
+                               d.Modal = true;
+                               d.SetDefaultSize(500,400);
+                               d.ShowAll();
+                               d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); 
player.Dispose();};
+                       }
+                       
+                       if(play) {
+                               LogB.Information("Play video playing...");
+                               player.Play();
+                       }
                        return true;    
                }
                return false;   
@@ -5058,56 +5076,56 @@ LogB.Debug("X");
                                break;
                }
 
-               playVideo(Util.GetVideoFileName(currentSession.UniqueID, type, id));
+               playVideo(Util.GetVideoFileName(currentSession.UniqueID, type, id), false, true);
        }
 
        private void on_video_play_selected_jump_clicked (object o, EventArgs args) {
                if (myTreeViewJumps.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.JUMP,
-                                               myTreeViewJumps.EventSelectedID));
+                                               myTreeViewJumps.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_jump_rj_clicked (object o, EventArgs args) {
                if (myTreeViewJumpsRj.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.JUMP_RJ,
-                                               myTreeViewJumpsRj.EventSelectedID));
+                                               myTreeViewJumpsRj.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_run_clicked (object o, EventArgs args) {
                if (myTreeViewRuns.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.RUN,
-                                               myTreeViewRuns.EventSelectedID));
+                                               myTreeViewRuns.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_run_interval_clicked (object o, EventArgs args) {
                if (myTreeViewRunsInterval.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.RUN_I,
-                                               myTreeViewRunsInterval.EventSelectedID));
+                                               myTreeViewRunsInterval.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_reaction_time_clicked (object o, EventArgs args) {
                if (myTreeViewReactionTimes.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.RT,
-                                               myTreeViewReactionTimes.EventSelectedID));
+                                               myTreeViewReactionTimes.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_pulse_clicked (object o, EventArgs args) {
                if (myTreeViewPulses.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.PULSE,
-                                               myTreeViewPulses.EventSelectedID));
+                                               myTreeViewPulses.EventSelectedID), false, true);
        }
 
        private void on_video_play_selected_multi_chronopic_clicked (object o, EventArgs args) {
                if (myTreeViewMultiChronopic.EventSelectedID > 0) 
                        playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
                                                Constants.TestTypes.MULTICHRONOPIC,
-                                               myTreeViewMultiChronopic.EventSelectedID));
+                                               myTreeViewMultiChronopic.EventSelectedID), false, true);
        }
 
        /* ---------------------------------------------------------
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e293204..4700608 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -54,7 +54,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_encoder_capture_finish;
        [Widget] Gtk.Button button_encoder_recalculate;
        [Widget] Gtk.Button button_encoder_load_signal;
-       [Widget] Gtk.Button button_video_play_this_test_encoder;
+       //[Widget] Gtk.Button button_video_play_this_test_encoder;
        [Widget] Gtk.Viewport viewport_image_encoder_capture;
        [Widget] Gtk.Image image_encoder_capture;
        [Widget] Gtk.Image image_encoder_capture_open;
@@ -1286,7 +1286,11 @@ public partial class ChronoJumpWindow
                                //entry_encoder_signal_comment.Text = eSQL.description;
                                encoderTimeStamp = eSQL.GetDate(false); 
                                encoderSignalUniqueID = eSQL.uniqueID;
-                               button_video_play_this_test_encoder.Sensitive = (eSQL.videoURL != "");
+                               
+                               //button_video_play_this_test_encoder.Sensitive = (eSQL.videoURL != "");
+                               viewport_capture_encoder.Sensitive = (eSQL.videoURL != "");
+                               if(eSQL.videoURL != "")
+                                       playEncoderVideo(false);
 
                                encoderConfigurationCurrent = eSQL.encoderConfiguration;
 
@@ -1821,7 +1825,8 @@ public partial class ChronoJumpWindow
                                encoderSignalUniqueID = myID;
                                feedback = Catalog.GetString("Set saved");
                        
-                               button_video_play_this_test_encoder.Sensitive = false;
+                               //button_video_play_this_test_encoder.Sensitive = false;
+                               viewport_capture_encoder.Sensitive = false;
                                //copy video    
                                if(preferences.videoOn) {
                                        if(Util.CopyTempVideo(currentSession.UniqueID, 
@@ -1833,7 +1838,9 @@ public partial class ChronoJumpWindow
                                                //need assign uniqueID to update and add the URL of video
                                                eSQL.uniqueID = encoderSignalUniqueID;
                                                SqliteEncoder.Update(false, eSQL);
-                                               button_video_play_this_test_encoder.Sensitive = true;
+                                               //button_video_play_this_test_encoder.Sensitive = true;
+                                               viewport_capture_encoder.Sensitive = true;
+                                               playEncoderVideo(false);
                                        } else {
                                                new DialogMessage(Constants.MessageTypes.WARNING, 
                                                                Catalog.GetString("Sorry, video cannot be 
stored."));
@@ -5363,7 +5370,8 @@ LogB.Debug("D");
                        capturer.ClickRec();
                        label_video_feedback_encoder.Text = "Rec.";
                }
-               button_video_play_this_test_encoder.Sensitive = false; 
+               //button_video_play_this_test_encoder.Sensitive = false; 
+               viewport_capture_encoder.Sensitive = false;
        }
 
        private void encoderStopVideoRecord() {
@@ -5378,8 +5386,21 @@ LogB.Debug("D");
 
 
        void on_video_play_this_test_encoder_clicked (object o, EventArgs args) {
-               if(! playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                       Constants.TestTypes.ENCODER, Convert.ToInt32(encoderSignalUniqueID))))
+               playEncoderVideo(true);
+       }
+
+       void playEncoderVideo(bool play) {
+               string file = Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.ENCODER, Convert.ToInt32(encoderSignalUniqueID));
+
+               bool errors = false;
+               if(file == null || file == "") 
+                       errors = true;
+               else
+                       if(! playVideo(file, true, play)) //encoder, start playing?
+                               errors = true;
+
+               if(errors)
                        new DialogMessage(Constants.MessageTypes.WARNING, 
                                        Catalog.GetString("Sorry, file not found"));
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]