Preserve video settings across page loads
This commit is contained in:
parent
40a4b0006b
commit
9a6bca5b5b
@ -212,6 +212,21 @@
|
|||||||
sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop);
|
sessionStorage.setItem('sidebar-scroll', sidebar.scrollTop);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Preserve video volume and mute status between page loads
|
||||||
|
(function() {
|
||||||
|
var video = document.querySelector('video');
|
||||||
|
if (!video) return;
|
||||||
|
var saved = sessionStorage.getItem('video-volume');
|
||||||
|
if (saved !== null) {
|
||||||
|
var v = parseFloat(saved);
|
||||||
|
video.volume = v;
|
||||||
|
video.muted = v === 0;
|
||||||
|
}
|
||||||
|
video.addEventListener('volumechange', function() {
|
||||||
|
sessionStorage.setItem('video-volume', video.muted ? '0' : video.volume);
|
||||||
|
});
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
2
main.py
2
main.py
@ -424,7 +424,7 @@ def _render_page(
|
|||||||
if content_type and content_type.startswith("video"):
|
if content_type and content_type.startswith("video"):
|
||||||
media_element = (
|
media_element = (
|
||||||
f'<video class="media" src="{img_url}" controls autoplay '
|
f'<video class="media" src="{img_url}" controls autoplay '
|
||||||
f'loop muted playsinline {data_attrs}></video>'
|
f'loop playsinline {data_attrs}></video>'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
media_element = (
|
media_element = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user