From dfa10a5989ad3b99dbd4f32742aa76de448af92c Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Wed, 19 Mar 2014 14:15:59 +0100 Subject: [PATCH] Playback was not completed correctly. Might fix issue #366 and #374 --- .../service/playback/PlaybackService.java | 15 ++++++++++++++- .../playback/PlaybackServiceMediaPlayer.java | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java index 6bc8c4127..bb200c5dd 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java @@ -530,7 +530,7 @@ public class PlaybackService extends Service { stopWidgetUpdater(); } - writePlaybackPreferences(); + writePlaybackPreferencesNoMediaPlaying(); if (nextMedia != null) { stream = !media.localFileAvailable(); mediaPlayer.playMediaObject(nextMedia, stream, startWhenPrepared, prepareImmediately); @@ -555,6 +555,19 @@ public class PlaybackService extends Service { sendNotificationBroadcast(NOTIFICATION_TYPE_SLEEPTIMER_UPDATE, 0); } + private void writePlaybackPreferencesNoMediaPlaying() { + SharedPreferences.Editor editor = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()).edit(); + editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA, + PlaybackPreferences.NO_MEDIA_PLAYING); + editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID, + PlaybackPreferences.NO_MEDIA_PLAYING); + editor.putLong( + PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, + PlaybackPreferences.NO_MEDIA_PLAYING); + editor.commit(); + } + private void writePlaybackPreferences() { if (AppConfig.DEBUG) diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java index 30f6de458..9e4624794 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java @@ -756,6 +756,7 @@ public class PlaybackServiceMediaPlayer { mediaPlayer.reset(); } + audioManager.abandonAudioFocus(audioFocusChangeListener); callback.endPlayback(true); playerLock.unlock();