diff options
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | res/xml/preferences.xml | 9 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/preferences/UserPreferences.java | 10 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 17 | ||||
m--------- | submodules/dslv | 0 |
5 files changed, 33 insertions, 7 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 30590a719..46a91a295 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -309,9 +309,11 @@ <string name="folder_not_empty_dialog_title">Folder is not empty</string> <string name="folder_not_empty_dialog_msg">The folder you have selected is not empty. Media downloads and other files will be placed directly in this folder. Continue anyway?</string> <string name="set_to_default_folder">Choose default folder</string> + <string name="pref_pausePlaybackForFocusLoss_sum">Pause playback instead of lowering volume when another app wants to play sounds</string> + <string name="pref_pausePlaybackForFocusLoss_title">Pause for interruptions</string> <!-- Online feed view --> <string name="subscribe_label">Subscribe</string> <string name="subscribed_label">Subscribed</string> <string name="downloading_label">Downloading...</string> -</resources>
\ No newline at end of file +</resources> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 65507a346..10b571305 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -31,6 +31,13 @@ android:key="prefPlaybackSpeedLauncher" android:summary="@string/pref_playback_speed_sum" android:title="@string/pref_playback_speed_title" /> + + <CheckBoxPreference + android:defaultValue="false" + android:enabled="true" + android:key="prefPauseForFocusLoss" + android:summary="@string/pref_pausePlaybackForFocusLoss_sum" + android:title="@string/pref_pausePlaybackForFocusLoss_title" /> </PreferenceCategory> <PreferenceCategory android:title="@string/network_pref"> <ListPreference @@ -127,4 +134,4 @@ </PreferenceCategory> -</PreferenceScreen>
\ No newline at end of file +</PreferenceScreen> 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: diff --git a/submodules/dslv b/submodules/dslv -Subproject 643cc2a1afd4f849d5a33f014f877f7d7c10b2d +Subproject c56bf97269d5dc90df1c428fd18df0e7619eff0 |