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

jwplayer.js not being acknowledged (TypeError: jwplayer(...).setup is not a function)


Hi I have had this code working previously in another website.
If you visit the website, you can see in the sourcecode, the JS files are being called.

When I run the page, I get this error " jwplayer(...).setup is not a function"
So it's not finding the jwplayer function? what it calls inside the js files correct?
Here's my code located currently in the footer:

<code> <script>
function jwpf(url = '#', vidid = 'jwid', width = 710, height = 430, stoptime = 'all', pretitle = 'Loading the player...', image = '#') {
$atts = {
stoptime : stoptime,
width : width,
height : height,
url : url,
pretitle : pretitle,
image : image,
vidid : vidid
};

setStopTime = $atts['stoptime'];

jwplayer("jwid").setup({
file: "#",
height: $atts['height'],
width: $atts['width'],
image: $atts['image']
});



if (setStopTime != "all") {
jwplayer().onTime(function(){
var currentPosition = jwplayer().getPosition();
if (currentPosition >= setStopTime) {jwplayer($atts['vidid']).stop(); }
}); };

return $atts['vidid'];

};

$("#articles-content").html(jwpf());
</script>
</code>

The return is for test purposes. Once I get the bakcend working without error, I'll add the front end in.

9 Community Answers

Todd

JW Player Support Agent  
0 rated :

Where are you linking to either a self-hosted player or our cloud-hosted player? See code examples at http://support.jwplayer.com/customer/portal/articles/1406723-mp4-video-embed

Please send me a link to your test page so I can investigate further. If you do not want to include it in the forums, you can e-mail it to me at support@jwplayer.com

Thanks,
Todd

steveyantz

User  
0 rated :

oh yeah, haha sorry. I meant to do that.

I'm self hosting. I have the js files just before this script.

<script type='text/javascript' src='http://emlmcoach.com/wp-content/jwplayer/jwplayer.js'></script>
<script type='text/javascript' src='http://emlmcoach.com/wp-content/jwplayer/jwplayer.html5.js'></script>

as you can see, the links work.
and in the source code, it shows up.

the website is: http://ucanusenglish.cn/

Todd

JW Player Support Agent  
0 rated :

You have some syntax errors in your Javascript. I am seeing the following error:

SyntaxError: Expected token ‘)’

Please embed just your self-hosted player and the necessary <div> tag on a test page and let me know if that works.

Kind regards,
Todd

steveyantz

User  
0 rated :

I've turned off any jquery I created, other than this.

<script type='text/javascript' src='http://emlmcoach.com/wp-content/jwplayer/jwplayer.js'></script>
<script type='text/javascript' src='http://emlmcoach.com/wp-content/jwplayer/jwplayer.html5.js'></script>

<script>
jwplayer("jwid").setup({
file: "#",
height: 360,
width: 640,
image: "#"
});

$("#articles-content").html('<div id="jwid">test</div>');

</script>

Still getting the same error:
"TypeError: jwplayer(...).setup is not a function"

Which browser are you testing it in to get that error?
It should say where the Javascript syntax error is located, and on which line.

Todd

JW Player Support Agent  
0 rated :

Sorry, line 484. What is the URL to your new test page?

steveyantz

User  
0 rated :

same. it's just on the main page.

steveyantz

User  
0 rated :

If you can give me more info on that error if it's still showing up. It's important to fix it.
What platform are you using that returns that error?
Firefox, and Chrome aren't giving me it.

steveyantz

User  
0 rated :

I figured it out. After doing to some internet searching.
Supposedly the div has to run before the script for it to work..

Todd

JW Player Support Agent  
0 rated :

Yes, the div needs to be present in the code so our player knows where to put the video.

This question has received the maximum number of answers.