зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357639 - part3 : change audio focus state before notifying observers. r=sebastian
Notify observer might cause the method (notifyStoppedPlaying) is called by C++ side, and we should change our internal state before calling the method. MozReview-Commit-ID: 5xNXhGmAIrR --HG-- extra : rebase_source : 23fb8bef4066cad5238f49bb692445d9b684a84e
This commit is contained in:
Родитель
fcd83aadc6
Коммит
59a4e31527
|
@ -59,31 +59,32 @@ public class AudioFocusAgent {
|
||||||
switch (focusChange) {
|
switch (focusChange) {
|
||||||
case AudioManager.AUDIOFOCUS_LOSS:
|
case AudioManager.AUDIOFOCUS_LOSS:
|
||||||
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS");
|
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS");
|
||||||
|
mAudioFocusState = State.LOST_FOCUS;
|
||||||
notifyObservers("audioFocusChanged", "lostAudioFocus");
|
notifyObservers("audioFocusChanged", "lostAudioFocus");
|
||||||
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
|
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
|
||||||
mAudioFocusState = State.LOST_FOCUS;
|
|
||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
||||||
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT");
|
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT");
|
||||||
|
mAudioFocusState = State.LOST_FOCUS_TRANSIENT;
|
||||||
notifyObservers("audioFocusChanged", "lostAudioFocusTransiently");
|
notifyObservers("audioFocusChanged", "lostAudioFocusTransiently");
|
||||||
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
|
notifyMediaControlService(MediaControlService.ACTION_PAUSE_BY_AUDIO_FOCUS);
|
||||||
mAudioFocusState = State.LOST_FOCUS_TRANSIENT;
|
|
||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
||||||
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
|
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
|
||||||
notifyMediaControlService(MediaControlService.ACTION_START_AUDIO_DUCK);
|
|
||||||
mAudioFocusState = State.LOST_FOCUS_TRANSIENT_CAN_DUCK;
|
mAudioFocusState = State.LOST_FOCUS_TRANSIENT_CAN_DUCK;
|
||||||
|
notifyMediaControlService(MediaControlService.ACTION_START_AUDIO_DUCK);
|
||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_GAIN:
|
case AudioManager.AUDIOFOCUS_GAIN:
|
||||||
if (mAudioFocusState.equals(State.LOST_FOCUS_TRANSIENT_CAN_DUCK)) {
|
State state = mAudioFocusState;
|
||||||
|
mAudioFocusState = State.OWN_FOCUS;
|
||||||
|
if (state.equals(State.LOST_FOCUS_TRANSIENT_CAN_DUCK)) {
|
||||||
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN (from DUCKING)");
|
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN (from DUCKING)");
|
||||||
notifyMediaControlService(MediaControlService.ACTION_STOP_AUDIO_DUCK);
|
notifyMediaControlService(MediaControlService.ACTION_STOP_AUDIO_DUCK);
|
||||||
} else if (mAudioFocusState.equals(State.LOST_FOCUS_TRANSIENT)) {
|
} else if (state.equals(State.LOST_FOCUS_TRANSIENT)) {
|
||||||
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN");
|
Log.d(LOGTAG, "onAudioFocusChange, AUDIOFOCUS_GAIN");
|
||||||
notifyObservers("audioFocusChanged", "gainAudioFocus");
|
notifyObservers("audioFocusChanged", "gainAudioFocus");
|
||||||
notifyMediaControlService(MediaControlService.ACTION_RESUME_BY_AUDIO_FOCUS);
|
notifyMediaControlService(MediaControlService.ACTION_RESUME_BY_AUDIO_FOCUS);
|
||||||
}
|
}
|
||||||
mAudioFocusState = State.OWN_FOCUS;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче