1

Im using jwplayer to handle the videos on my site, but having difficulty figuring out how to fire an event on a certain percentage of the video.

This is my current code:

jwplayer("myElement").setup({
    file: "video.mp4",
    height: 600,
    width: 600,
    events: {
        onComplete: function() {
            alert("hi!");
        }
    }
}); 

which fires an event only on complete. I want to fire the even when the video hits 80 percent completion.

Any tips?

7
  • I would look into using onTime for this.
    – emaxsaun
    Nov 18, 2013 at 19:52
  • @EthanJWPlayer how would I dynamically get the time position of the 80% mark
    – Dondada
    Nov 18, 2013 at 19:59
  • get the lenght of the video and current time then progress = current time X lenght / 100 whene progress >=80 fire your fine
    – Hichem
    Nov 18, 2013 at 20:09
  • progress should be in an event like playing
    – Hichem
    Nov 18, 2013 at 20:10
  • Read this: longtailvideo.com/support/jw-player/28851/…
    – Ani
    Nov 18, 2013 at 20:11

1 Answer 1

2

here is your solution on DEMO

the problem is you can not get the duration of the video only current duration

jwplayer("myElement").setup({
file: "video.mp4",
height: 600,
width: 600,
   }); 

if your video length is 5:00 so durationtofire = 4;

var durationtofire = 4;
jwplayer("myElement").onTime(function(event) {
   if (event.position > durationtofire) {
    alert("we are on 80%");
}
});

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.