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

Dynamic Player Size - throwing event error


Hi, I found a piece of code on your site earlier today, that seemed to work fine. But then it just stopped and now I get an error in the console: "There was an error calling back an event handler". This is on development server, so I can't easily send a link...

When running setup on the videoplayer:

bc.. events: {
onMeta: function(event) {
if(event.metadata.width != undefined && event.metadata.height != undefined && event.metadata.width != 0)
{
var playerWidth = event.metadata.width;
if (playerWidth > 640) {
playerWidth = 640;
}
var playerHeight = (event.metadata.height/event.metadata.width)*playerWidth;
jwplayer().resize(playerWidth, playerHeight);
}
}
}

12 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Can you put something up?

JW Player

User  
0 rated :

Ok, I had my boss put up a temporary static HTML page:
apps.pgalinks.com/temp.html

I tried it both ways inside .setup() and

bc.. jwplayer().onMeta( function(event) {
if(event.metadata.width != undefined && event.metadata.height != undefined && event.metadata.width != 0)
{
var playerWidth = event.metadata.width;
if (playerWidth > 640) {
playerWidth = 640;
}
var playerHeight = (event.metadata.height/event.metadata.width)*playerWidth;
jwplayer().resize(playerWidth, playerHeight);
}
});

Ethan Feldman

JW Player Support Agent  
0 rated :

Are you trying to make the player responsive? You can just do that in line now – http://www.longtailvideo.com/blog/32697/new-in-jw-player-responsive-design

JW Player

User  
0 rated :

No, what I'm trying to do is display the videos at their native resolution/video size if they are smaller than 640 width, or resize down to 640 if they are larger, adjusting the height appropriately, as some of them are 16x9 and others are 4x3 aspect ratio.

Also, for some reason we are able to skip (seek) ahead in IE9, while the code I put in place is preventing it in most browsers and versions. We need to require the members to watch the whole video before they can take a test about it to pass and get credit.

Ethan Feldman

JW Player Support Agent  
0 rated :

You are trying to resize the player. That is what making the player responsive does.

JW Player

User  
0 rated :

Ok, yes, but I'm trying to resize it not to a certain width based on page or device that's viewing it, but based on the video that is being played at its meta-data. I swear I had the code above working, it was even resizing on my bosses computer, but then on mine I was getting those event errors "There was an error calling back an event handler"

Ethan Feldman

JW Player Support Agent  
0 rated :

Where did you get the script from?

JW Player

User  
0 rated :

I found it in one of your forums, but I can't find it again...

JW Player

User  
0 rated :

It may have been here:
http://www.techques.com/question/1-2580633/Auto-resize-in-JW-Player

Ethan Feldman

JW Player Support Agent  
0 rated :

That code looks like it is for jw player 5, not 6.

JW Player

User  
0 rated :

I see, is there a way to resize the player based on native video size if video is smaller with 6?

Ethan Feldman

JW Player Support Agent  
0 rated :

We don’t really expose that, we do have resizing – http://www.longtailvideo.com/support/jw-player/29411/resizing-the-player, but this is based on just dimensions and not native video size.

This question has received the maximum number of answers.