diff options
author | Glenn Guy <glennguy83@gmail.com> | 2018-10-12 00:03:56 +1100 |
---|---|---|
committer | Glenn Guy <glennguy83@gmail.com> | 2018-10-12 00:03:56 +1100 |
commit | 5f04bd8dfea5231fc248855c20edf4baec22f66b (patch) | |
tree | 3b852363ede04b92c5dd9b9997fe3041420b64f4 /app/src/main/java | |
parent | 0ac0bc63b0035c8d781be884c84273fd6c363e82 (diff) | |
download | dsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.tar.gz dsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.tar.bz2 dsub-5f04bd8dfea5231fc248855c20edf4baec22f66b.zip |
Fix playback pausing when disconnecting bluetooth
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 8 |
1 files changed, 8 insertions, 0 deletions
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); |