diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index fbbe40db25e7..6dc50d4feeb6 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -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(); diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 229b9b0f9aeb..cb42ffbf5c5e 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -6888,6 +6888,13 @@ value: 60000 mirror: always +# We would only use media control to control media which duration is longer +# than this value. +- name: media.mediacontrol.eligible.media.duration.s + type: AtomicFloat + value: 3.0f + mirror: always + - name: media.webrtc.platformencoder type: bool #if defined(MOZ_WIDGET_ANDROID)