Improvement of code. Now none flag is used, but the readyState property from video element

This commit is contained in:
Alex Batista 2015-09-29 20:49:25 -03:00
parent bcfd0aae3c
commit 92a6996754

View file

@ -150,7 +150,6 @@
// Flags if video background is loaded
loadeddataVideo = false,
// The horizontal and vertical index of the currently active slide
indexh,
indexv,
@ -2476,16 +2475,16 @@
// Start video playback
var currentVideo = currentBackground.querySelector( 'video' );
if( currentVideo ) {
if(currentVideo.readyState >1){
currentVideo.currentTime = 0;
currentVideo.play();
}
else{
currentVideo.addEventListener("loadeddata", function() {
currentVideo.currentTime = 0;
currentVideo.play();
loadeddataVideo = true;
this.removeEventListener("loadeddata",function(){return false});
currentVideo.removeEventListener("loadeddata",function(){return false});
});
if(loadeddataVideo === true){
currentVideo.currentTime = 0;
currentVideo.play();
}
}