I realise variants of this question have been asked before, but none specifically relating to how to do it on video.js
I'm using video.js for my videos. I need the videos to play when the user scrolls to their view. Many people have asked about html5 videos but I would like to know on video.js specifically. I've done the following but no luck -
var videos = videojs('movie-id_html5_api');
videojs("movie-id_html5_api").ready(function(){
  var videos = this;
  fraction = 0.8;
  function checkScroll() {
  for(var i = 0; i < videos.length; i++) {
    var video = videos[i];
    var x = video.offsetLeft, y = video.offsetTop, w = video.offsetWidth, h = video.offsetHeight, r = x + w, //right
        b = y + h, //bottom
        visibleX, visibleY, visible;
        visibleX = Math.max(0, Math.min(w, window.pageXOffset + window.innerWidth - x, r - window.pageXOffset));
        visibleY = Math.max(0, Math.min(h, window.pageYOffset + window.innerHeight - y, b - window.pageYOffset));
        visible = visibleX * visibleY / (w * h);
        if (visible > fraction) {
            videos.play();
        } else {
            videos.pause();
        }
   }
  }
    });
    window.addEventListener('scroll', checkScroll, false);
    window.addEventListener('resize', checkScroll, false);
I should also mention I have multiple videos with the same ID 'movie-id_html5_api' and I would all like to get them to play when scrolled.
thank you in advance!!
 
     
    