smartblonde
smartblonde

Reputation: 148

Can we add error and event handlers before jwplayer player can generate those errors?

The JWPlayer JS API seems unclear about what happens during .setup(). The docs recommend waiting until .setup() is completed and the player is ready. Presumably they mean the ready() event is triggered. What is the proper way to register handlers for setupError, ready and other error events before calling .setup() ? Does anyone know what JWPlayer does with the file(s) before .setup() completes?

Upvotes: 1

Views: 1033

Answers (1)

Todd
Todd

Reputation: 249

My suggestion would be to chain all of your event handlers to the same setup() call:

var playerInstance = jwplayer('myVideo');
playerInstance.setup({
    file: 'bunny.mp4',
}).on('ready',function(){
    console.log('ready');      
}).on('setupError',function(){
    console.log('setupError')
});

What are you trying to do to the file before setup() completes?

As far as what JW Player does with the file, we do not request the file URL until the player starts playback unless you are using one of the preload options as documented at https://developer.jwplayer.com/jw-player/docs/developer-guide/customization/configuration-reference/

Upvotes: 1

Related Questions