I am creating a page with multiple videos slide show(video playinf one by one correctly). But now I want to add time duration to each video.
I have a four videos(array in javascript) and I want to play first video(2mins video)for 15mins and second(10mins) video for 30mins and so on. Please tell me guys, how to do it?
//my code
//multiple video playing code
var videoSource = new Array();
videoSource[0] = 'Colgate.mp4';
videoSource[1] = 'Soap.mp4';
var i = 0;
var videoCount = videoSource.length;
//document.getElementById("myVideo").setAttribute("src",videoSource[0]);
function videoPlay(videoNum) {
document.getElementById("myVideo").setAttribute("src", videoSource[videoNum]);
document.getElementById("myVideo").load();
document.getElementById("myVideo").play();
}
document.getElementById('myVideo').addEventListener('ended', myHandler, false);
videoPlay(1);
function myHandler() {
i++;
if (i == (videoCount - 1)) {
i = 0;
videoPlay(i);
} else {
videoPlay(i);
}
}
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="100%" height="auto" id="vlc" loop="yes" autoplay="yes"></embed>
<center><video controls autoplay id="myVideo" width="100%" height="auto"></video></center>
</div>
My javascript code for one video timing is working.
var video = document.getElementById('myVideo');
var videoStartTime = 0;
var durationTime = 0;
video.addEventListener('loadedmetadata', function() {
videoStartTime = 20;
durationTime = 22;
this.currentTime = videoStartTime;
}, false);
video.addEventListener('timeupdate', function() {
if(this.currentTime > videoStartTime + durationTime){
this.pause();
}
});