commit 1374429ab4c7418a5db59240afbbd0f169a88537
parent d0971e3733145fa2efdfcf37ffae102ac44f7031
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Mon, 29 Jul 2024 15:31:04 +0200
feat: enable autoplay on videos
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/assets/js/yt.js b/assets/js/yt.js
@@ -1,17 +1,21 @@
// Embed Youtube Video
function embed_yt(oid, vid) {
+ // Scroll to video section
window.location = "#entry_" + oid;
+ // Fetch thumbnail image to replace
var img = document.querySelector("#thumbnail_" + oid);
+ // Create player iframe-object and set
var player = document.createElement("iframe");
+ player.id = "videoplayer_" + oid;
player.allowFullscreen = "true";
player.sandbox = "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox";
player.width = "100%";
- //player.height = "100%";
player.frameborder = "0";
player.scrolling = "no";
player.loading = "lazy";
- player.src = "https://www.youtube-nocookie.com/embed/" +
- vid;
+ player.allow = "autoplay";
+ player.src = "https://www.youtube-nocookie.com/embed/" + vid + "?autoplay=1";
+ // Replace thumbnail image with player
img.replaceWith(player);
}