[Banshee-List] Patch: delay now-playing submission
- From: Wade Menard <wade ezri org>
- To: banshee-list gnome org
- Subject: [Banshee-List] Patch: delay now-playing submission
- Date: Mon, 03 Mar 2008 23:07:59 -0500
Currently Banshee attempts to queue up now-playing submissions right on
PlayerEngineEvent.StartOfStream. If the user changes tracks rapidly it
can cause the connection manager to choke, and last.fm probably doesn't
like the spam, either. This patch delays the submission until ~4 seconds
after the track has started (or has been seeked into).
It's basically just moving the chunk into PlayerEngineEvent.Iterate and
adding a bool.
--
Index:
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
===================================================================
---
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs (revision 3371)
+++
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs (working copy)
@@ -63,6 +63,7 @@
private Account account;
private bool queued; /* if current_track has been queued */
+ private bool nowplaying_queued; /* if current_track has been
queued as NowPlaying */
private DateTime song_start_time;
private TrackInfo last_track;
@@ -228,15 +229,7 @@
song_start_time = DateTime.Now;
last_track =
ServiceManager.PlayerEngine.CurrentTrack;
queued = false;
-
- // Queue as now playing
- if (last_track != null &&
last_track.Duration.TotalSeconds > 30 &&
- (actions["AudioscrobblerEnableAction"] as
ToggleAction).Active) {
-
- connection.NowPlaying (last_track.ArtistName,
last_track.TrackTitle,
- last_track.AlbumTitle,
last_track.Duration.TotalSeconds, last_track.TrackNumber);
- }
-
+ nowplaying_queued = false;
break;
case PlayerEngineEvent.Seek:
@@ -245,6 +238,19 @@
case PlayerEngineEvent.Iterate:
st.IncreasePosition ();
+
+ // Queue as now playing
+ if (last_track != null &&
last_track.Duration.TotalSeconds > 30 &&
+ ServiceManager.PlayerEngine.Position > 4000 &&
+ !nowplaying_queued &&
+ (actions["AudioscrobblerEnableAction"] as
ToggleAction).Active) {
+
+ connection.NowPlaying (last_track.ArtistName,
last_track.TrackTitle,
+ last_track.AlbumTitle,
last_track.Duration.TotalSeconds, last_track.TrackNumber);
+
+ nowplaying_queued = true;
+
+ }
break;
case PlayerEngineEvent.EndOfStream:
Index: src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
===================================================================
--- src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs (revision 3371)
+++ src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs (working copy)
@@ -63,6 +63,7 @@
private Account account;
private bool queued; /* if current_track has been queued */
+ private bool nowplaying_queued; /* if current_track has been queued as NowPlaying */
private DateTime song_start_time;
private TrackInfo last_track;
@@ -228,15 +229,7 @@
song_start_time = DateTime.Now;
last_track = ServiceManager.PlayerEngine.CurrentTrack;
queued = false;
-
- // Queue as now playing
- if (last_track != null && last_track.Duration.TotalSeconds > 30 &&
- (actions["AudioscrobblerEnableAction"] as ToggleAction).Active) {
-
- connection.NowPlaying (last_track.ArtistName, last_track.TrackTitle,
- last_track.AlbumTitle, last_track.Duration.TotalSeconds, last_track.TrackNumber);
- }
-
+ nowplaying_queued = false;
break;
case PlayerEngineEvent.Seek:
@@ -245,6 +238,19 @@
case PlayerEngineEvent.Iterate:
st.IncreasePosition ();
+
+ // Queue as now playing
+ if (last_track != null && last_track.Duration.TotalSeconds > 30 &&
+ ServiceManager.PlayerEngine.Position > 4000 &&
+ !nowplaying_queued &&
+ (actions["AudioscrobblerEnableAction"] as ToggleAction).Active) {
+
+ connection.NowPlaying (last_track.ArtistName, last_track.TrackTitle,
+ last_track.AlbumTitle, last_track.Duration.TotalSeconds, last_track.TrackNumber);
+
+ nowplaying_queued = true;
+
+ }
break;
case PlayerEngineEvent.EndOfStream:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]