aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/service/DownloadService.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java8
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);