[longomatch] Save automatically playback rate for plays



commit 06e7ba36723a2752d508bcf43d51deb1028d286a
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Jul 4 19:05:49 2013 +0200

    Save automatically playback rate for plays

 LongoMatch.Core/Handlers/Handlers.cs               |    2 -
 LongoMatch.Core/Handlers/Multimedia.cs             |    1 +
 LongoMatch.Core/Interfaces/GUI/IMainWindow.cs      |    1 -
 LongoMatch.Core/Interfaces/GUI/IPlayer.cs          |    3 +-
 LongoMatch.Core/Store/Play.cs                      |    6 +++
 LongoMatch.Core/Store/PlayListPlay.cs              |    4 +-
 .../Store/Templates/CategoriesTemplate.cs          |    1 -
 LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs         |   42 +++++++++++++-------
 LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs |   10 ++++-
 LongoMatch.GUI.Multimedia/gtk-gui/objects.xml      |    2 +
 LongoMatch.GUI/Gui/Component/PlayListWidget.cs     |    7 ---
 .../Gui/Component/PlayersListTreeWidget.cs         |    5 +-
 .../Gui/Component/PlaysListTreeWidget.cs           |    5 +-
 LongoMatch.GUI/Gui/Component/TimeScale.cs          |    2 +-
 LongoMatch.GUI/Gui/MainWindow.cs                   |    7 ---
 LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs    |   13 ------
 LongoMatch.GUI/gtk-gui/objects.xml                 |    6 +--
 LongoMatch.Services/Services/EventsManager.cs      |   12 +++++-
 LongoMatch.Services/Services/PlaylistManager.cs    |   10 +----
 19 files changed, 68 insertions(+), 71 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index e666103..25de474 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -72,8 +72,6 @@ namespace LongoMatch.Handlers
        public delegate void PlayListNodeAddedHandler(Play play);
        /* A play list element is selected */
        public delegate void PlayListNodeSelectedHandler(PlayListPlay play);
-       /* Save current playrate for a play list element */
-       public delegate void ApplyCurrentRateHandler(PlayListPlay play);
        /* Open a playlist */
        public delegate void OpenPlaylistHandler();
        /* New a playlist */
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 2f2c0d7..f8f24f1 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -33,6 +33,7 @@ namespace LongoMatch.Handlers
        public delegate void FramesProgressHandler(int actual, int total, Image frame);
        public delegate void DrawFrameHandler(int time);
        public delegate void EllpasedTimeHandler(int ellapsedTime);
+       public delegate void PlaybackRateChangedHandler (float rate);
 
 
        public delegate void ErrorHandler(object o, string message);
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
index 3094793..1ac01cb 100644
--- a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -63,7 +63,6 @@ namespace LongoMatch.Interfaces.GUI
                event ManageCategoriesHandler ManageCategoriesEvent;
                event ManageProjects ManageProjectsEvent;
                event ManageDatabases ManageDatabasesEvent;
-               event ApplyCurrentRateHandler ApplyRateEvent;
                event EditPreferences EditPreferencesEvent;
                
                /* Game Units events */
diff --git a/LongoMatch.Core/Interfaces/GUI/IPlayer.cs b/LongoMatch.Core/Interfaces/GUI/IPlayer.cs
index 1b461f7..3842cd4 100644
--- a/LongoMatch.Core/Interfaces/GUI/IPlayer.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IPlayer.cs
@@ -32,6 +32,7 @@ namespace LongoMatch.Interfaces.GUI
                event DrawFrameHandler DrawFrame;
                event SeekEventHandler SeekEvent;
                event DetachPlayerHandler Detach;
+               event PlaybackRateChangedHandler PlaybackRateChanged;
                
                long AccurateCurrentTime {get;}
                int CurrentTime {get;}
@@ -68,7 +69,7 @@ namespace LongoMatch.Interfaces.GUI
                void FramerateDown();
                void UpdateSegmentStartTime(long start);
                void UpdateSegmentStopTime(long stop);
