[Slim-Checkins] r12695 - /trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm

andy at svn.slimdevices.com andy at svn.slimdevices.com
Thu Aug 23 08:59:59 PDT 2007


Author: andy
Date: Thu Aug 23 08:59:58 2007
New Revision: 12695

URL: http://svn.slimdevices.com?rev=12695&view=rev
Log:
Increase timeout on Pandora API calls, report station changes

Modified:
    trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm

Modified: trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm?rev=12695&r1=12694&r2=12695&view=diff
==============================================================================
--- trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm (original)
+++ trunk/server/Slim/Plugin/Pandora/ProtocolHandler.pm Thu Aug 23 08:59:58 2007
@@ -88,6 +88,27 @@
 		
 		my ($stationId) = $url =~ m{^pandora://([^.]+)\.mp3};
 		
+		# If the user was playing a different Pandora station, report a stationChange event
+		my $prevTrack = $client->pluginData('prevTrack') || $client->pluginData('currentTrack');
+		if ( $prevTrack && $prevTrack->{stationToken} ne $stationId ) {
+			my $snURL = Slim::Networking::SqueezeNetwork->url(
+				  '/api/pandora/playback/stationChange?stationId=' . $prevTrack->{stationToken} 
+				. '&trackId=' . $prevTrack->{trackToken}
+			);
+
+			my $http = Slim::Networking::SqueezeNetwork->new(
+				sub {},
+				sub {},
+				{
+					client  => $client,
+					timeout => 35,
+				},
+			);
+
+			$log->debug('Reporting station change to SqueezeNetwork');
+			$http->get( $snURL );
+		}
+		
 		getNextTrack( $client, {
 			stationId => $stationId,
 			callback  => $callback,
@@ -113,8 +134,9 @@
 		\&gotNextTrack,
 		\&gotNextTrackError,
 		{
-			client => $client,
-			params => $params,
+			client  => $client,
+			params  => $params,
+			timeout => 35,
 		},
 	);
 	
@@ -282,7 +304,8 @@
 		sub {},
 		sub {},
 		{
-			client => $client,
+			client  => $client,
+			timeout => 35,
 		},
 	);
 	
@@ -413,7 +436,8 @@
 			sub {},
 			sub {},
 			{
-				client => $client,
+				client  => $client,
+				timeout => 35,
 			},
 		);
 



More information about the checkins mailing list