jwplayer

How do I stop JWPlayer from automatically playing the next video in the playlist?


Lets say I have a dozen videos loaded in a JWPlayer playlist on a page. I'd like the first video to autoplay- a simple task of changing a setting:

autostart: true

What I don't want, however, is for the next video in the playlist to play when the first one completes, which seems to happen automatically. I do not see anything in the JWPlayer docs about changing this setting.

There is the solution of pausing the video a very short time before it actually completes, and not allowing it to go further, but I was wondering if there's a more elegant solution than that.


Solution

  • 'Pausing the video a short time before it actually completes' was pretty close to the answer I ended up using. JWPlayer has two key functions:

    onComplete()
    

    and

    onBeforeComplete()
    

    I had tried using onComplete to stop it from continuing, but that didn't work. It would keep moving on to the next video. If you need to change what you want the player to do between videos on your playlist, you need to do onBeforeComplete(). There is no noticeable difference in the actual time stopped.

    I ended up setting it to go to a user selected video instead of the one next on the playlist.