Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to seek() then pause() with JWPlayer 5.4

Tags:

jwplayer

seek

Does anyone know how to get JW PLayer v5.4 (either the Flash rendering or the HTML5 rendering) to pause after a seek() command?

I'm trying to get the video to step 0.01 seconds forward or backward when a user clicks the fine-grain control buttons (or uses the left or right arrow keys). This is so they can snap a framegrab with better precision.

I'm not sure if this is even possible but I've tried a few things with no luck. Such as the following:

var stepTo = jwplayer("video_player").getPosition() + 0.01;

jwplayer("video_player").seek(stepTo).onComplete(function(){
    jwplayer('video_player').pause();
});

And:

jwplayer("video_player").pause().seek(stepTo);

And:

jwplayer("jwplayer_container").seek(stepTo).pause();

And:

jwplayer("video_player").pause().play().pause();

I've also seen that the 'Shortcuts' plugin has this feature, but that plugin ins't compatible with v5.4 yet.

Thanks for any help.

like image 987
AJB Avatar asked Jan 23 '11 00:01

AJB


1 Answers

@AJB -

There's a ticket to add an "onSeek" event scheduled for the 5.6 player. In the meantime, the best way to do this is probably something like this:

jwplayer("video_player").seek(stepTo);

var pauseOnSeek = true;
jwplayer.onTime(function() {
   if (pauseOnSeek) {
      this.pause();
      pauseOnSeek = false;
   }
});

If the onTime() event fires off before the seek is complete, you may be able to hack around it by setting a timeout before defining the onTime() handler.

like image 187
PabloS Avatar answered Oct 24 '22 15:10

PabloS