[longomatch] Keep original player state when detaching it



commit 98b78f81bf8adad03093c0cd3cd020758f23638f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Sep 12 03:27:57 2014 +0200

    Keep original player state when detaching it

 LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs       |    1 +
 LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs         |    7 ++++
 LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs |    6 +++
 LongoMatch.GUI/Gui/Component/AnalysisComponent.cs  |   39 ++++++++++++--------
 4 files changed, 37 insertions(+), 16 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
index 0205389..04edfb6 100644
--- a/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IPlayerBin.cs
@@ -35,6 +35,7 @@ namespace LongoMatch.Core.Interfaces.GUI
                bool Opened {get;}
                bool SeekingEnabled {set;}
                bool Sensitive {set; get;}
+               bool Playing { get; }
                IFramesCapturer FramesCapturer {get;set;}
 
                void Open (MediaFile file);
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index 55b44c4..4d061d9 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -176,6 +176,13 @@ namespace LongoMatch.Gui
                                vscale1.Visible = value;
                        }
                }
+               
+               public bool Playing {
+                       get {
+                               return player != null ? player.Playing : false;
+                       }
+               }
+               
                #endregion
                #region Public methods
                public void Open (MediaFile file)
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs 
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index d0113da..47e8cce 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -161,6 +161,12 @@ namespace LongoMatch.Gui
                
 #region Player
 
+               public bool Playing {
+                       get {
+                               return playerbin.Playing;
+                       }
+               }
+               
                public IFramesCapturer FramesCapturer {
                        set {
                                playerbin.FramesCapturer = value;
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index 38797d9..134ead8 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -82,32 +82,39 @@ namespace LongoMatch.Gui.Component
                                Config.EventsBroker.EmitKeyPressed(o, (int)args.Event.Key, 
(int)args.Event.State));
                }
                
-               public void DetachPlayer () {
-                       playercapturer.Pause();
+               public void DetachPlayer ()
+               {
+                       bool isPlaying = playercapturer.Playing;
+                       
+                       /* Pause the player here to prevent the sink drawing while the windows
+                        * are beeing changed */
+                       playercapturer.Pause ();
                        if (!detachedPlayer) {
                                EventBox box;
-                               Log.Debug("Detaching player");
+                               Log.Debug ("Detaching player");
                                
-                               playerWindow = new Gtk.Window(Constants.SOFTWARE_NAME);
-                               playerWindow.Icon = Stetic.IconLoader.LoadIcon(this, "longomatch", 
IconSize.Button);
-                               playerWindow.DeleteEvent += (o, args) => DetachPlayer();
-                               box = new EventBox();
+                               playerWindow = new Gtk.Window (Constants.SOFTWARE_NAME);
+                               playerWindow.Icon = Stetic.IconLoader.LoadIcon (this, "longomatch", 
IconSize.Button);
+                               playerWindow.DeleteEvent += (o, args) => DetachPlayer ();
+                               box = new EventBox ();
                                
-                               box.KeyPressEvent += (o, args) => OnKeyPressEvent(args.Event);
-                               playerWindow.Add(box);
+                               box.KeyPressEvent += (o, args) => OnKeyPressEvent (args.Event);
+                               playerWindow.Add (box);
                                
-                               box.Show();
-                               playerWindow.Show();
+                               box.Show ();
+                               playerWindow.Show ();
                                
-                               playercapturer.Reparent(box);
+                               playercapturer.Reparent (box);
                                videowidgetsbox.Visible = false;
                        } else {
-                               Log.Debug("Attaching player again");
+                               Log.Debug ("Attaching player again");
                                videowidgetsbox.Visible = true;
-                               playercapturer.Reparent(this.videowidgetsbox);
-                               playerWindow.Destroy();
+                               playercapturer.Reparent (this.videowidgetsbox);
+                               playerWindow.Destroy ();
+                       }
+                       if (isPlaying) {
+                               playercapturer.Play();
                        }
-                       playercapturer.Play();
                        detachedPlayer = !detachedPlayer;
                }
                


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