aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorGlenn Guy <glennguy83@gmail.com>2018-10-12 00:03:56 +1100
committerGlenn Guy <glennguy83@gmail.com>2018-10-12 00:03:56 +1100
commit5f04bd8dfea5231fc248855c20edf4baec22f66b (patch)
tree3b852363ede04b92c5dd9b9997fe3041420b64f4 /app/src/main
parent0ac0bc63b0035c8d781be884c84273fd6c363e82 (diff)
downloaddsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.tar.gz
dsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.tar.bz2
dsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.zip
Fix playback pausing when disconnecting bluetooth
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml6
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java8
2 files changed, 8 insertions, 6 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cfc70a55..52756534 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -166,12 +166,6 @@
</intent-filter>
</receiver>
- <receiver android:name="github.daneren2005.dsub.receiver.AudioNoisyReceiver">
- <intent-filter android:priority="999">
- <action android:name="android.media.AUDIO_BECOMING_NOISY" />
- </intent-filter>
- </receiver>
-
<receiver android:name="github.daneren2005.dsub.receiver.A2dpIntentReceiver">
<intent-filter>
<action android:name="android.music.playstatusrequest"/>
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index 6c3cfbd7..f4bc2343 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -42,6 +42,7 @@ import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.domain.RemoteControlState;
import github.daneren2005.dsub.domain.RepeatMode;
import github.daneren2005.dsub.domain.ServerInfo;
+import github.daneren2005.dsub.receiver.AudioNoisyReceiver;
import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver;
import github.daneren2005.dsub.util.ArtistRadioBuffer;
import github.daneren2005.dsub.util.ImageLoader;
@@ -77,6 +78,7 @@ import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
@@ -180,6 +182,9 @@ public class DownloadService extends Service {
private boolean autoPlayStart = false;
private boolean runListenersOnInit = false;
+ private IntentFilter audioNoisyIntent = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
+ private AudioNoisyReceiver audioNoisyReceiver = new AudioNoisyReceiver();
+
private MediaRouteManager mediaRouter;
// Variables to manage getCurrentPosition sometimes starting from an arbitrary non-zero number
@@ -1328,6 +1333,7 @@ public class DownloadService extends Service {
} else if(playerState == PAUSED_TEMP) {
setPlayerState(temp ? PAUSED_TEMP : PAUSED);
}
+ unregisterReceiver(audioNoisyReceiver);
} catch (Exception x) {
handleError(x);
}
@@ -1352,6 +1358,7 @@ public class DownloadService extends Service {
} else if(playerState == PAUSED) {
setPlayerState(STOPPED);
}
+ unregisterReceiver(audioNoisyReceiver);
} catch(Exception x) {
handleError(x);
}
@@ -1371,6 +1378,7 @@ public class DownloadService extends Service {
autoPlayStart = true;
}
}
+ registerReceiver(audioNoisyReceiver, audioNoisyIntent);
setPlayerState(STARTED);
} catch (Exception x) {
handleError(x);