Preload video, to avoid wait when pressing finish-button
parent
393379884b
commit
f23160d67b
|
@ -233,32 +233,37 @@ 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);
|
||||||
|
|
||||||
|
var $video;
|
||||||
|
if (params.endGame.animations.showAnimations) {
|
||||||
|
var sources = "";
|
||||||
|
var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo;
|
||||||
|
|
||||||
|
if (videoData) {
|
||||||
|
for (var key in videoData) {
|
||||||
|
sources += '<source src="' + cp + videoData[key] + '" type="' + key + '">';
|
||||||
|
}
|
||||||
|
// TODO: Width/height from somewhere.
|
||||||
|
$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) {
|
$('.qs-finishbutton').click(function (ev) {
|
||||||
// Display animation if present.
|
// Display animation if present.
|
||||||
if (params.endGame.animations.showAnimations) {
|
if ($video) {
|
||||||
// Init anims.
|
// Start video.
|
||||||
console.log("Now we should have started some anims...");
|
target.html($video);
|
||||||
var sources = "";
|
$video.on('play', function(ev) {
|
||||||
var videoData = success ? params.endGame.animations.successVideo : params.endGame.animations.failVideo;
|
console.log('Video started playing!!!');
|
||||||
|
}).on('ended', function(ev) {
|
||||||
if (videoData) {
|
console.log('Video is finished, quitting now!');
|
||||||
for (var key in videoData) {
|
// On animation finished:
|
||||||
sources += '<source src="' + cp + videoData[key] + '" type="' + key + '">';
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
}
|
});
|
||||||
// TODO: Width/height from somewhere.
|
// Press play on tape!
|
||||||
var $video = $('<video width="635" height="500">' + sources + 'Stop using IE you fool</video>');
|
$video[0].play();
|
||||||
|
|
||||||
target.html($video);
|
|
||||||
$video.on('play', function(ev) {
|
|
||||||
console.log('Video started playing!!!');
|
|
||||||
}).on('ended', function(ev) {
|
|
||||||
console.log('Video is finished, quitting now!');
|
|
||||||
// On animation finished:
|
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
|
||||||
});
|
|
||||||
// Play vidoi!
|
|
||||||
$video[0].play();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Trigger finished event.
|
// Trigger finished event.
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
||||||
|
|
Loading…
Reference in New Issue