diff --git a/js/questionset.js b/js/questionset.js index a0acb78..b96cc0e 100644 --- a/js/questionset.js +++ b/js/questionset.js @@ -357,6 +357,8 @@ H5P.QuestionSet = function (options, contentId, contentData) { currentQuestion = questionNumber; + handleAutoPlay(currentQuestion); + // Hide all questions $('.question-container', $myDom).hide().eq(questionNumber).show(); @@ -407,6 +409,21 @@ H5P.QuestionSet = function (options, contentId, contentData) { 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. * Used for contracts with integrated content.