[banshee] [gapless] Fix PlayCount calculation (bgo#613418)



commit d9b8d8794d356b759dcae2382654f9c6aeb62cbd
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Fri Mar 26 19:36:34 2010 +1100

    [gapless] Fix PlayCount calculation (bgo#613418)

 .../Banshee.GStreamer/PlayerEngine.cs              |    3 +++
 .../Banshee.MediaEngine/PlayerEngineService.cs     |   17 ++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
index 3d203bd..8d2b979 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
@@ -304,6 +304,9 @@ namespace Banshee.GStreamer
         private void OnNextTrackStarting (IntPtr player)
         {
             if (GaplessEnabled) {
+                // Must do it here because the next track is already playing.
+                ServiceManager.PlayerEngine.IncrementLastPlayed (1.0);
+
                 OnEventChanged (PlayerEvent.EndOfStream);
                 OnEventChanged (PlayerEvent.StartOfStream);
             }
diff --git a/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs b/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
index 7e1c7f1..79ec1f8 100644
--- a/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
+++ b/src/Core/Banshee.Services/Banshee.MediaEngine/PlayerEngineService.cs
@@ -390,16 +390,19 @@ namespace Banshee.MediaEngine
             }
         }
 
-        private bool incremented_last_played = true;
         public void IncrementLastPlayed ()
         {
+            // If Length <= 0 assume 100% completion.
+            IncrementLastPlayed (active_engine.Length <= 0
+                ? 1.0
+                : (double)active_engine.Position / active_engine.Length);
+        }
+
+        private bool incremented_last_played = true;
+        public void IncrementLastPlayed (double completed)
+        {
             if (!incremented_last_played && CurrentTrack != null && CurrentTrack.PlaybackError == StreamPlaybackError.None) {
-                //if Length <= 0 assume 100% completion:
-                if (active_engine.Length <= 0) {
-                    CurrentTrack.OnPlaybackFinished (1);
-                } else {
-                    CurrentTrack.OnPlaybackFinished ((double)active_engine.Position / (double)active_engine.Length);
-                }
+                CurrentTrack.OnPlaybackFinished (completed);
                 incremented_last_played = true;
             }
         }



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