How to automatically unmute a video as it scrolls into view and mute it automatically when it scrolls away? Can we achieve this with Velo code?

Question:
how to automatically unmute a video as it scrolls into view and mute it automatically when it scrolls away ? Can we achieve this velo or without it?

Product:
Wix Editor

What are you trying to achieve:
[Explain the details of what you are trying to achieve. The more details you provide, the easier it is to understand what you need.]

What have you already tried:
[Share resources, forum topics, articles, or tutorials you’ve already used to try and answer your question.]

Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]

Yes, if you’re using the Wix Video Player, then this bit of Velo code should be able to do it:

$w.onReady(function () {

    $w("#myVideoPlayer").onViewportEnter((event) => {
        $w("#myVideoPlayer").unmute();
    });

    $w("#myVideoPlayer").onViewportLeave((event) => {
        $w("#myVideoPlayer").mute();
    });

});

Simply replace myVideoPlayer with the id of your video player element, and you’re good to go!

Thanks @Pratham for the solution. I tried the code and it works but it the video doesn’t autoplay the first time. I have to press the play button and then it is working as per the code. I set the autoplay setting to true but still it doesn’t autoplay on viewport entrance.

I also tried below code, still it doesn’t autoplay:

$w.onReady(function () {

$w("#videoPlayerHomepage2").onViewportEnter((event) => {
    $w("#videoPlayerHomepage2").unmute();
    $w('#videoPlayerHomepage2').play();
});

$w("#videoPlayerHomepage2").onViewportLeave((event) => {
    $w("#videoPlayerHomepage2").mute();
    $w('#videoPlayerHomepage2').pause();
});

});

There must be some bug on Wix-Side, regarding the related API.

This AUTO-PLAY-LIST was working perfectly in the past…

https://russian-dima.wixsite.com/meinewebsite/kopie-von-autoplay-video-list

Here you can see a Video-Play-List, which was capable to stop and start video-playback automatically.

Unfurtenatelly this AUTOMATIC-PLAYLIST do not work anymore, without having done on it anything since years.

You will face also in the future, that all your in the past generated CODE will die one day.
This is how Wix works. Today → it’s working ← → tomorrow → it’s → DEAD !

You want to see another example ???

Here we go. —>

2 Likes