Looking to enhance my website by displaying a random fullscreen background video selected from a folder of videos that I will manage. The goal is to steadily increase the number of videos in the folder (e.g., bg1.mp4, bg2.mp4, etc...) and have the code automatically pick a random video to loop upon loading the page.
Here's my current code: https://jsfiddle.net/nenr3kyn/2/, which unfortunately isn't functioning as intended. Currently, I have specified a particular video as the source file:
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
I seem to be facing issues with getting the HTML to reference the variable defined by the JavaScript "vid", as shown here:
<source src=vid type="video/mp4">
Additionally, this code restricts me to only having specific videos listed within the code, making it impossible to easily add new files to the folder. Ideally, I would like the JavaScript to be able to recognize all the files present in the folder and select one at random, but I've been unsuccessful in implementing that solution as well.
Any suggestions? I welcome any input. Thank you very much!!