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



Author: gburt
Date: Thu Oct  9 20:13:48 2008
New Revision: 4680
URL: http://svn.gnome.org/viewvc/banshee?rev=4680&view=rev

Log:
2008-10-09  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
	Keep track of the track that was playing (if any) before the play queue
	took over so we can return playback to the song after it (BGO #547213).

	* src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs:
	Add a public PriorTrack property that outside code can use to make the
	QueryLinear code grab the next track after the one set, instead of the one
	after the 'CurrentTrack' (eg the last one played).  Used to return
	playback to the right spot in a source after the queue is finished.



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	Thu Oct  9 20:13:48 2008
@@ -52,6 +52,7 @@
         private IStackProvider<TrackInfo> next_stack;
     
         private TrackInfo current_track;
+        private TrackInfo prior_track;
         private TrackInfo changing_to_track;
         private bool raise_started_after_transition = false;
         private bool transition_track_started = false;
@@ -316,7 +317,11 @@
             if (Source.TrackModel.Count == 0)
                 return null;
 
-            int index = Source.TrackModel.IndexOf (CurrentTrack);
+            int index = Source.TrackModel.IndexOf (PriorTrack);
+
+            // Clear the PriorTrack after using it, it's only meant to be used for a single Query
+            PriorTrack = null;
+
             if (index == -1) {
                 return Source.TrackModel[0];
             } else {
@@ -401,6 +406,11 @@
             get { return current_track; }
             protected set { current_track = value; }
         }
+
+        public TrackInfo PriorTrack {
+            get { return prior_track ?? CurrentTrack; }
+            set { prior_track = value; }
+        }
         
         protected DateTime source_set_at = DateTime.MinValue;
         public ITrackModelSource Source {

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	Thu Oct  9 20:13:48 2008
@@ -52,6 +52,7 @@
 
         private ITrackModelSource prior_playback_source;
         private DatabaseTrackInfo playing_track;
+        private TrackInfo prior_playback_track;
         private PlayQueueActions actions;
         private bool was_playing = false;
         
@@ -188,14 +189,19 @@
         private void OnPlayerEvent (PlayerEventArgs args)
         {
             if (args.Event == PlayerEvent.EndOfStream) {
-                if (RemovePlayingTrack () && !was_playing) {
-                    ServiceManager.PlaybackController.StopWhenFinished = true;
+                if (RemovePlayingTrack ()) {
+                    if (was_playing) {
+                        ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
+                    } else {
+                        ServiceManager.PlaybackController.StopWhenFinished = true;
+                    }
                 }
             } else if (args.Event == PlayerEvent.StartOfStream) {
                 if (this == ServiceManager.PlaybackController.Source) {
-                    playing_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo; 
+                    playing_track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
                 } else {
                     playing_track = null;
+                    prior_playback_track = ServiceManager.PlayerEngine.CurrentTrack;
                 }
             }
         }
@@ -212,6 +218,7 @@
             if (Count == 0) {
                 ServiceManager.PlaybackController.Source = PriorSource;
                 if (was_playing) {
+                    ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
                     ServiceManager.PlaybackController.Next (restart);
                 } else {
                     ServiceManager.PlayerEngine.Close ();



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