Bug 1804770 - add a pref to control video wakelock. r=azebrowski

Differential Revision: https://phabricator.services.mozilla.com/D165324
This commit is contained in:
alwu 2022-12-22 19:19:15 +00:00
Родитель 20bc7ced74
Коммит c74a2f66c2
2 изменённых файлов: 17 добавлений и 7 удалений

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

@ -402,15 +402,21 @@ void HTMLVideoElement::UpdateWakeLock() {
}
bool HTMLVideoElement::ShouldCreateVideoWakeLock() const {
// Only request wake lock for video with audio or video from media stream,
// because non-stream video without audio is often used as a background image.
if (!StaticPrefs::media_video_wakelock()) {
return false;
}
// Only request wake lock for video with audio or video from media
// stream, because non-stream video without audio is often used as a
// background image.
//
// Some web conferencing sites route audio outside the video element, and
// would not be detected unless we check for media stream, so do that below.
// Some web conferencing sites route audio outside the video element,
// and would not be detected unless we check for media stream, so do
// that below.
//
// Media streams generally aren't used as background images, though if they
// were we'd get false positives. If this is an issue, we could check for
// media stream AND document has audio playing (but that was tricky to do).
// Media streams generally aren't used as background images, though if
// they were we'd get false positives. If this is an issue, we could
// check for media stream AND document has audio playing (but that was
// tricky to do).
return HasVideo() && (mSrcStream || HasAudio());
}

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

@ -10659,6 +10659,10 @@
#endif
mirror: always
- name: media.video-wakelock
type: RelaxedAtomicBool
value: true
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "midi."