Bug 1653390 - part3 : wrap the detail of updating playback state into Start(). r=bryce

`NotifyMediaControlPlaybackStateChanged()` would be called when `mPaused` changes, but it would only take effect after the listener starts. If the media changes its `mPaused` before we starts listener, then we have to manully update `NotifyMediaControlPlaybackStateChanged()`.

However, I think wrapping this detail into `Start()` itself would be clearer.

Differential Revision: https://phabricator.services.mozilla.com/D84649
This commit is contained in:
alwu 2020-07-23 21:32:58 +00:00
Родитель dd84046a02
Коммит 019c658238
1 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -417,6 +417,12 @@ class HTMLMediaElement::MediaControlKeyListener final
}
NotifyPlaybackStateChanged(MediaPlaybackState::eStarted);
// If owner has started playing before the listener starts, we should update
// the playing state as well. Eg. media starts inaudily and becomes audible
// later.
if (!Owner()->Paused()) {
NotifyMediaStartedPlaying();
}
return true;
}
@ -7876,12 +7882,6 @@ void HTMLMediaElement::StartListeningMediaControlKeyIfNeeded() {
!mMediaControlKeyListener->Start()) {
return;
}
// If `mPaused` was being changed at the time the listener didn't start, then
// this method won't be called. Eg. if the media becomes audible after it has
// been playing for a while. Therefore, we have to manually update playback
// state after starting listener.
NotifyMediaControlPlaybackStateChanged();
}
void HTMLMediaElement::StopListeningMediaControlKeyIfNeeded() {