Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body onload="myNewSrc()">
- <div class="video-wrapper-main">
- <video onended="myAddListener()" class="episodeVideo" preload="auto"
- autoplay controls>
- <source src="" type="video/mp4">
- </video>
- </div>
- </body>
- var currentIndex = 0;
- // listener function changes src
- function myNewSrc() {
- var myVideo = document.getElementsByClassName('episodeVideo')[0];
- myVideo.src = videoSources[currentIndex];
- myVideo.load();
- }
- // add a listener function to the ended event
- function myAddListener() {
- var myVideo = document.getElementsByClassName('episodeVideo')[0];
- currentIndex = (currentIndex + 1) % videoSources.length;
- myVideo.src = videoSources[currentIndex];
- myVideo.addEventListener('ended', myNewSrc, false);
- }
Add Comment
Please, Sign In to add comment