Video Autoplay ( when visible)

Video Autoplay ( when visible)

https://cdnjs.com/libraries/vissense/tutorials/getting-started

My Example of making all video using vissense function

    $(".video").each(function () {
        var myVideo = document.getElementById(this.id);

        VisSense.VisMon.Builder(VisSense(myVideo, { fullyvisible: 0.75 }))
        .on('fullyvisible', function(monitor) {
          myVideo.play();
        })
        .on('hidden', function(monitor) {
          myVideo.pause();
        }).build().start();
    });

Code Explanation
1. For each class video, get their id and set VisSense function to it
2. Set the fullyvisible to desire visibility for my case i set it to 75% to autoplay videos

Back To Top