mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-07 14:03:31 +01:00
Made sure PlaybackService only reacts to transient audio focus loss if
it's in the PLAYING state
This commit is contained in:
parent
71f948cafa
commit
9f25077b94
@ -276,19 +276,23 @@ public class PlaybackService extends Service {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
||||||
|
if (status == PlayerStatus.PLAYING) {
|
||||||
if (AppConfig.DEBUG)
|
if (AppConfig.DEBUG)
|
||||||
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
|
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
|
||||||
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
|
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
|
||||||
AudioManager.ADJUST_LOWER, 0);
|
AudioManager.ADJUST_LOWER, 0);
|
||||||
pausedBecauseOfTransientAudiofocusLoss = true;
|
pausedBecauseOfTransientAudiofocusLoss = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
||||||
|
if (status == PlayerStatus.PLAYING) {
|
||||||
if (AppConfig.DEBUG)
|
if (AppConfig.DEBUG)
|
||||||
Log.d(TAG, "Lost audio focus temporarily. Pausing...");
|
Log.d(TAG, "Lost audio focus temporarily. Pausing...");
|
||||||
pause(false);
|
pause(false);
|
||||||
pausedBecauseOfTransientAudiofocusLoss = true;
|
pausedBecauseOfTransientAudiofocusLoss = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -722,9 +726,11 @@ public class PlaybackService extends Service {
|
|||||||
Bitmap icon = BitmapFactory.decodeResource(null,
|
Bitmap icon = BitmapFactory.decodeResource(null,
|
||||||
R.drawable.ic_stat_antenna);
|
R.drawable.ic_stat_antenna);
|
||||||
notificationBuilder = new NotificationCompat.Builder(this)
|
notificationBuilder = new NotificationCompat.Builder(this)
|
||||||
.setContentTitle(getString(R.string.playbackservice_notification_title))
|
.setContentTitle(
|
||||||
.setContentText(getString(R.string.playbackservice_notification_content)).setOngoing(true)
|
getString(R.string.playbackservice_notification_title))
|
||||||
.setContentIntent(pIntent).setLargeIcon(icon)
|
.setContentText(
|
||||||
|
getString(R.string.playbackservice_notification_content))
|
||||||
|
.setOngoing(true).setContentIntent(pIntent).setLargeIcon(icon)
|
||||||
.setSmallIcon(R.drawable.ic_stat_antenna);
|
.setSmallIcon(R.drawable.ic_stat_antenna);
|
||||||
|
|
||||||
startForeground(NOTIFICATION_ID, notificationBuilder.getNotification());
|
startForeground(NOTIFICATION_ID, notificationBuilder.getNotification());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user