summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/util/PlaybackController.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/danoeh/antennapod/util/PlaybackController.java')
-rw-r--r--src/de/danoeh/antennapod/util/PlaybackController.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java
index 6ac7de0ca..cb7b0c1bd 100644
--- a/src/de/danoeh/antennapod/util/PlaybackController.java
+++ b/src/de/danoeh/antennapod/util/PlaybackController.java
@@ -116,7 +116,16 @@ public abstract class PlaybackController {
} catch (IllegalArgumentException e) {
// ignore
}
+
+ try {
+ activity.unregisterReceiver(shutdownReceiver);
+ } catch (IllegalArgumentException e) {
+ // ignore
+ }
cancelPositionObserver();
+ schedExecutor.shutdownNow();
+ media = null;
+
}
/** Should be called in the activity's onPause() method. */
@@ -226,6 +235,9 @@ public abstract class PlaybackController {
activity.registerReceiver(notificationReceiver, new IntentFilter(
PlaybackService.ACTION_PLAYER_NOTIFICATION));
+ activity.registerReceiver(shutdownReceiver, new IntentFilter(
+ PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
+
queryService();
if (AppConfig.DEBUG)
Log.d(TAG, "Connection to Service established");
@@ -300,6 +312,20 @@ public abstract class PlaybackController {
};
+ private BroadcastReceiver shutdownReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(
+ PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
+ release();
+ onShutdownNotification();
+ }
+ }
+ };
+
+ public abstract void onShutdownNotification();
+
/** Called when the currently displayed information should be refreshed. */
public abstract void onReloadNotification(int code);