-
Notifications
You must be signed in to change notification settings - Fork 0
Loading the PJS Library
giannif edited this page Dec 16, 2014
·
10 revisions
Builds are deployed to http://media.mtvnservices.com/player/js/{version}. They are accessible through http://media.mtvnservices.com/pjs/?v={version}. The /pjs/ route will return the correct build for the correct context (user agent, referrer, etc.).
The PJS library is loaded just like any other javascript file. If you include it in the head, it is considered "blocking" and will be loaded before your page. You can put it in the footer to avoid this.
If you know the library is loaded, you can use it right away. However, if you want to decouple your logic, you can use some boilerplate code to listen for a _pjsReady feature.
var _pjsReady = _pjsReady || [];
// it's best to add functions with "push", the api overrides it once it loads,
// so you don't have to check PJS.isReady.
_pjsReady.push(function(){
// fires when the api has loaded,
// or if the api is already loaded.
// now I can create players.
var player = new PJS.Player(element);
});