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

require.js, AMD and "missing license key"


As happy as I was that jwPlayer is using a compatible format for the js file, I'm currently working with a setup including require.js and I'm getting a player on my site but it shows "Error setting up player: Missing license key".

# This is in the template file
<div id="jwPlayerWrapper"></div>
require(['jwplayer','initJwplayer'], function(jwplayer, BackgroundJwPlayer) {
jwplayer.key="[HereWouldBeMyKey]"; //tried this first
var controller = new BackgroundJwPlayer('jwPlayerWrapper', jwplayer);
controller.init();
});

The alias jwplayer points to the original player script downloaded from my account dashboard that initializes/returns the jwplayer object.
The file behind initJwplayer contains the init of the BackgroundJwPlayer object and calling the init function on this will set up the player.

I tried defining the key from within the require block inside the template as well as insite the init function before calling jwplayer.setup, both with little success.

Everything else seems to work fine, the player is initialized, recognized and stuff... only the key is missing, even though its there.


Any help greatly appreciated.

6 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, there.

Can you please give me a link to a page where you have the affected player installed?

Thank you.

KADlancer

User  
0 rated :

As the website is still in development, I can't.

Building a mock would require a complete setup with require and the rest so I can't provide a direct look at the code.

Is there a problem with local development and a staging environment that can't be accessed by other IPs in regard to checking the key validity?

James Herrieven

User  
2 rated :

Some of the (hard)coding within JW Player relies on "jwplayer" being scoped as a global variable.

Try adding the following as the first line of your require block:

window.jwplayer = jwplayer;

As follows:

# This is in the template file
<div id="jwPlayerWrapper"></div>
require(['jwplayer','initJwplayer'], function(jwplayer, BackgroundJwPlayer) {
window.jwplayer = jwplayer;
jwplayer.key="[HereWouldBeMyKey]"; //tried this first
var controller = new BackgroundJwPlayer('jwPlayerWrapper', jwplayer);
controller.init();
});

James Herrieven
===================================================
Powered by Haiku
http://powered-by-haiku.co.uk/
---------------------------------------------------
Tatami for Online Video
http://dev.powered-by-haiku.co.uk/solutions/tatami/
---------------------------------------------------
skype: JamesHerrieven
email: james[at]haiku[dot]co[dot]uk
===================================================

KADlancer

User  
1 rated :

@James Herrieven

"Some of the (hard)coding within JW Player relies on "jwplayer" being scoped as a global variable."
THIS!

Thank you. This seems to fix the missing key error. I need to adjust a few more things but the key is recognized now so I can finish the project.

Thanks a lot. This tip was spot on!

eve

User  
0 rated :

I'm also having the error 'Missing License Key" at my URL here:
http://d3b1wx5otkxco2.cloudfront.net/jwexample.html

I registered for a free JW player, but was given a license key. Where do I add it? How can I get this video to play?

Alex

JW Player Support Agent  
0 rated :

Hi, there.

Your code looks pretty good for the self-hosted player. If you uncomment the embed code and the <div>, it should work.

Please let me know if you need any more help or have any other questions.

Thank you!

This question has received the maximum number of answers.