ofer
ofer

Reputation: 31

Changing video in jwplayer on error

I'd like the jwplayer to load a different video every time there is an error. I tried

 jwplayer().onError(function(e){                                        
                setTimeout(function(){                 
                    jwplayer().stop();
                    var errorVideo="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4";
                    jwplayer().setup({
                        file: errorVideo,
                        height: 360,
                        width: 640,
                        autostart:true
                    }).load();
                }, 1000);               
            }

And I can hear the audio but can't see the video

Upvotes: 2

Views: 1394

Answers (2)

Josie Keller
Josie Keller

Reputation: 477

Try using .load() instead of .setup(). This will load a new file into your existing player instead of creating a new player with conflicting JS.

Here's a demo of this functionality with a code sample: https://developer.jwplayer.com/jw-player/demos/basic/custom-error/

Upvotes: 0

Todd
Todd

Reputation: 249

Try calling jwplayer().remove() to get rid of the old video before calling jwplayer().setup() with the new video.

Upvotes: 3

Related Questions