mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-03 11:22:25 +00:00
fix: keep autoplay fallback from saving mute
(cherry picked from commit f373bb9ce7)
This commit is contained in:
1 parent
0513c7fcd8
commit
d8e5113efd
7 files changed
+96
-10
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user