document.addEventListener("DOMContentLoaded", function() { const portraitFrame = document.getElementById("vimeoPortrait"); const landscapeFrame = document.getElementById("vimeoLandscape"); const portraitPlayer = new Vimeo.Player(portraitFrame); const landscapePlayer = new Vimeo.Player(landscapeFrame); // Autoplay both silently in the background (helps with instant switching) portraitPlayer.play().catch(()=>{}); landscapePlayer.play().catch(()=>{}); function showVideo() { const isPortrait = window.matchMedia("(orientation: portrait)").matches; const isMobile = window.innerWidth {}); } else { portraitFrame.style.opacity = 0; landscapeFrame.style.opacity = 1; portraitPlayer.pause(); landscapePlayer.play().catch(()=>{}); } } showVideo(); window.addEventListener("orientationchange", showVideo); window.addEventListener("resize", showVideo); });