banshee r4188 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.PlaybackController src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue



Author: gburt
Date: Mon Jun 23 19:02:50 2008
New Revision: 4188
URL: http://svn.gnome.org/viewvc/banshee?rev=4188&view=rev

Log:
2008-06-23  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
	Remember the last playback source when switching to the play queue, so
	when the queue is empty we can switch back to it.

	* src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs:
	Have the playback source follow the active source when first started up.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
   trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs	Mon Jun 23 19:02:50 2008
@@ -57,6 +57,7 @@
         private bool transition_track_started = false;
         private int consecutive_errors;
         private uint error_transition_id;
+        private DateTime source_auto_set_at = DateTime.MinValue;
     
         private PlaybackShuffleMode shuffle_mode;
         private PlaybackRepeatMode repeat_mode;
@@ -90,6 +91,14 @@
                 PlayerEvent.StateChange |
                 PlayerEvent.Error, 
                 true);
+
+            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
+                ITrackModelSource active_source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;
+                if (active_source != null && source_auto_set_at == source_set_at && !player_engine.IsPlaying ()) {
+                    Source = active_source;
+                    source_auto_set_at = source_set_at;
+                }
+            };
         }
         
         protected virtual void InstantiateStacks ()
@@ -384,7 +393,7 @@
             protected set { current_track = value; }
         }
         
-        protected DateTime source_set_at;
+        protected DateTime source_set_at = DateTime.MinValue;
         public ITrackModelSource Source {
             get { 
                 if (source == null && ServiceManager.SourceManager.DefaultSource is ITrackModelSource) {

Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	Mon Jun 23 19:02:50 2008
@@ -51,6 +51,7 @@
     {
         private static string special_playlist_name = "Play Queue";//typeof (PlayQueueSource).ToString ();
 
+        private ITrackModelSource prior_playback_source;
         private DatabaseTrackInfo playing_track;
         private bool actions_loaded = false;
 
@@ -115,7 +116,7 @@
             
             TrackModel.Reloaded += delegate {
                 if (this == ServiceManager.PlaybackController.Source && Count == 0) {
-                    ServiceManager.PlaybackController.Source = (ITrackModelSource)ServiceManager.SourceManager.DefaultSource;
+                    ServiceManager.PlaybackController.Source = PriorSource;
                 }
             };
             
@@ -127,6 +128,7 @@
         private void SetAsPlaybackSourceUnlessPlaying ()
         {
             if (Count > 0) {
+                PriorSource = ServiceManager.PlaybackController.Source;
                 ServiceManager.PlaybackController.NextSource = this;
             }
         }
@@ -174,6 +176,7 @@
         private void OnCanonicalPlaybackControllerTransition (object o, EventArgs args)
         {
             if (Count > 0) {
+                PriorSource = ServiceManager.PlaybackController.Source;
                 ServiceManager.PlaybackController.Source = this;
             }
         }
@@ -238,7 +241,7 @@
             RemovePlayingTrack ();
             
             if (Count == 0) {
-                ServiceManager.PlaybackController.Source = (ITrackModelSource)ServiceManager.SourceManager.DefaultSource;
+                ServiceManager.PlaybackController.Source = PriorSource;
                 ServiceManager.PlaybackController.Next (restart);
                 return;
             }
@@ -258,6 +261,21 @@
             }
         }
         
+        private ITrackModelSource PriorSource {
+            get {
+                if (prior_playback_source == null || prior_playback_source == this) {
+                    return (ITrackModelSource)ServiceManager.SourceManager.DefaultSource;
+                }
+                return prior_playback_source;
+            }
+            set {
+                if (value == null || value == this) {
+                    return;
+                }
+                prior_playback_source = value;
+            }
+        }
+        
         public override bool CanRename {
             get { return false; }
         }



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