-               void SetStartStop(long start, long stop);
+               void SetStartStop(long start, long stop, float rate=1);
                void CloseActualSegment();
                void SetSensitive();
                void UnSensitive();
diff --git a/LongoMatch.Core/Store/Play.cs b/LongoMatch.Core/Store/Play.cs
index 2924e74..fb36eb8 100644
--- a/LongoMatch.Core/Store/Play.cs
+++ b/LongoMatch.Core/Store/Play.cs
@@ -43,6 +43,7 @@ namespace LongoMatch.Store
                        Players = new PlayersTagStore(); 
                        Teams = new TeamsTagStore();
                        Fps = 25;
+                       PlaybackRate = 1.0;
                }
                #endregion
 
@@ -207,6 +208,11 @@ namespace LongoMatch.Store
                        set;
                }
                
+               public double PlaybackRate {
+                       get;
+                       set;
+               }
+               
                #endregion
 
                #region Public methods
diff --git a/LongoMatch.Core/Store/PlayListPlay.cs b/LongoMatch.Core/Store/PlayListPlay.cs
index fbfd17a..eca7f57 100644
--- a/LongoMatch.Core/Store/PlayListPlay.cs
+++ b/LongoMatch.Core/Store/PlayListPlay.cs
@@ -36,15 +36,15 @@ namespace LongoMatch.Store
                        Valid = true;
                }
                
-               public PlayListPlay(Play play, MediaFile mediaFile, float rate, bool valid)
+               public PlayListPlay(Play play, MediaFile mediaFile, bool valid)
                {
                        Name = play.Name;
                        Start = play.Start;
                        Stop = play.Stop;
                        Miniature = play.Miniature;
                        Drawings = play.Drawings;
+                       Rate = play.Rate;
                        MediaFile = mediaFile;
-                       Rate = rate;
                        Valid = valid;
                }
                #endregion
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs 
b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index 15e65f5..bebc3da 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -94,7 +94,6 @@ namespace LongoMatch.Store.Templates
        
                public void AddDefaultSubcategories (Category cat) {
                        PlayerSubCategory localplayers, visitorplayers;
-                       TagSubCategory period;
                        
                        localplayers = new PlayerSubCategory {
                                Name = Catalog.GetString("Local Team Players"),
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index a6cf747..b8b1665 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -49,8 +49,10 @@ namespace LongoMatch.Gui
                public event LongoMatch.Handlers.DrawFrameHandler DrawFrame;
                public event SeekEventHandler SeekEvent;
                public event DetachPlayerHandler Detach;
+               public event PlaybackRateChangedHandler PlaybackRateChanged;
 
                private const int THUMBNAIL_MAX_WIDTH = 100;
+               const int SCALE_FPS = 25;
                private LongoMatch.Video.Common.TickHandler tickHandler;
                private LongoMatch.Multimedia.Interfaces.IPlayer player;
                private long length=0;
@@ -63,6 +65,7 @@ namespace LongoMatch.Gui
                private float rate=1;
                private double previousVLevel = 1;
                private bool muted=false;
+               bool emitRateScale = true;
                private object[] pendingSeek=null; //{start,stop,rate}
                //the player.mrl is diferent from the filename as it's an uri eg:file:///foo.avi
                private string filename = null;
@@ -126,7 +129,7 @@ namespace LongoMatch.Gui
                                return rate;
                        }
                        set {
-                               vscale1.Value = (int)(value*25);
+                               SetScaleValue ((int)(value*SCALE_FPS));
                        }
                }
                
@@ -348,16 +351,16 @@ namespace LongoMatch.Gui
                                SeekEvent(stop);
                }
 
