Added video playback on QuestionSet finish
parent
55e3af8dd1
commit
393379884b
|
@ -86,7 +86,7 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
endGame: {
|
endGame: {
|
||||||
showResultPage: true,
|
showResultPage: true,
|
||||||
resultPage: {
|
resultPage: {
|
||||||
succesGreeting: "Congratulations!",
|
successGreeting: "Congratulations!",
|
||||||
successComment: "You have enough correct answers to pass the test.",
|
successComment: "You have enough correct answers to pass the test.",
|
||||||
failGreeting: "Sorry!",
|
failGreeting: "Sorry!",
|
||||||
failComment: "You don't have enough correct answers to pass this test.",
|
failComment: "You don't have enough correct answers to pass this test.",
|
||||||
|
@ -95,7 +95,9 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
},
|
},
|
||||||
animations: {
|
animations: {
|
||||||
showAnimations: false,
|
showAnimations: false,
|
||||||
succesResultAnimation: {
|
successVideo: undefined,
|
||||||
|
failVideo: undefined,
|
||||||
|
successResultAnimation: {
|
||||||
machineName: "H5P.Image",
|
machineName: "H5P.Image",
|
||||||
options: {image: ""}
|
options: {image: ""}
|
||||||
},
|
},
|
||||||
|
@ -236,8 +238,27 @@ H5P.QuestionSet = function (options, contentId) {
|
||||||
if (params.endGame.animations.showAnimations) {
|
if (params.endGame.animations.showAnimations) {
|
||||||
// Init anims.
|
// Init anims.
|
||||||
console.log("Now we should have started some anims...");
|
console.log("Now we should have started some anims...");
|
||||||
|
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.
|
||||||
|
var $video = $('<video width="635" height="500">' + sources + 'Stop using IE you fool</video>');
|
||||||
|
|
||||||
|
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:
|
// On animation finished:
|
||||||
$(returnObject).trigger('h5pQuestionSetFinished', eventData);
|
$(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