[banshee] [RandomBy] Skips user-selected artist/album (bgo#608778)
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [RandomBy] Skips user-selected artist/album (bgo#608778)
- Date: Sat, 13 Nov 2010 21:39:18 +0000 (UTC)
commit 1b6ab49974d6c4178f8b056b4730decb8578452b
Author: Gabriel Burt <gabriel burt gmail com>
Date: Sat Nov 13 15:35:17 2010 -0600
[RandomBy] Skips user-selected artist/album (bgo#608778)
If you were in shuffle by artist or album mode, if you manually chose an
album or artist to play, when the track is done Banshee would pick a new
artist or album instead of continuing with the one you chose.
.../Banshee.Collection.Database/RandomBy.cs | 4 ++++
.../Banshee.Collection.Database/RandomByAlbum.cs | 8 ++++++++
.../Banshee.Collection.Database/RandomByArtist.cs | 11 +++++++++++
.../Banshee.Collection.Database/Shuffler.cs | 19 ++++++++++++++++++-
4 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
index 76a323d..a68765d 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomBy.cs
@@ -193,6 +193,10 @@ namespace Banshee.Collection.Database
};
}
+ public virtual void SetLastTrack (TrackInfo track)
+ {
+ }
+
protected virtual IEnumerable<object> GetConditionParameters (DateTime after)
{
yield break;
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
index 7ab9928..56055e9 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByAlbum.cs
@@ -81,6 +81,14 @@ namespace Banshee.Collection.Database
return IsReady;
}
+ public override void SetLastTrack (TrackInfo track)
+ {
+ var dbtrack = track as DatabaseTrackInfo;
+ if (dbtrack != null && dbtrack.AlbumId != album_id) {
+ album_id = dbtrack.AlbumId;
+ }
+ }
+
protected override IEnumerable<object> GetConditionParameters (DateTime after)
{
yield return album_id == null ? (int)0 : (int)album_id;
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
index 63b0f53..154a3e2 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/RandomByArtist.cs
@@ -79,6 +79,17 @@ namespace Banshee.Collection.Database
return IsReady;
}
+ public override void SetLastTrack (TrackInfo track)
+ {
+ var dbtrack = track as DatabaseTrackInfo;
+ if (dbtrack != null) {
+ var new_id = dbtrack.Album.ArtistId;
+ if (new_id != id) {
+ id = new_id;
+ }
+ }
+ }
+
protected override IEnumerable<object> GetConditionParameters (DateTime after)
{
yield return id == null ? (int)0 : (int)id;
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
index efc3246..296d496 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
@@ -49,7 +49,7 @@ namespace Banshee.Collection.Database
public class Shuffler
{
- public static readonly Shuffler Playback = new Shuffler () { Id = "playback", DbId = 0 };
+ public static readonly Shuffler Playback = new Shuffler (true);
private static string shuffles_sql = "INSERT OR REPLACE INTO CoreShuffles (ShufflerID, LastShuffledAt, TrackID) ";
private static string modify_sql = "INSERT OR REPLACE INTO CoreShuffleModifications (ShufflerID, LastModifiedAt, ModificationType, TrackID) ";
@@ -62,6 +62,7 @@ namespace Banshee.Collection.Database
private List<RandomBy> random_modes;
private Dictionary<TypeExtensionNode, RandomBy> node_map = new Dictionary<TypeExtensionNode, RandomBy> ();
private DatabaseTrackListModel model;
+ private TrackInfo last_track;
public string Id { get; private set; }
public int DbId { get; private set; }
@@ -71,6 +72,18 @@ namespace Banshee.Collection.Database
public IList<RandomBy> RandomModes { get { return random_modes; } }
+ private Shuffler (bool playback) : this ()
+ {
+ Id = "playback";
+ DbId = 0;
+ ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, Banshee.MediaEngine.PlayerEvent.StartOfStream);
+ }
+
+ private void OnPlayerEvent (Banshee.MediaEngine.PlayerEventArgs args)
+ {
+ last_track = ServiceManager.PlayerEngine.CurrentTrack;
+ }
+
public Shuffler (string id) : this ()
{
Id = id;
@@ -203,6 +216,10 @@ namespace Banshee.Collection.Database
var random = random_modes.FirstOrDefault (r => r.Id == mode);
if (random != null) {
+ if (last_track != null && !resetSinceTime) {
+ random.SetLastTrack (last_track);
+ }
+
if (!random.IsReady) {
if (!random.Next (random_began_at) && repeat) {
random_began_at = last_random;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]