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

Getting 'TypeError: Cannot read property 'setup' of undefined' error


I'm getting the TypeError in a function that calls the jwplayer( element ).setup( ... ) API function. In my call to jwplayer(element ).setup, the element variable is set to the value returned by $( 'audio-player' ).last()[ 0 ], which at the time of the call I know contains a reference to the <div> tag that I want the jwplayer to connect to.

Unfortunately, I can't find the API documentation for jwPlayer version 5.10.2295. so I can't determine what possible parameter types the jwplayer call are supporte. However, in other examples of jwplayer(...).setup(...) calls, I've seen a string containing the class name is passed and the file and other properties are hard-coded, something that I don't want to do. In my case I have several places where I want to embed the jwplayer, and of course each place has a different song or video that is to be played, so I don't see how passing in a class name used by multiple <div> tags would work.

Is it possible to pass a specific div object to jwplayer and assign the properties using variables as follows:

<script>
function show_player( element, video_url, video_image ) {

jwplayer( element ).setup( {
flashplayer: '/Resources/public/miscjslibs/jwplayer/player.swf',
file: video_url,
image: video_image,
height: 26,
width: 480,
controlbar: 'bottom',
autostart: true
} );

}
</script>

Each place were I want to use jwplayer I would use the following:

<div class="audio-player"></div>
<script>
show_player( $audioPlayers.last()[ 0 ],.
"https://www.youtube.com/embed/uMsOIWa-gHE',
'http://img.youtube.com/vi/uMsOIWa-gHE/0.jpg" );
</script>

I've embedded hard-coded strings for the parameters here, but they are actually values from a php script, and are unique to each call. Additionally, the $audioPlayers.last()[ 0 ] references the <div> just before the <script> in each place where the jwplayer is to be embedded.

Thank you,
Ron Brown

1 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

We’ve discontinued support for both JW5 and YouTube embeds. We suggest you update to JW8 and upload your content to your dashboard before embedding them on your page.

This question has received the maximum number of answers.