mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +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
@@ -1,6 +1,10 @@
|
||||
import { userLogger } from "../utils/logger.js";
|
||||
import { PLAYBACK_START_TIMEOUT } from "../constants.js";
|
||||
import { getCurrentVideo, setCurrentVideo } from "../state/appState.js";
|
||||
import {
|
||||
consumeAutoplayFallbackMute,
|
||||
muteForAutoplayFallback,
|
||||
} from "../utils/autoplayPreference.js";
|
||||
import {
|
||||
SimpleEventEmitter,
|
||||
extractWebSeedsFromMagnet,
|
||||
@@ -330,11 +334,17 @@ export class PlaybackService {
|
||||
return;
|
||||
}
|
||||
const storedUnmuted = localStorage.getItem("unmutedAutoplay");
|
||||
const userWantsUnmuted = storedUnmuted === "true";
|
||||
// Sound is the default for an explicit watch action. Browsers may still
|
||||
// reject unmuted autoplay, in which case the coordinator retries muted.
|
||||
// Preserve a viewer's explicit mute choice across subsequent videos.
|
||||
const userWantsUnmuted = storedUnmuted !== "false";
|
||||
videoElement.muted = !userWantsUnmuted;
|
||||
|
||||
if (!videoElement.dataset.autoplayBound) {
|
||||
videoElement.addEventListener("volumechange", () => {
|
||||
if (consumeAutoplayFallbackMute(videoElement)) {
|
||||
return;
|
||||
}
|
||||
localStorage.setItem(
|
||||
"unmutedAutoplay",
|
||||
(!videoElement.muted).toString()
|
||||
@@ -344,6 +354,10 @@ export class PlaybackService {
|
||||
}
|
||||
}
|
||||
|
||||
muteForAutoplayFallback(videoElement) {
|
||||
return muteForAutoplayFallback(videoElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of event listeners ("watchdogs") on the video element to detect
|
||||
* when playback has stalled or failed.
|
||||
|
||||
Reference in new issue
Block a user