OK, I'm a JavaSript newbie, so forgive my ignorance on this. I have an existing onClick event for an image that triggers an auto-looping random video ("player1") from an array by calling two functions:
function setMp4Source01(){
var videos = [
"video1",
"video2",
"video3",
], videos = videos[Math.floor(Math.random() * videos.length)];
player1.setVideoSource("content/videos/" + videos + ".mp4");
}
and
function play(){
player1.play();
}
through this
<img src ... onclick="setMp4Source01();play();"/>
So my question: What would be the most elegant way to make this onClick event do what it's already doing AND also make it so that when the first random video ends, another random video is played immediately afterward without any user intervention/interaction, then a third random video after that, and so on?
In other words, I click on this image, and a random video from the videos array starts playing, and then as soon as that video ends, another random video from that same array automatically starts playing (without me having to click the image again), and then another video, etc., indefinitely.
Aucun commentaire:
Enregistrer un commentaire