Permalink
Browse files

Shut down the proxy on a thread in case the HTTP connection has hung

  • Loading branch information...
1 parent c1749ae commit aafecfc203fc1cab7c3c40699a6b88897916ba41 Sam Steele committed May 17, 2012
Showing with 17 additions and 3 deletions.
  1. +17 −3 app/src/fm/last/android/player/RadioPlayerService.java
@@ -342,7 +342,7 @@ public void onDestroy() {
}
if(proxy != null && proxy.isRunning()) {
- proxy.stop();
+ new StopProxyTask(proxy).execute();
proxy = null;
}
clearNotification();
@@ -695,7 +695,7 @@ private void playTrack(RadioTrack track, MediaPlayer p) {
RadioWidgetProvider.updateAppWidget_playing(this, track.getTitle(), track.getCreator(), 0, 0, true, track.getLoved(), false);
}
if(proxy != null) {
- proxy.stop();
+ new StopProxyTask(proxy).execute();
proxy = null;
}
@@ -815,7 +815,7 @@ private void stop() {
mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
if(proxy != null && proxy.isRunning()) {
- proxy.stop();
+ new StopProxyTask(proxy).execute();
proxy = null;
}
@@ -1373,6 +1373,20 @@ public Void doInBackground(Void... input) {
}
}
+ private class StopProxyTask extends AsyncTaskEx<Void, Void, Void> {
+ StreamProxy p;
+
+ StopProxyTask(StreamProxy p) {
+ this.p = p;
+ }
+
+ @Override
+ public Void doInBackground(Void... input) {
+ p.stop();
+ return null;
+ }
+ }
+
private final IRadioPlayer.Stub mBinder = new IRadioPlayer.Stub() {
public boolean supportsFocus() {
return mFocusHelper.isSupported();

0 comments on commit aafecfc

Please sign in to comment.