Bug 1654959 - part1 : start listener when media enters fullscreen. r=bryce

When a media enters fullscreen mode, we should consider it as an important one which user might want to control. Therefore, start the listener in order to notify the media has been started, then we would update the fullscreen state [1] which would activate the controller.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/base/Document.cpp#13429

Differential Revision: https://phabricator.services.mozilla.com/D84118
This commit is contained in:
alwu
2020-07-24 02:43:33 +00:00
parent 7d7bfcd48e
commit 9446b79dcc
3 changed files with 25 additions and 0 deletions

View File

@@ -6618,6 +6618,14 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() {
AddRemoveSelfReference();
}
void HTMLMediaElement::NotifyFullScreenChanged() {
if (IsInFullScreen()) {
StartMediaControlKeyListenerIfNeeded();
MOZ_ASSERT(mMediaControlKeyListener->IsStarted(),
"Failed to start the listener when entering fullscreen!");
}
}
void HTMLMediaElement::AddRemoveSelfReference() {
// XXX we could release earlier here in many situations if we examined
// which event listeners are attached. Right now we assume there is a
@@ -7868,7 +7876,16 @@ void HTMLMediaElement::NotifyMediaControlPlaybackStateChanged() {
}
}
bool HTMLMediaElement::IsInFullScreen() const {
return State().HasState(NS_EVENT_STATE_FULLSCREEN);
}
bool HTMLMediaElement::ShouldStartMediaControlKeyListener() const {
if (IsInFullScreen()) {
MEDIACONTROL_LOG("Start listener because of being used in fullscreen");
return true;
}
// In order to filter out notification-ish sound, we use this pref to set the
// eligible media duration to prevent showing media control for those short
// sound.