summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieloeh <daniel.oeh@gmail.com>2013-01-04 01:33:16 -0800
committerdanieloeh <daniel.oeh@gmail.com>2013-01-04 01:33:16 -0800
commit678981afb8cc6ba3ff9a3f763cd5d6acd93c277f (patch)
tree0bceef6f30fb0fb96085ccc04051654d5940580f
parent38cea758bf261f8898864499124e3244683b2208 (diff)
parent1caf1e5e085e425a81fd6109a4d33155275e8289 (diff)
downloadAntennaPod-678981afb8cc6ba3ff9a3f763cd5d6acd93c277f.zip
Merge pull request #73 from toggles/bluetooth_pause
Pause on bluetooth disconnect
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 94025f627..c5a20c31f 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -292,6 +292,8 @@ public class PlaybackService extends Service {
Intent.ACTION_HEADSET_PLUG));
registerReceiver(shutdownReceiver, new IntentFilter(
ACTION_SHUTDOWN_PLAYBACK_SERVICE));
+ registerReceiver(audioBecomingNoisy, new IntentFilter(
+ AudioManager.ACTION_AUDIO_BECOMING_NOISY));
}
@@ -321,6 +323,7 @@ public class PlaybackService extends Service {
disableSleepTimer();
unregisterReceiver(headsetDisconnected);
unregisterReceiver(shutdownReceiver);
+ unregisterReceiver(audioBecomingNoisy);
if (android.os.Build.VERSION.SDK_INT >= 14) {
audioManager.unregisterRemoteControlClient(remoteControlClient);
}
@@ -1111,6 +1114,27 @@ public class PlaybackService extends Service {
}
}
};
+
+ private BroadcastReceiver audioBecomingNoisy = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // sound is about to change, eg. bluetooth -> speaker
+ boolean pauseOnDisconnect = PreferenceManager
+ .getDefaultSharedPreferences(
+ context.getApplicationContext())
+ .getBoolean(
+ PodcastApp.PREF_PAUSE_ON_HEADSET_DISCONNECT,
+ false);
+ if(pauseOnDisconnect&&status==PlayerStatus.PLAYING) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG,
+ "Pausing playback because audio is becoming noisy");
+ pause(false, true);
+ }
+ }
+ //android.media.AUDIO_BECOMING_NOISY
+ };
private BroadcastReceiver shutdownReceiver = new BroadcastReceiver() {