Preload video, to avoid wait when pressing finish-button
parent
393379884b
commit
f23160d67b
|
@ -233,11 +233,9 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
finishButtonText: params.endGame.resultPage.finishButtonText
|
finishButtonText: params.endGame.resultPage.finishButtonText
|
||||||
};
|
};
|
||||||
endTemplate.update(target.attr('id'), eparams);
|
endTemplate.update(target.attr('id'), eparams);
|
||||||
$('.qs-finishbutton').click(function (ev) {
|
|
||||||
// Display animation if present.
|
var $video;
|
||||||
if (params.endGame.animations.showAnimations) {
|
if (params.endGame.animations.showAnimations) {
|
||||||
// Init anims.
|
|
||||||
console.log("Now we should have started some anims...");
|
|
||||||
var sources = "";
|
var sources = "";
|
||||||
var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo;
|
var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo;
|
||||||
|
|
||||||
|
@ -246,8 +244,16 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
sources += '<source src="' + cp + videoData[key] + '" type="' + key + '">';
|
sources += '<source src="' + cp + videoData[key] + '" type="' + key + '">';
|
||||||
}
|
}
|
||||||
// TODO: Width/height from somewhere.
|
// TODO: Width/height from somewhere.
|
||||||
var $video = $('<video width="635" height="500">' + sources + 'Stop using IE you fool</video>');
|
$video = $('<video width="635" height="500">' + sources + 'Stop using IE you fool</video>');
|
||||||
|
$video[0].autoplay = false;
|
||||||
|
$video[0].load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.qs-finishbutton').click(function (ev) {
|
||||||
|
// Display animation if present.
|
||||||
|
if ($video) {
|
||||||
|
// Start video.
|
||||||
target.html($video);
|
target.html($video);
|
||||||
$video.on('play', function(ev) {
|
$video.on('play', function(ev) {
|
||||||
console.log('Video started playing!!!');
|
console.log('Video started playing!!!');
|
||||||
|
@ -256,9 +262,8 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
// On animation finished:
|
// On animation finished:
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
});
|
});
|
||||||
// Play vidoi!
|
// Press play on tape!
|
||||||
$video[0].play();
|
$video[0].play();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Trigger finished event.
|
// Trigger finished event.
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
|
|
Loading…
Reference in New Issue