Bug 1617033 - part8 : add an eligible media duration value to filter out notification sound. r=chunmin

Intercepting media control keys would also come up with the virtual control interface in most of platforms, and for the notification sound we don't want either to show the interface or control them.

Currently we use 3s as a threshold to filter those short duration media which are possible to be a notification sound.

Differential Revision: https://phabricator.services.mozilla.com/D64478
This commit is contained in:
alwu
2020-03-06 17:52:15 +00:00
parent 3bed76049e
commit 97a3a47401
2 changed files with 17 additions and 0 deletions

View File

@@ -7699,6 +7699,16 @@ void HTMLMediaElement::StartListeningMediaControlEventIfNeeded() {
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.
if (Duration() <
StaticPrefs::media_mediacontrol_eligible_media_duration_s()) {
MEDIACONTROL_LOG("Not listening because media's duration %f is too short.",
Duration());
return;
}
// As we would like to start listening to media control event again so we
// should clear the timer, which is used to stop listening to the event.
ClearStopMediaControlTimerIfNeeded();