[Banshee-List] [PATCH] Audiosrobbler patch thing



Hi all/Aaron,

Linkied/inline (hopefully my mail client doesn't fsck it up)is a small
patch to resolve the now-playing delay thing (see earlier discussion on the
mailing list), and to fix a small UI bug where the Visit user page menuitem
would remain grayed out even though the user updated their account
information to use valid data.

Patch is also @ http://mediati.org/temp/as-patch.diff

Hopefully we get this in before tomorrow sometime. :)

Cheers,
Alex Hixon

Index:
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
===================================================================
---
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs	(revision
3439)
+++
src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs	(working
copy)
@@ -65,6 +65,8 @@
         private Account account;
         
         private bool queued; /* if current_track has been queued */
+        private bool now_playing_sent = false; /* self explanitory :) */
+        private int iterate_countdown = 4 * 4; /* number of times to wait
for iterate event before sending now playing */
         
         private DateTime song_start_time;
         private TrackInfo last_track;
@@ -97,6 +99,11 @@
                 connection.UpdateNetworkState (args.Connected);
             };
             
+            // Update the Visit action menu item if we update our account
info
+            LastfmCore.Account.Updated += delegate (object o, EventArgs
args) {
+                action_service["AudioscrobblerVisitAction"].Sensitive =
LastfmCore.Account.UserName != null && LastfmCore.Account.CryptedPassword
!= null;
+            };
+            
             ServiceManager.PlayerEngine.EventChanged +=
OnPlayerEngineEventChanged;
             
             action_service = ServiceManager.Get<InterfaceActionService>
("InterfaceActionService");
@@ -232,14 +239,8 @@
                     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);
-                    }
+                    now_playing_sent = false;
+                    iterate_countdown = 4 * 4;  /* we get roughly 4
events/sec */
                     
                     break;
                 
@@ -248,11 +249,27 @@
                     break;
                 
                 case PlayerEngineEvent.Iterate:
+                    // Queue as now playing
+                    if (!now_playing_sent && iterate_countdown == 0) {
+                        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);
+                        }
+                        
+                        now_playing_sent = true;
+                    } else if (iterate_countdown > 0) {
+                        Console.WriteLine ("Skipping...");
+                        iterate_countdown --;
+                    }
+                    
                     st.IncreasePosition ();
                     break;
                 
                 case PlayerEngineEvent.EndOfStream:
                     Queue (ServiceManager.PlayerEngine.CurrentTrack);
+                    iterate_countdown = 4 * 4; 
                     break;
             }
         }



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