[banshee/gapless-ng: 3/836] [Banshee.PlaybackControllerService] Factor a CalcNextTrack function out of Next() and Previous()
- From: Christopher James Halse Rogers <chrishr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gapless-ng: 3/836] [Banshee.PlaybackControllerService] Factor a CalcNextTrack function out of Next() and Previous()
- Date: Thu, 25 Feb 2010 22:41:42 +0000 (UTC)
commit ce2ebc63c1987fe6b837adf1075a2454c499959a
Author: Christopher James Halse Rogers <raof ubuntu com>
Date: Tue Jul 14 16:09:17 2009 +1000
[Banshee.PlaybackControllerService] Factor a CalcNextTrack function out of Next() and Previous()
.../PlaybackControllerService.cs | 52 +++++++++-----------
1 files changed, 23 insertions(+), 29 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
index 5c52f55..d870b01 100644
--- a/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
+++ b/src/Core/Banshee.Services/Banshee.PlaybackController/PlaybackControllerService.cs
@@ -263,27 +263,14 @@ namespace Banshee.PlaybackController
bool IBasicPlaybackController.Next (bool restart)
{
- TrackInfo tmp_track = CurrentTrack;
+ if (CurrentTrack != null) {
+ previous_stack.Push (CurrentTrack);
+ }
- if (next_stack.Count > 0) {
- CurrentTrack = next_stack.Pop ();
- if (tmp_track != null) {
- previous_stack.Push (tmp_track);
- }
- } else {
- TrackInfo next_track = QueryTrack (Direction.Next, restart);
- if (next_track != null) {
- if (tmp_track != null) {
- previous_stack.Push (tmp_track);
- }
- } else {
- return true;
- }
-
- CurrentTrack = next_track;
+ CurrentTrack = CalcNextTrack (Direction.Next, restart);
+ if (CurrentTrack != null) {
+ QueuePlayTrack ();
}
-
- QueuePlayTrack ();
return true;
}
@@ -293,20 +280,27 @@ namespace Banshee.PlaybackController
next_stack.Push (current_track);
}
- if (previous_stack.Count > 0) {
- CurrentTrack = previous_stack.Pop ();
- } else {
- TrackInfo track = CurrentTrack = QueryTrack (Direction.Previous, restart);
- if (track != null) {
- CurrentTrack = track;
- } else {
- return true;
- }
+ CurrentTrack = CalcNextTrack (Direction.Previous, restart);
+ if (CurrentTrack == null) {
+ QueuePlayTrack ();
}
- QueuePlayTrack ();
return true;
}
+
+ private TrackInfo CalcNextTrack (Direction direction, bool restart)
+ {
+ if (direction == Direction.Previous) {
+ if (previous_stack.Count > 0) {
+ return previous_stack.Pop ();
+ }
+ } else if (direction == Direction.Next) {
+ if (next_stack.Count > 0) {
+ return next_stack.Pop ();
+ }
+ }
+ return QueryTrack (direction, restart);
+ }
private TrackInfo QueryTrack (Direction direction, bool restart)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]