From 8e05212c750e9bccee0681efc40d75eebd16fb78 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Tue, 11 Feb 2014 18:57:19 +0100 Subject: [PATCH] Bugfixes - Skipping an episode did not work - pauseOnHeadsetDisconnect preference was not updated correctly --- .../preferences/UserPreferences.java | 4 ++- .../service/playback/PlaybackService.java | 2 +- .../playback/PlaybackServiceMediaPlayer.java | 29 ++++++++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java index f00d6245c..69714c6a8 100644 --- a/src/de/danoeh/antennapod/preferences/UserPreferences.java +++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java @@ -319,7 +319,9 @@ public class UserPreferences implements PREF_PLAYBACK_SPEED_ARRAY, null)); } else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) { pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false); - } + } else if (key.equals(PREF_PAUSE_ON_HEADSET_DISCONNECT)) { + pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true); + } } public static void setPlaybackSpeed(String speed) { diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackService.java b/src/de/danoeh/antennapod/service/playback/PlaybackService.java index 68034ceb9..21aca915e 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackService.java @@ -899,7 +899,7 @@ public class PlaybackService extends Service { intent.getAction().equals(ACTION_SKIP_CURRENT_EPISODE)) { if (AppConfig.DEBUG) Log.d(TAG, "Received SKIP_CURRENT_EPISODE intent"); - endPlayback(true); + mediaPlayer.endPlayback(); } } }; diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java index da273cc0e..52cde2718 100644 --- a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java +++ b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java @@ -737,6 +737,26 @@ public class PlaybackServiceMediaPlayer { } }; + public void endPlayback() { + executor.submit(new Runnable() { + @Override + public void run() { + playerLock.lock(); + + if (playerStatus != PlayerStatus.INDETERMINATE) { + setPlayerStatus(PlayerStatus.INDETERMINATE, media); + } + if (mediaPlayer != null) { + mediaPlayer.reset(); + + } + callback.endPlayback(true); + + playerLock.unlock(); + } + }); + } + /** * Holds information about a PSMP object. */ @@ -808,14 +828,7 @@ public class PlaybackServiceMediaPlayer { }; private void genericOnCompletion() { - executor.submit(new Runnable() { - @Override - public void run() { - audioManager.abandonAudioFocus(audioFocusChangeListener); - callback.endPlayback(true); - } - }); - + endPlayback(); } private final com.aocate.media.MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener = new com.aocate.media.MediaPlayer.OnBufferingUpdateListener() {