HELP with loading new video src with click!

https://codepen.io/TuscannyCodes/pen/KKavPKN

Hey, im trying to figure out why this isn’t working. You won’t be able to see the video in the codepen because the files are not available of course, BUT it works on my end.

Im looking to have to have a new video play whenever the user clicks the existing video. Im implementing this by creating an array with video files. Then using math.random to randomize the array and pulgging that into the src of the video html.

Am I making any sense?

If not I linked the codepen :sweat_smile:

Any idea why the onclick isn’t working here? All of the video files are named properly and the original video file is working via the HTML file. But for some reason, its not loading the new videos on click.

Someone please send help :pray: :sweat_smile:

The page is a random quote generator. So im basically just trying to do the same thing that the page is doing, but adding that same feature to the video element of the page.

OOOKAY I see what’s happening here

The eventListener is working! Everything is working correctly! (very proud of myself :smirk:)

I can see that as user clicks the src of the video does in fact change, but it seems that the browser has already preloaded the default video, so no changes will be seen in the window…

hmm :thinking: a bit of a shame. Is there no way to do this without basically preloading all the videos and switching them out in that way? I didn’t think that this would be such an expensive thing to do but I guess it would be…

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.