Ingo86
Ingo86

Reputation: 182

Flowplayer, infinite execution of cuepoint

I need to make the following workflow for an e-learning application:

  1. pause the player
  2. hide the player
  3. show a question (the challenge)
  4. get user answer

  5. if the answer is true

    1. hide the question div
    2. show the player
    3. resume the play
  6. 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

Answers (1)

Ingo86
Ingo86

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

Related Questions