Fixed PlaybackService ignoring result of requestAudiFocus before (re-)starting playback, also fixed issue where getting loss_transient twice would prevent playback from resuming where audio_focus_gain is next received
This commit is contained in:
parent
a5776e3080
commit
ddf29c92af
@ -991,7 +991,10 @@ public final class PlaybackService extends Service
|
|||||||
if (mNotificationMode != NEVER)
|
if (mNotificationMode != NEVER)
|
||||||
startForeground(NOTIFICATION_ID, createNotification(mCurrentSong, mState, mNotificationMode));
|
startForeground(NOTIFICATION_ID, createNotification(mCurrentSong, mState, mNotificationMode));
|
||||||
|
|
||||||
mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
|
final int result = mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
|
||||||
|
if (result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
|
||||||
|
unsetFlag(FLAG_PLAYING);
|
||||||
|
}
|
||||||
|
|
||||||
mHandler.removeMessages(MSG_ENTER_SLEEP_STATE);
|
mHandler.removeMessages(MSG_ENTER_SLEEP_STATE);
|
||||||
try {
|
try {
|
||||||
@ -2140,9 +2143,10 @@ public final class PlaybackService extends Service
|
|||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
||||||
synchronized (mStateLock) {
|
synchronized (mStateLock) {
|
||||||
mTransientAudioLoss = (mState & FLAG_PLAYING) != 0;
|
if((mState & FLAG_PLAYING) != 0) {
|
||||||
if(mTransientAudioLoss) {
|
mTransientAudioLoss = true;
|
||||||
if (type == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
|
|
||||||
|
if(type == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
|
||||||
setFlag(FLAG_DUCKING);
|
setFlag(FLAG_DUCKING);
|
||||||
} else {
|
} else {
|
||||||
mForceNotificationVisible = true;
|
mForceNotificationVisible = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user