Answers for "Video_loop_array"

0

Video_loop_array

window.onload = function(){ 
    //now that the window has loaded we add our event listeners to the videos.
    //When video1 has ended, play video2 etc
    document.getElementById("video1").addEventListener("ended", function(){ playVideo("video2"); });
    document.getElementById("video2").addEventListener("ended", function(){ playVideo("video3"); });
    document.getElementById("video3").addEventListener("ended", function(){ playVideo("video1"); });
}

function playVideo(videoID){
    //This playVideo function takes in the ID of a video element and plays that video.
    var videoElement = document.getElementById(videoID);
    videoElement.play();
}
Posted by: Guest on April-17-2022

Browse Popular Code Answers by Language