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

Problem accessing jwPlayer() within a function


Hello,

I have successfully set up a jwplayer instance, and it is the only one on the page. I can access its properties from an <a onclick> event (for example, <a onclick='jwPlayer().getPosition()'>Report position</a>), but once I call jwPlayer().getPosition() from inside a script or function, I get an 'Uncaught ReferenceError: jwPlayer is not defined'. I am by no means an expert in JS or JQuery, but how could this be a scope issue? I see examples of this working fine on the support pages. I also tried targeting the specific element id: jwPlayer('videoPlayer').getPosition(). I am scratching my head on this one.

Any help is appreciated. Thanks!

Chris Hardwick

6 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Do you have a link?

jherrieven

User  
1 rated :

@Chris

jwPlayer != jwplayer

JavaScript is case-sensitive and the "jwplayer" object is all lowercase.

Ethan Feldman

JW Player Support Agent  
0 rated :

Ah, that would do it.

christanhardwick

User  
0 rated :

well, in the interim I found I could put the function in the events when setting up the jwplayer. But I assume one can call the jwplayer within another function, outside of setup()... I just don't seem to be able to. I will try to put a fiddle together to show this today. Thanks.

christanhardwick

User  
0 rated :

Whoops! didn't see jherriven's reply. Thank you! Should have caught that.

Ethan Feldman

JW Player Support Agent  
0 rated :

Glad you got it.

This question has received the maximum number of answers.