1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-10 08:18:30 +01:00

adding in perdedora's PR to the master branch

This commit is contained in:
Lorenzo Yario 2025-02-02 22:24:06 -06:00 committed by GitHub
parent f3cb2552ce
commit 92096b43b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,6 +89,12 @@ function setupVideo(thumb, url) {
} }
} }
function setVolume() {
const volume = setting("videovolume");
video.volume = volume;
video.muted = (volume === 0);
}
// Clicking on thumbnail expands video // Clicking on thumbnail expands video
thumb.addEventListener("click", function(e) { thumb.addEventListener("click", function(e) {
if (setting("videoexpand") && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { if (setting("videoexpand") && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
@ -105,15 +111,21 @@ function setupVideo(thumb, url) {
video.parentNode.parentNode.removeAttribute('style'); video.parentNode.parentNode.removeAttribute('style');
thumb.style.display = "none"; thumb.style.display = "none";
video.muted = (setting("videovolume") == 0); setVolume();
video.volume = setting("videovolume");
video.controls = true; video.controls = true;
if (video.readyState == 0) { if (video.readyState == 0) {
video.addEventListener("loadedmetadata", expand2, false); video.addEventListener("loadedmetadata", expand2, false);
} else { } else {
setTimeout(expand2, 0); setTimeout(expand2, 0);
} }
video.play(); let promise = video.play();
if (promise !== undefined) {
promise.then(_ => {
}).catch(_ => {
video.muted = true;
video.play();
});
}
e.preventDefault(); e.preventDefault();
} }
}, false); }, false);
@ -158,10 +170,16 @@ function setupVideo(thumb, url) {
videoContainer.style.display = "inline"; videoContainer.style.display = "inline";
videoContainer.style.position = "fixed"; videoContainer.style.position = "fixed";
video.muted = (setting("videovolume") == 0); setVolume();
video.volume = setting("videovolume");
video.controls = false; video.controls = false;
video.play(); let promise = video.play();
if (promise !== undefined) {
promise.then(_ => {
}).catch(_ => {
video.muted = true;
video.play();
});
}
} }
}, false); }, false);