Skip to content

Commit

Permalink
Merge pull request #12 from karandikar/fix-videostate
Browse files Browse the repository at this point in the history
Fix videostate being undefined if YouTube API loads slowly
  • Loading branch information
caesar2164 authored Jun 7, 2017
2 parents dce4d5f + 88cd900 commit 30377fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion invideoquiz/public/js/src/invideoquiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function InVideoQuizXBlock(runtime, element) {
var componentIsVideo = component.data('id').indexOf(videoId) !== -1;
if (componentIsVideo) {
video = $('.video', component);
videoState = video.data('video-player-state');
} else {
$.each(problemTimesMap, function (time, componentId) {
if (component.data('id').indexOf(componentId) !== -1) {
Expand Down Expand Up @@ -103,6 +102,8 @@ function InVideoQuizXBlock(runtime, element) {
var problemToDisplay;

video.on('play', function () {
videoState = videoState || video.data('video-player-state');

clearInterval(resizeIntervalObject);

if (problemToDisplay) {
Expand Down Expand Up @@ -134,6 +135,7 @@ function InVideoQuizXBlock(runtime, element) {
});

video.on('pause', function () {
videoState = videoState || video.data('video-player-state');
clearInterval(intervalObject);
if (problemToDisplay) {
resizeIntervalObject = setInterval(function () {
Expand Down

0 comments on commit 30377fa

Please sign in to comment.