summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/service
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-09-25 13:37:47 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-09-25 13:37:47 +0200
commit88b3a015cd9cd4f793f0aaa984b878bb94303ae4 (patch)
tree4f2360e057c5c7442b9f84b2844b2e6b08f4313d /src/de/danoeh/antennapod/service
parentd39bd6831bea56b2e93f98107d630aa6d9056fdf (diff)
downloadAntennaPod-88b3a015cd9cd4f793f0aaa984b878bb94303ae4.zip
Feeds weren't always deleted properly
Diffstat (limited to 'src/de/danoeh/antennapod/service')
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index d46e6c153..9b5a404f6 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -87,6 +87,12 @@ public class PlaybackService extends Service {
public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.service.notificationCode";
public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.service.notificationType";
+ /**
+ * If the PlaybackService receives this action, it will stop playback and
+ * try to shutdown.
+ */
+ public static final String ACTION_SHUTDOWN_PLAYBACK_SERVICE = "action.de.danoeh.antennapod.service.actionShutdownPlaybackService";
+
/** Used in NOTIFICATION_TYPE_RELOAD. */
public static final int EXTRA_CODE_AUDIO = 1;
public static final int EXTRA_CODE_VIDEO = 2;
@@ -266,6 +272,8 @@ public class PlaybackService extends Service {
}
registerReceiver(headsetDisconnected, new IntentFilter(
Intent.ACTION_HEADSET_PLUG));
+ registerReceiver(shutdownReceiver, new IntentFilter(
+ ACTION_SHUTDOWN_PLAYBACK_SERVICE));
}
@@ -278,6 +286,7 @@ public class PlaybackService extends Service {
isRunning = false;
disableSleepTimer();
unregisterReceiver(headsetDisconnected);
+ unregisterReceiver(shutdownReceiver);
if (android.os.Build.VERSION.SDK_INT >= 14) {
audioManager.unregisterRemoteControlClient(remoteControlClient);
}
@@ -486,7 +495,7 @@ public class PlaybackService extends Service {
player.setDataSource(media.getDownload_url());
setStatus(PlayerStatus.PREPARING);
player.prepareAsync();
- } else if (media.getFile_url() != null){
+ } else if (media.getFile_url() != null) {
player.setDataSource(media.getFile_url());
setStatus(PlayerStatus.PREPARING);
player.prepare();
@@ -556,9 +565,12 @@ public class PlaybackService extends Service {
ChapterUtils
.readID3ChaptersFromFeedMediaDownloadUrl(media
.getItem());
- if (media.getItem().getChapters() != null) {
+ if (media.getItem().getChapters() != null
+ && !interrupted()) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD,
0);
+ manager.setFeedItem(PlaybackService.this,
+ media.getItem());
}
if (AppConfig.DEBUG)
Log.d(TAG, "ChapterLoaderThread has finished");
@@ -731,7 +743,8 @@ public class PlaybackService extends Service {
/** Pauses playback and destroys service. Recommended for video playback. */
public void stop() {
- pause(true);
+ if (AppConfig.DEBUG) Log.d(TAG, "Stopping playback");
+ player.stop();
stopSelf();
}
@@ -985,6 +998,20 @@ public class PlaybackService extends Service {
}
};
+ private BroadcastReceiver shutdownReceiver = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
+ schedExecutor.shutdownNow();
+ stop();
+ media = null;
+ feed = null;
+ }
+ }
+
+ };
+
/** Periodically saves the position of the media file */
class PositionSaver implements Runnable {
public static final int WAITING_INTERVALL = 5000;