[banshee/1.5.1-fixes: 18/56] [PlayQueueSource] Fix next playback source (bgo#599834)



commit 7c4b9b329ff75e4fa158d2e9f57cdef0a8f6b752
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Tue Nov 3 11:05:33 2009 +1100

    [PlayQueueSource] Fix next playback source (bgo#599834)
    
    Set the queue as playback source only if there are manually added tracks or
    if we just started and nothing is playing.

 .../Banshee.PlayQueue/PlayQueueSource.cs           |   22 ++++++++++++++++++-
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
index 931529f..75c3747 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
@@ -300,6 +300,7 @@ namespace Banshee.PlayQueue
                 // mark the first added track as current.
                 if (index != -1 && view_order == current_view_order) {
                     SetCurrentTrack (TrackModel[index] as DatabaseTrackInfo);
+                    SetAsPlaybackSourceUnlessPlaying ();
                 }
                 return true;
             }
@@ -309,8 +310,25 @@ namespace Banshee.PlayQueue
         private void SetAsPlaybackSourceUnlessPlaying ()
         {
             if (current_track != null && ServiceManager.PlaybackController.Source != this) {
-                PriorSource = ServiceManager.PlaybackController.Source;
-                ServiceManager.PlaybackController.NextSource = this;
+                bool set_source = !ServiceManager.PlayerEngine.IsPlaying ();
+                if (!set_source) {
+                    long view_order = ServiceManager.DbConnection.Query<long> (@"
+                        SELECT ViewOrder
+                        FROM CorePlaylistEntries
+                        WHERE PlaylistID = ? AND EntryID = ?",
+                        DbId, Convert.ToInt64 (current_track.CacheEntryId));
+                    long nongenerated = ServiceManager.DbConnection.Query<long> (@"
+                        SELECT COUNT(*)
+                        FROM CorePlaylistEntries
+                        WHERE PlaylistID = ? AND ViewOrder >= ? AND Generated = 0",
+                        DbId, view_order);
+                    set_source = nongenerated > 0;
+                }
+
+                if (set_source) {
+                    PriorSource = ServiceManager.PlaybackController.Source;
+                    ServiceManager.PlaybackController.NextSource = this;
+                }
             }
         }
 



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