diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-10-03 13:15:47 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-10-03 13:15:47 +0200 |
commit | 088878fcfd69dd07d26cf612ac72125efd252a7b (patch) | |
tree | 3f83e9a9c79191c750be63dfa78624942fd86e7a /src | |
parent | 83bb0a608440c21ce61af68df0a8be0c387f1c0c (diff) | |
parent | c960a65189014fddbf7336c028385b350fdca504 (diff) | |
download | AntennaPod-088878fcfd69dd07d26cf612ac72125efd252a7b.zip |
Merge branch 'pause-on-interrupt' of git://github.com/TomHennen/AntennaPod into TomHennen-pause-on-interrupt
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/preferences/UserPreferences.java | 10 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 17 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java index d15f5ba53..8b57979af 100644 --- a/src/de/danoeh/antennapod/preferences/UserPreferences.java +++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java @@ -48,6 +48,7 @@ public class UserPreferences implements public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize"; private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed"; private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray"; + public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss"; private static int EPISODE_CACHE_SIZE_UNLIMITED = -1; @@ -69,6 +70,7 @@ public class UserPreferences implements private int episodeCacheSize; private String playbackSpeed; private String[] playbackSpeedArray; + private boolean pauseForFocusLoss; private UserPreferences(Context context) { this.context = context; @@ -121,6 +123,7 @@ public class UserPreferences implements playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0"); playbackSpeedArray = readPlaybackSpeedArray(sp.getString( PREF_PLAYBACK_SPEED_ARRAY, null)); + pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false); } private int readThemeValue(String valueFromPrefs) { @@ -264,6 +267,11 @@ public class UserPreferences implements instanceAvailable(); return instance.enableAutodownload; } + + public static boolean shouldPauseForFocusLoss() { + instanceAvailable(); + return instance.pauseForFocusLoss; + } @Override public void onSharedPreferenceChanged(SharedPreferences sp, String key) { @@ -309,6 +317,8 @@ public class UserPreferences implements } else if (key.equals(PREF_PLAYBACK_SPEED_ARRAY)) { playbackSpeedArray = readPlaybackSpeedArray(sp.getString( 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); } } diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 025bf7dc4..0bb8753c1 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -381,11 +381,18 @@ public class PlaybackService extends Service { break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: if (status == PlayerStatus.PLAYING) { - if (AppConfig.DEBUG) - Log.d(TAG, "Lost audio focus temporarily. Ducking..."); - audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_LOWER, 0); - pausedBecauseOfTransientAudiofocusLoss = true; + if (!UserPreferences.shouldPauseForFocusLoss()) { + if (AppConfig.DEBUG) + Log.d(TAG, "Lost audio focus temporarily. Ducking..."); + audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_LOWER, 0); + pausedBecauseOfTransientAudiofocusLoss = true; + } else { + if (AppConfig.DEBUG) + Log.d(TAG, "Lost audio focus temporarily. Could duck, but won't, pausing..."); + pause(false, false); + pausedBecauseOfTransientAudiofocusLoss = true; + } } break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: |