Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
- </head>
- <body>
- <!-- this is your video element -->
- <video width="400" controls>
- <!-- your video source, verify so that type is accurate -->
- <source id="vidsrc" src="../media/0-11970-20200228064830.mp4" type="video/mp4">
- </video>
- <?php
- //fetch and list all the files found in the video folder. Make sure to change the path to your video folder.
- foreach(glob('../media/*') as $video){
- echo '- <a href="#" id="isVideo" class="isVideo" data-video="'.$video.'">'.$video.'</a><br/>';
- }
- ?>
- <!--<script>
- document.getElementById('isVideo').onclick = function(){
- document.getElementById('vidsrc').setAttribute('src', $(this).data('video'));
- }
- </script>-->
- <script type="text/javascript">
- //jQuery code that will trigger when you click on one of the links displayed by the PHP script
- $('.isVideo').on('click',function(){
- //this will change the video source to the chosen video
- $('#vidsrc').attr('src','../media/0-11970-20200228064830.mp4');
- return false;
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment