onsa
12/20/2016 - 10:39 AM

Load next video when current ends

Load next video when current ends

function loadNextVideo() {
  myVideo.src = sources[currentVideo % sources.length];
  myVideo.load();
  currentVideo++;
}

function loadAndplayNextVideo() {
  loadNextVideo();
  myVideo.play();
}

function init() {
  myVideo = document.querySelector("#myVideo");
  myVideo.addEventListener('ended', loadAndplayNextVideo, false);
}