I am creating a splash page, wherein there’s a video playing on autoplay. I am currently using a VideoBox to play this video on a loop, and the video is set to play automatically. I’ve used the interface to select the video I want to play, and the no-code editor so it plays automatically.
Now I am writing code so that when the form factor switches to mobile, I want the VideoBox to play a totally separate video. The problem is that because using the no-code I selected a certain file, this video is the only video that will play, even if the code understands that it’s supposed to be switching files.
What can I do?
Here is my code —
import wixWindow from 'wix-window';
import wixWindowFrontend from 'wix-window-frontend';
// ...
wixWindow.openLightbox("LightboxName");
$w.onReady(function have() {
let videoSrc = $w("#myVideo").src;
$w("#myVideo").
console.log("Here is the video: " + videoSrc);
let desktopvideo = "wix:video://v1/f028b0_2fd63df8d642414e8db86d28def86837/_#posterUri=f028b0_2fd63df8d642414e8db86d28def86837f000.jpg&posterWidth=1920&posterHeight=1080";
let mobilevideo = "wix:video://v1/f028b0_76d1a867cdbf4914b74470abf9f7f9a0/_#posterUri=f028b0_76d1a867cdbf4914b74470abf9f7f9a0f000.jpg&posterWidth=1920&posterHeight=1080";
let formFactor = wixWindowFrontend.formFactor;
console.log("Form Factor: " + formFactor)
if (formFactor === "Desktop"){
videoSrc = desktopvideo;
} else if(formFactor === "Mobile"){
videoSrc = mobilevideo;
}
console.log("Here is the video: " + videoSrc);
});