Try using Event.COMPLETE event ........ myVideo.addEventListener(Event.COMPLETE,myNewSrc,false);
Flash fallback for javascript "ended" event listener?
-
04-12-2021 - |
سؤال
I'm using this script to load a series of videos that a user has selected on a form on a previous page... it loads a video array using the <video>
tag, and I was wondering what the best way to provide a flash-based fallback would be — is it simply a matter of browser detection and loading a completely flash-based alternative to the script, or is there an easier way to modify the existing script?
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function myEndedListener(){
var myVideo = document.getElementsByTagName('video')[0];
myVideo.addEventListener('ended',myNewSrc,false);
}
var position = 0;
var videoList=new Array('one.mp4', 'two.mp4', 'three.mp4');
function myNewSrc() {
var myVideo = document.getElementsByTagName('video')[0];
if(++position >= videoList.length) {
position = 0;
}
myVideo.src=videoList[position];
myVideo.load();
myVideo.play();
}
المحلول
لا تنتمي إلى StackOverflow