Guest User

Untitled

a guest
Dec 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <body onload="myNewSrc()">
  2. <div class="video-wrapper-main">
  3. <video onended="myAddListener()" class="episodeVideo" preload="auto"
  4. autoplay controls>
  5. <source src="" type="video/mp4">
  6. </video>
  7. </div>
  8. </body>
  9.  
  10. var currentIndex = 0;
  11. // listener function changes src
  12. function myNewSrc() {
  13. var myVideo = document.getElementsByClassName('episodeVideo')[0];
  14. myVideo.src = videoSources[currentIndex];
  15. myVideo.load();
  16. }
  17.  
  18. // add a listener function to the ended event
  19. function myAddListener() {
  20. var myVideo = document.getElementsByClassName('episodeVideo')[0];
  21. currentIndex = (currentIndex + 1) % videoSources.length;
  22. myVideo.src = videoSources[currentIndex];
  23. myVideo.addEventListener('ended', myNewSrc, false);
  24.  
  25. }
Add Comment
Please, Sign In to add comment