1xptolevitico69

Video Playlist

Mar 20th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.39 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width">
  7. <style>
  8.  
  9. video {
  10. width:600px;
  11. position:absolute;
  12. top:50%;
  13. left:50%;
  14. transform:translate(-50%,-50%);
  15. border:5px solid red;
  16. padding:5px;
  17. cursor:pointer;
  18. }
  19.  
  20. #h1, #h2 {
  21. position:absolute;
  22. top:5%;
  23. left:50%;
  24. transform:translate(-50%,-5%);
  25. font-size:40px;
  26. font-family:arial;
  27. }
  28.  
  29. </style>
  30. </head>
  31. <body>
  32.  
  33. <h1 id='h1'></h1>
  34. <h1 id='h2'></h1>
  35.  
  36. <a href='1.mp4'></a>
  37. <a href='2.mp4'></a>
  38. <a href='3.mp4'></a>
  39. <a href='4.mp4'></a>
  40. <a href='5.mp4'></a>
  41.  
  42.  
  43. <video id='video'></video>
  44.  
  45.  
  46. <script>
  47.  
  48. Default = 0;
  49. counter = 1;
  50. i = 0;
  51.  
  52.           x = document.getElementsByTagName('a');
  53.  
  54. video.src = x[i];
  55.  
  56. video.onclick = function(){
  57. if( Default == 0 ){
  58. Default = 1;
  59. video.controls = true;
  60. video.load();
  61. video.play();
  62. h1.innerHTML = 'Now playing Video ' + counter;
  63. }
  64. }
  65.  
  66.  
  67. video.onended=()=>{
  68.  
  69.      i++;  
  70.      counter++;
  71.      video.src = x[i];
  72.      video.play();
  73.      h1.innerHTML = 'Now playing Video ' + counter;
  74.  
  75.         if( i == x.length ){
  76.              i = 0;
  77.              video.src = x[i];
  78.              video.play();      
  79.              h2.innerHTML = 'Loop mode now active';
  80.              h1.style.display = 'none';
  81. }
  82.  
  83.         if( counter == x.length ){
  84.             counter = 0;          
  85. }
  86. }
  87.  
  88.  
  89. </script>
  90. </body>
  91. </html>
Add Comment
Please, Sign In to add comment