-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwplayer.js
41 lines (34 loc) · 982 Bytes
/
jwplayer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
JWPlayer = {
load: _.once(function(token) {
if (!token) {
console.warn('Please add your token to JWPlayer.load()');
return
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://content.jwplatform.com/libraries/' + token + '.js';
document.head.appendChild(script);
this._checkReady();
}),
_checkReady: function() {
var self = this;
var i = 0;
var checkReady = Meteor.setInterval(function(){
if (typeof jwplayer !== 'undefined') {
self._loaded.set(true);
Meteor.clearInterval(checkReady);
} else {
i += 100;
if (i > 5000) {
// stop checking if the lib isn't loaded within 5 secs
Meteor.clearInterval(checkReady);
console.warn('Error loading JW Player from CDN');
}
}
}, 100);
},
_loaded: new ReactiveVar(false),
loaded: function() {
return this._loaded.get();
}
};