Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Jwplayer responsive bug when calling setup twice

I provided here a little fiddle. The problem is if you call a setup function for the jwplayer twice, video will lose responsiveness. Use case for this is for example in Angular where where we keep jwplayer options in one object variable and we provide those upon calling a setup function. The thing is that we have sources changing all the time while controller JS goes through the whole process so before we actually display player on the page we wanna have latest videos provided. So everytime sources get updated by loading another source video we wanna call setup function again to provide latest sources.

In this example I'm only loading 1 file and that is why I use file property and not sources, point is just to show you what is happening. Also we could have done our flow in a different way to make sure we call setup only once but I personally think this shouldn't be happening anyways that is why I'm reporting it as a bug. Please correct me if I'm wrong.

The thing is, first time you call setup function and you provide aspect ratio (let's say '4:3'), that function will take that object and manipulate it's properties and return that object back to the app with 'aspectratio' property of '75%'. So next time you call a setup with that object aspect ratio will be sent as 75% and that is something that jwplayer doesn't understand and it will not add:

.jwplayer.aspectMode {
height: auto;

to the div in which jwplayer is held which is crucial for video responsive design. (Try removing one setup call from JSFiddle example and it will be responsive)

Fix for this is to clone object everytime before we pass it to jwplayer setup function, but I don't know exactly is that something we should be doing or jwplayer should do by default to prevent these things from happening.

1 Community Answers

Cooper Reid

JW Player Support Agent  
-2 rated :

This seems to be a timing related issue. You are calling setup twice in a row, and the first setup call may have have complete. I would wait for readiness to call the second setup:

This question has received the maximum number of answers.