Guest User

Untitled

a guest
Mar 2nd, 2020
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
  4. </head>
  5. <body>
  6. <!-- this is your video element -->
  7. <video width="400" controls>
  8. <!-- your video source, verify so that type is accurate -->
  9. <source id="vidsrc" src="../media/0-11970-20200228064830.mp4" type="video/mp4">
  10. </video>
  11.  
  12. <?php
  13. //fetch and list all the files found in the video folder. Make sure to change the path to your video folder.
  14. foreach(glob('../media/*') as $video){
  15. echo '- <a href="#" id="isVideo" class="isVideo" data-video="'.$video.'">'.$video.'</a><br/>';
  16. }
  17. ?>
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. <!--<script>
  26. document.getElementById('isVideo').onclick = function(){
  27. document.getElementById('vidsrc').setAttribute('src', $(this).data('video'));
  28. }
  29. </script>-->
  30.  
  31. <script type="text/javascript">
  32. //jQuery code that will trigger when you click on one of the links displayed by the PHP script
  33. $('.isVideo').on('click',function(){
  34. //this will change the video source to the chosen video
  35. $('#vidsrc').attr('src','../media/0-11970-20200228064830.mp4');
  36. return false;
  37. });
  38. </script>
  39. </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment