fix: keep autoplay fallback from saving mute

(cherry picked from commit f373bb9ce7)
This commit is contained in:
thePR0M3TH3AN committed 2026-07-26 12:33:57 -04:00
1 parent 0513c7fcd8
commit d8e5113efd
7 files changed
+96 -10

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
const FALLBACK_MUTE_DATASET_KEY = "bitvidAutoplayFallbackMute";
/**
* Mute playback after an unmuted autoplay rejection without recording the
* browser-policy fallback as a viewer preference.
*/
export function muteForAutoplayFallback(videoElement) {
if (!videoElement || videoElement.muted) {
return false;
}
if (videoElement.dataset) {
videoElement.dataset[FALLBACK_MUTE_DATASET_KEY] = "true";
}
videoElement.muted = true;
return true;
}
/** Consume the marker attached to the next fallback-generated volume change. */
export function consumeAutoplayFallbackMute(videoElement) {
if (videoElement?.dataset?.[FALLBACK_MUTE_DATASET_KEY] !== "true") {
return false;
}
delete videoElement.dataset[FALLBACK_MUTE_DATASET_KEY];
return true;
}