Reputation: 182
I need to make the following workflow for an e-learning application:
get user answer
if the answer is true
if the answer is wrong reload the page and start the video from the beginning
I need to keep manual seeking disabled while playing the video. Here is my code
flowplayer_settings.clip.onCuepoint = [config.de, function(clip, point) {
this.pause();
this.hide();
$("#question").show();
$.ajax({
url: config.qp,
success: function(data) {
$("#question").html(data);
$('#advance').click(function() {
$f().show();
$f().resume();
});
},
dataType: 'html'
});
}];
Into the code, when I click on the #advance button, that is shown after I have answered correctly to a question, I get another question, it seems that the cuepoint is called an infinite number of times. I cannot understand that. Any advices? Thanks a lot.
Upvotes: 2
Views: 443
Reputation: 182
I solved with a dirty solution, I am not proud of that but I have not found any better way to solve this issue. I just put a flag that checks if the cuepoint has already been executed, if so I skip the cuepoint code.
flowplayer_settings.clip.onCuepoint = [config.de, function(clip, point) {
if (flag == 1) {
this.pause();
if (this.isFullscreen()) {
this.toggleFullscreen();
}
$.blockUI({ message: $("#question"), css: { top: '30%' } });
$.ajax({
url: config.qp,
success: function(data) {
$("#question").html(data);
flag = 0;
$('#advance').click( function () {
$.unblockUI();
});
$('#failure > button').click( function () {
$.unblockUI();
location.reload();
});
},
dataType: 'html'
});
}
Upvotes: 2