-               public void SetStartStop(long start, long stop) {
+               public void SetStartStop(long start, long stop, float rate = 1) {
                        segmentStartTime = start;
                        segmentStopTime = stop;
                        closebutton.Show();
-                       vscale1.Value = 25;
+                       SetScaleValue ((int) (rate * SCALE_FPS));
                        if (readyToSeek) {
-                               player.SegmentSeek(start, stop, GetRateFromScale());
+                               player.SegmentSeek(start, stop, rate);
                                player.Play();
                        } else {
-                               pendingSeek = new object[3] {start, stop, GetRateFromScale()};
+                               pendingSeek = new object[3] {start, stop, rate};
                        }
                }
 
@@ -365,7 +368,7 @@ namespace LongoMatch.Gui
                        closebutton.Hide();
                        segmentStartTime = 0;
                        segmentStopTime = 0;
-                       vscale1.Value=25;
+                       SetScaleValue (SCALE_FPS);
                        //timescale.Sensitive = true;
                        slength = TimeString.MSecondsToSecondsString(length);
                        SegmentClosedEvent();
@@ -386,15 +389,21 @@ namespace LongoMatch.Gui
 
                #region Private methods
 
+               void SetScaleValue (int value) {
+                       emitRateScale = false;
+                       vscale1.Value = value;
+                       emitRateScale = true;
+               }
+               
                private float GetRateFromScale() {
                        VScale scale= vscale1;
                        double val = scale.Value;
 
-                       if(val >25) {
-                               val = val-25 ;
+                       if(val >SCALE_FPS) {
+                               val = val - SCALE_FPS ;
                        }
-                       else if(val <=25) {
-                               val = val/25;
+                       else if(val <= SCALE_FPS) {
+                               val = val / SCALE_FPS;
                        }
                        return (float)val;
                }
@@ -604,15 +613,15 @@ namespace LongoMatch.Gui
                protected virtual void OnVscale1FormatValue(object o, Gtk.FormatValueArgs args)
                {
                        double val = args.Value;
-                       if(val >25) {
-                               val = val-25 ;
+                       if(val > SCALE_FPS) {
+                               val = val - SCALE_FPS ;
                                args.RetVal = val +"X";
                        }
-                       else if(val ==25) {
+                       else if(val == SCALE_FPS) {
                                args.RetVal = "1X";
                        }
-                       else if(val <25) {
-                               args.RetVal = "-"+val+"/25"+"X";
+                       else if(val < SCALE_FPS) {
+                               args.RetVal = "-"+val+"/"+SCALE_FPS+"X";
                        }
                }
 
@@ -636,6 +645,9 @@ namespace LongoMatch.Gui
                        else
                                player.SetRate(val);
                        rate = val;
+                       if (PlaybackRateChanged != null && emitRateScale) {
+                               PlaybackRateChanged (rate);
+                       }
                }
 
                protected virtual void OnVideoboxButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs 
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index 95ff009..3be2392 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -42,6 +42,7 @@ namespace LongoMatch.Gui
                public event DrawFrameHandler DrawFrame;
                public event SeekEventHandler SeekEvent;
                public event DetachPlayerHandler Detach;
+               public event PlaybackRateChangedHandler PlaybackRateChanged;
                
                public enum PlayerOperationMode {
                        Player,
@@ -315,13 +316,13 @@ namespace LongoMatch.Gui
                        playerbin.UpdateSegmentStopTime (stop);
                }
                
-               public void SetStartStop (long start, long stop) {
+               public void SetStartStop (long start, long stop, float rate=1) {
                        if (mode == PlayerOperationMode.PreviewCapturer) {
                                backtolivebutton.Visible = true;
                                LoadBackgroundPlayer();
                                ShowPlayer ();
                        }
-                       playerbin.SetStartStop (start, stop);
+                       playerbin.SetStartStop (start, stop, rate);
                }
                
                public void CloseActualSegment () {
@@ -400,6 +401,11 @@ namespace LongoMatch.Gui
                                if (Detach != null)
                                        Detach (detach);
                        };
+                       
+                       playerbin.PlaybackRateChanged += (rate) => {
+                               if (PlaybackRateChanged != null)
+                                       PlaybackRateChanged (rate);
+                       };
                }
                
                void LoadBackgroundPlayer () {
diff --git a/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml b/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
index b8a34e8..4e9df92 100644
--- a/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
+++ b/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
@@ -27,6 +27,7 @@
         <signal name="DrawFrame" />
         <signal name="SeekEvent" />
         <signal name="Detach" />
+        <signal name="PlaybackRateChanged" />
       </itemgroup>
     </signals>
   </object>
@@ -50,6 +51,7 @@
         <signal name="DrawFrame" />
         <signal name="SeekEvent" />
         <signal name="Detach" />
+        <signal name="PlaybackRateChanged" />
       </itemgroup>
     </signals>
   </object>
diff --git a/LongoMatch.GUI/Gui/Component/PlayListWidget.cs b/LongoMatch.GUI/Gui/Component/PlayListWidget.cs
index d800894..b8dc78a 100644
--- a/LongoMatch.GUI/Gui/Component/PlayListWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlayListWidget.cs
@@ -35,7 +35,6 @@ namespace LongoMatch.Gui.Component
        public partial class PlayListWidget : Gtk.Bin, IPlaylistWidget
        {
                public event PlayListNodeSelectedHandler PlayListNodeSelected;
-               public event ApplyCurrentRateHandler ApplyCurrentRate;
                public event OpenPlaylistHandler OpenPlaylistEvent;
                public event NewPlaylistHandler NewPlaylistEvent;
                public event SavePlaylistHandler SavePlaylistEvent;
@@ -48,7 +47,6 @@ namespace LongoMatch.Gui.Component
                        this.Build();
                        playlisttreeview1.Reorderable = true;
                        playlisttreeview1.RowActivated += OnPlaylisttreeview1RowActivated;
-                       playlisttreeview1.ApplyCurrentRate += OnApplyRate;
                        savebutton.Sensitive = false;
                        newvideobutton.Sensitive = false;
 
@@ -104,11 +102,6 @@ namespace LongoMatch.Gui.Component
                        }
                }
                
-               protected virtual void OnApplyRate(PlayListPlay plNode) {
-                       if(ApplyCurrentRate != null)
-                               ApplyCurrentRate(plNode);
-               }
-               
                protected virtual void OnSavebuttonClicked(object sender, System.EventArgs e)
                {
                        if (SavePlaylistEvent != null)
diff --git a/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs 
b/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
index 3c6769f..ddc7223 100644
--- a/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlayersListTreeWidget.cs
@@ -139,10 +139,11 @@ namespace LongoMatch.Gui.Component
 
                        foreach(var path in paths) {
                                TreeIter iter;
+                               Play play;
                                
                                playerstreeview.Model.GetIter(out iter, path);
-                               playlist.Add(new PlayListPlay((Play)playerstreeview.Model.GetValue(iter, 0),
-                                                             Project.Description.File, 1, true));
+                               play = (Play)playerstreeview.Model.GetValue(iter, 0);
+                               playlist.Add(new PlayListPlay(play, Project.Description.File, true));
                        }
                        
                        if (RenderPlaylistEvent != null)
diff --git a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs 
b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
index 2b561c5..d94be7d 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
@@ -235,10 +235,11 @@ namespace LongoMatch.Gui.Component
 
                        foreach(var path in paths) {
                                TreeIter iter;
+                               Play play;
                                
                                treeview.Model.GetIter(out iter, path);
-                               playlist.Add(new PlayListPlay((Play)treeview.Model.GetValue(iter, 0),
-                                                             project.Description.File, 1, true));
+                               play = (Play)treeview.Model.GetValue(iter, 0);
+                               playlist.Add (new PlayListPlay(play, project.Description.File, true));
                        }
                        
                        if (RenderPlaylist != null)
diff --git a/LongoMatch.GUI/Gui/Component/TimeScale.cs b/LongoMatch.GUI/Gui/Component/TimeScale.cs
index ddf1094..b321099 100644
--- a/LongoMatch.GUI/Gui/Component/TimeScale.cs
+++ b/LongoMatch.GUI/Gui/Component/TimeScale.cs
@@ -129,7 +129,7 @@ namespace LongoMatch.Gui.Component
                        if (RenderPlaylist != null) {
                                PlayList pl = new PlayList();
                                pl.Add (new PlayListPlay (menuToNodeDict[sender as MenuItem],
-                                                         mediaFile, 1.0f, true));
+                                                         mediaFile, true));
                                RenderPlaylist (pl);
                        }
                        
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index dc47c3f..3816be9 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -84,7 +84,6 @@ namespace LongoMatch.Gui
                public event ManageCategoriesHandler ManageCategoriesEvent;
                public event ManageProjects ManageProjectsEvent;
                public event ManageDatabases ManageDatabasesEvent;
-               public event ApplyCurrentRateHandler ApplyRateEvent;
                public event EditPreferences EditPreferencesEvent;
                
                /* Game Units events */
@@ -274,7 +273,6 @@ namespace LongoMatch.Gui
 
                        /* Connect playlist events */
                        playlist.PlayListNodeSelected += EmitPlayListNodeSelected;
-                       playlist.ApplyCurrentRate += EmitApplyRate;
                        playlist.NewPlaylistEvent += EmitNewPlaylist;
                        playlist.OpenPlaylistEvent += EmitOpenPlaylist;
                        playlist.SavePlaylistEvent += EmitSavePlaylist;
@@ -825,11 +823,6 @@ namespace LongoMatch.Gui
                                RenderPlaylistEvent(playlist);
                }
                
-               private void EmitApplyRate(PlayListPlay plNode) {
-                       if (ApplyRateEvent != null)
-                               ApplyRateEvent (plNode);
-               }
-
                private void EmitTagPlay(Play play) {
                        if (TagPlayEvent != null)
                                TagPlayEvent (play);
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
index 53a23c8..13fc975 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayListTreeView.cs
@@ -36,7 +36,6 @@ namespace LongoMatch.Gui.Component
        public class PlayListTreeView : Gtk.TreeView
        {
                Menu menu;
-               MenuItem setRate;
                ListStore ls;
                IPlayList playlist;
                PlayListPlay loadedPlay = null; //The play currently loaded in the player
@@ -44,8 +43,6 @@ namespace LongoMatch.Gui.Component
                int preDragPos = 0;
                TreeIter selectedIter;
 
-               public event ApplyCurrentRateHandler ApplyCurrentRate;
-
 
                public PlayListTreeView() {
 
@@ -61,11 +58,7 @@ namespace LongoMatch.Gui.Component
                        MenuItem delete = new MenuItem(Catalog.GetString("Delete"));
                        delete.Activated += new EventHandler(OnDelete);
                        delete.Show();
-                       setRate = new MenuItem(Catalog.GetString("Apply current play rate"));
-                       setRate.Activated += new EventHandler(OnApplyRate);
-                       setRate.Show();
                        menu.Append(title);
-                       menu.Append(setRate);
                        menu.Append(delete);
 
 
@@ -104,7 +97,6 @@ namespace LongoMatch.Gui.Component
                                        ListStore list = ((ListStore)Model);
                                        Model.GetIter(out selectedIter,path);
                                        selectedPlay = (PlayListPlay)(list.GetValue(selectedIter,0));
-                                       setRate.Sensitive = selectedPlay == loadedPlay;
                                        menu.Popup();
                                }
                        }
@@ -128,11 +120,6 @@ namespace LongoMatch.Gui.Component
                        list.Remove(ref selectedIter);
                }
 
-               protected void OnApplyRate(object obj, EventArgs args) {
-                       if(ApplyCurrentRate != null)
-                               ApplyCurrentRate(selectedPlay);
-               }
-
                private void RenderName(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel 
model, Gtk.TreeIter iter)
                {
                        PlayListPlay tNode = (PlayListPlay) model.GetValue(iter, 0);
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index 4e054ad..086cbf4 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -11,9 +11,6 @@
   <object type="LongoMatch.Gui.Component.PlayListTreeView" palette-category="LongoMatch" 
allow-children="false" base-type="Gtk.TreeView">
     <itemgroups />
     <signals>
-      <itemgroup label="PlayListTreeView Signals">
-        <signal name="ApplyCurrentRate" />
-      </itemgroup>
     </signals>
   </object>
   <object type="LongoMatch.Gui.Component.CategoriesTreeView" palette-category="LongoMatch" 
allow-children="false" base-type="Gtk.TreeView">
@@ -76,7 +73,6 @@
     <signals>
       <itemgroup label="PlayListWidget Signals">
         <signal name="PlayListNodeSelected" />
-        <signal name="ApplyCurrentRate" />
         <signal name="OpenPlaylistEvent" />
         <signal name="NewPlaylistEvent" />
         <signal name="SavePlaylistEvent" />
@@ -349,6 +345,7 @@
         <signal name="DrawFrame" />
         <signal name="SeekEvent" />
         <signal name="Detach" />
+        <signal name="PlaybackRateChanged" />
       </itemgroup>
     </signals>
   </object>
@@ -372,6 +369,7 @@
         <signal name="DrawFrame" />
         <signal name="SeekEvent" />
         <signal name="Detach" />
+        <signal name="PlaybackRateChanged" />
       </itemgroup>
     </signals>
   </object>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 353a153..ea14e32 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -101,6 +101,7 @@ namespace LongoMatch.Services
                        player.Prev += OnPrev;
                        player.SegmentClosedEvent += OnSegmentClosedEvent;
                        player.DrawFrame += OnDrawFrame;
+                       player.PlaybackRateChanged += HandlePlaybackRateChanged;
                }
 
                void RenderPlay (Project project, Play play, MediaFile file) {
@@ -122,7 +123,7 @@ namespace LongoMatch.Services
                                Directory.CreateDirectory (Path.GetDirectoryName (outputFile));
                                settings = EncodingSettings.DefaultRenderingSettings (outputFile);
                                playlist = new PlayList();
-                               playlist.Add (new PlayListPlay (play, file, 1, true));
+                               playlist.Add (new PlayListPlay (play, file, true));
                        
                                job = new EditionJob (playlist, settings, Config.EnableAudio, 
Config.OverlayTitle); 
                                renderer.AddJob (job);
@@ -252,11 +253,18 @@ namespace LongoMatch.Services
                                           showAllTags);
                }
 
+               void HandlePlaybackRateChanged (float rate)
+               {
+                       if (selectedTimeNode != null) {
+                               selectedTimeNode.Rate = rate;
+                       }
+               }
+
                protected virtual void OnPlaySelected(Play play)
                {
                        Log.Debug("Play selected: " + play);
                        selectedTimeNode = play;
-                       player.SetStartStop(play.Start.MSeconds,play.Stop.MSeconds);
+                       player.SetStartStop(play.Start.MSeconds,play.Stop.MSeconds, play.Rate);
                        drawingManager.Play=play;
                        mainWindow.UpdateSelectedPlay(play);
                }
diff --git a/LongoMatch.Services/Services/PlaylistManager.cs b/LongoMatch.Services/Services/PlaylistManager.cs
index 515fa3e..d7760d0 100644
--- a/LongoMatch.Services/Services/PlaylistManager.cs
+++ b/LongoMatch.Services/Services/PlaylistManager.cs
@@ -83,7 +83,6 @@ namespace LongoMatch.Services
                        /* Handle Add/Select/Rate events from other widgets */
                        mainWindow.PlayListNodeAddedEvent += OnPlayListNodeAdded;
                        mainWindow.PlayListNodeSelectedEvent += LoadPlaylistPlay;
-                       mainWindow.ApplyRateEvent += (p) => {p.Rate = player.Rate;};
                        mainWindow.RenderPlaylistEvent += OnRenderPlaylistEvent;
                        
                        /* Handle Next/Prev from the player */
@@ -180,14 +179,7 @@ namespace LongoMatch.Services
                
                protected virtual void OnPlayListNodeAdded(Play play)
                {
-                       Add(new PlayListPlay {
-                               MediaFile = OpenedProject.Description.File,
-                               Drawings = play.Drawings,
-                               Start = play.Start,
-                               Stop = play.Stop,
-                               Name = play.Name,
-                               Rate = 1.0f,
-                       });
+                       Add(new PlayListPlay (play, OpenedProject.Description.File, true));
                }
                
                protected virtual void OnSavePlaylist()


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