Bug 1627999 - part8 : remove audible check in media element. r=bryce

This patch will do :
- remove audible check from the logic of registering controller
- include audio channel affect on the media element's audible state

The advantage of doing so :
- it can help to reduce the intermittent failure during testing by earlier hooking media elements in the content process to the media controller in the chrome process

More details :
In D72497, we have added the audible check to postpone the activation of the media controller, which would ensure that we only control media after it become audible. Therefore, we can remove the previous implementation which we use to achieve that in media element.

When having that audible check in media element, it would postpone the timing of adding media element to `ContentMediaController` that causes some intermitent failures when I was writing test for bug1633565. When removing those checks, we can ensure that the media element would have always been added into `ContentMediaController` after calling `video.play()`. If the element haven't been added into `ContentMediaController`, then it would miss to handle the media key events when test generates a fake media key event, which causes an intermitent failure.

Differential Revision: https://phabricator.services.mozilla.com/D73335
This commit is contained in:
alwu 2020-05-14 03:20:17 +00:00
parent 203a7440ae
commit d6ea0a004a

View File

@ -3336,7 +3336,6 @@ void HTMLMediaElement::SetVolumeInternal() {
NotifyAudioPlaybackChanged(
AudioChannelService::AudibleChangedReasons::eVolumeChanged);
StartListeningMediaControlEventIfNeeded();
}
void HTMLMediaElement::SetMuted(bool aMuted) {
@ -7228,7 +7227,6 @@ void HTMLMediaElement::SetAudibleState(bool aAudible) {
mIsAudioTrackAudible = aAudible;
NotifyAudioPlaybackChanged(
AudioChannelService::AudibleChangedReasons::eDataAudibleChanged);
StartListeningMediaControlEventIfNeeded();
}
}
@ -7317,7 +7315,6 @@ void HTMLMediaElement::SetMediaInfo(const MediaInfo& aInfo) {
mAudioChannelWrapper->AudioCaptureTrackChangeIfNeeded();
}
UpdateWakeLock();
StartListeningMediaControlEventIfNeeded();
}
void HTMLMediaElement::AudioCaptureTrackChange(bool aCapture) {
@ -7758,17 +7755,6 @@ void HTMLMediaElement::StartListeningMediaControlEventIfNeeded() {
return;
}
// This includes cases such like `video is muted`, `video has zero volume`,
// `video's audio track is still inaudible` and `tab is muted by audio channel
// (tab sound indicator)`, all these cases would make media inaudible.
// `ComputedVolume()` would return the final volume applied the affection made
// by audio channel, which is used to detect if the tab is muted by audio
// channel.
if (!IsAudible() || ComputedVolume() == 0.0f) {
MEDIACONTROL_LOG("Not listening because media is inaudible");
return;
}
// 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.