When I try to set the source of a certain element, it returns an error and I have no clue why this is not working. Here is the javascript:
function playVid() {
var videoPlayer = document.getElementById("video");
var mp4VID = document.getElementById("videoSRC");
var arrOfVid = ["video/video.mp4","video/video1.mp4"]; //, "video/video2.mp4", "video/video3.mp4"];
var arrLenVID = arrOfVid.length;
var randomVID = Math.floor((Math.random() * arrLenVID));
mp4VID.src = arrOfVid[randomVID]; // mp4VIDSRC.src = arrOfVid[randomVID]
videoPlayer.load();
videoPlayer.volume = 0;
videoPlayer.play();
}
playVid();
The HTML part of it is:
<video id="video" autoplay="" style="" muted="">
<source id="videoSRC" src="video/video.mp4" type="video/mp4">
error: unsupported video format
</video>
Here's the error message I'm receiving:
Uncaught TypeError: Cannot set property 'src' of null
Nothing else seems to cross paths with it.