User Account

document.addEventListener("DOMContentLoaded", function() { // Alle Slides mit YouTube-Hintergrundvideos var videoBackgrounds = document.querySelectorAll('.sp-video-background'); ``` videoBackgrounds.forEach(function(bg) { var iframe = bg.querySelector('iframe'); if (!iframe) return; // Ursprüngliche src sichern var originalSrc = iframe.src; iframe.removeAttribute('src'); // Funktion zum Laden des Videos var loadVideo = function() { iframe.src = originalSrc + '&autoplay=1'; // Autoplay aktivieren // Optional: iframe sichtbar machen, falls ausgeblendet iframe.style.display = 'block'; }; // Prüfen, ob Slide sichtbar ist var observer = new IntersectionObserver(function(entries, observer) { entries.forEach(function(entry) { if (entry.isIntersecting) { loadVideo(); observer.unobserve(entry.target); // nur einmal laden } }); }, { threshold: 0.25 }); // 25% sichtbar observer.observe(bg); }); ``` });