Update PlaybackHandler.java

This commit is contained in:
Doozy 2022-05-05 15:13:01 +03:00
parent 37aa73879c
commit f86c30c608

View file

@ -36,6 +36,8 @@ class PlaybackHandler extends Handler {
@NonNull private final WeakReference<MusicService> mService; @NonNull private final WeakReference<MusicService> mService;
private float currentDuckVolume = 1.0f; private float currentDuckVolume = 1.0f;
private boolean sFocusEnabled = PreferenceUtil.INSTANCE.isAudioFocusEnabled();
PlaybackHandler(final MusicService service, @NonNull final Looper looper) { PlaybackHandler(final MusicService service, @NonNull final Looper looper) {
super(looper); super(looper);
@ -146,7 +148,10 @@ class PlaybackHandler extends Handler {
case AudioManager.AUDIOFOCUS_LOSS: case AudioManager.AUDIOFOCUS_LOSS:
// Lost focus for an unbounded amount of time: stop playback and release media playback // Lost focus for an unbounded amount of time: stop playback and release media playback
boolean isAudioFocusEnabled = PreferenceUtil.INSTANCE.isAudioFocusEnabled();
if (!isAudioFocusEnabled) {
service.forcePause(); service.forcePause();
}
break; break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: