I have an array of videos and I would like to load them into the set video player that is currently on the page. Here's what I have:
var current = 0;
var videos = ["01", "02", "03", "04"];
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex ;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function shuffleAll(){
shuffle(videos);
}
function loadVideo(){
var video = document.getElementById('video');
var mp4 = document.getElementById('mp4');
d = new Date();
mp4.src = "videos/" + videos[current] + '.mp4';
alert(mp4.src);
video.load();
video.play();
}
And my HTML:
<body onLoad="shuffleAll()">
<a href="" onClick="javascript:loadVideo();">Load Video</a><br>
<video id="video" controls width="560">
<source id="mp4" type="video/mp4" />
</video>
</body>
But I click my Load Video Button, and it doesn't do anything. What am I missing?