Merge branch 'HFP-815-QS-multiple-autoplay-issue'

pull/4/merge
Paal Joergensen 2017-05-10 12:38:42 +02:00
commit b3887c0f56
1 changed files with 17 additions and 0 deletions

View File

@ -357,6 +357,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
currentQuestion = questionNumber; currentQuestion = questionNumber;
handleAutoPlay(currentQuestion);
// Hide all questions // Hide all questions
$('.question-container', $myDom).hide().eq(questionNumber).show(); $('.question-container', $myDom).hide().eq(questionNumber).show();
@ -407,6 +409,21 @@ H5P.QuestionSet = function (options, contentId, contentData) {
return currentQuestion; return currentQuestion;
}; };
/**
* Handle autoplays, limit to one at a time
*/
var handleAutoPlay = function (currentQuestion) {
for (var i = 0; i < questionInstances.length; i++) {
questionInstances[i].pause();
}
var hasAutoPlay = params.questions[currentQuestion].params.media.params.playback.autoplay;
if (hasAutoPlay) {
questionInstances[currentQuestion].play();
}
};
/** /**
* Show solutions for subcontent, and hide subcontent buttons. * Show solutions for subcontent, and hide subcontent buttons.
* Used for contracts with integrated content. * Used for contracts with integrated content.