2013-01-10 13:06:12 -08:00
|
|
|
/**
|
2013-01-12 22:23:22 -08:00
|
|
|
* @fileoverview Main function src.
|
2013-01-10 13:06:12 -08:00
|
|
|
*/
|
2011-11-29 11:40:05 -08:00
|
|
|
|
2013-01-10 13:06:12 -08:00
|
|
|
// HTML5 Shiv. Must be in <head> to support older browsers.
|
2013-06-28 13:06:50 -07:00
|
|
|
document.createElement('video');
|
|
|
|
document.createElement('audio');
|
|
|
|
document.createElement('track');
|
2012-12-30 21:45:50 -08:00
|
|
|
|
2013-01-04 16:58:23 -08:00
|
|
|
/**
|
|
|
|
* Doubles as the main function for users to create a player instance and also
|
|
|
|
* the main library object.
|
|
|
|
*
|
|
|
|
* @param {String|Element} id Video element or video element ID
|
|
|
|
* @param {Object=} options Optional options object for config/settings
|
|
|
|
* @param {Function=} ready Optional ready callback
|
|
|
|
* @return {vjs.Player} A player instance
|
|
|
|
*/
|
2013-02-22 22:26:58 -05:00
|
|
|
var vjs = function(id, options, ready){
|
2011-11-30 11:53:08 -08:00
|
|
|
var tag; // Element of ID
|
2011-11-29 11:40:05 -08:00
|
|
|
|
|
|
|
// Allow for element or ID to be passed in
|
|
|
|
// String ID
|
2013-01-10 13:06:12 -08:00
|
|
|
if (typeof id === 'string') {
|
2011-11-29 11:40:05 -08:00
|
|
|
|
|
|
|
// Adjust for jQuery ID syntax
|
2013-01-10 13:06:12 -08:00
|
|
|
if (id.indexOf('#') === 0) {
|
2011-11-29 11:40:05 -08:00
|
|
|
id = id.slice(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If a player instance has already been created for this ID return it.
|
2013-01-04 16:58:23 -08:00
|
|
|
if (vjs.players[id]) {
|
|
|
|
return vjs.players[id];
|
2011-11-29 11:40:05 -08:00
|
|
|
|
|
|
|
// Otherwise get element for ID
|
|
|
|
} else {
|
2013-01-10 13:06:12 -08:00
|
|
|
tag = vjs.el(id);
|
2011-11-29 11:40:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ID is a media element
|
|
|
|
} else {
|
|
|
|
tag = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for a useable element
|
|
|
|
if (!tag || !tag.nodeName) { // re: nodeName, could be a box div also
|
2013-01-10 13:06:12 -08:00
|
|
|
throw new TypeError('The element or ID supplied is not valid. (videojs)'); // Returns
|
2011-11-29 11:40:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Element may have a player attr referring to an already created player instance.
|
|
|
|
// If not, set up a new player and return the instance.
|
2013-01-16 20:24:38 -05:00
|
|
|
return tag['player'] || new vjs.Player(tag, options, ready);
|
2012-12-30 21:45:50 -08:00
|
|
|
};
|
2011-11-29 11:40:05 -08:00
|
|
|
|
2013-01-10 13:06:12 -08:00
|
|
|
// Extended name, also available externally, window.videojs
|
2013-01-04 16:58:23 -08:00
|
|
|
var videojs = vjs;
|
2013-04-22 11:32:17 -04:00
|
|
|
window.videojs = window.vjs = vjs;
|
2012-01-14 18:13:13 -08:00
|
|
|
|
|
|
|
// CDN Version. Used to target right flash swf.
|
2013-01-18 16:54:45 -08:00
|
|
|
vjs.CDN_VERSION = 'GENERATED_CDN_VSN';
|
|
|
|
vjs.ACCESS_PROTOCOL = ('https:' == document.location.protocol ? 'https://' : 'http://');
|
2011-11-29 11:40:05 -08:00
|
|
|
|
2012-12-30 21:45:50 -08:00
|
|
|
/**
|
2013-01-21 16:19:46 -08:00
|
|
|
* Global Player instance options, surfaced from vjs.Player.prototype.options_
|
|
|
|
* vjs.options = vjs.Player.prototype.options_
|
|
|
|
* All options should use string keys so they avoid
|
|
|
|
* renaming by closure compiler
|
2012-12-30 21:45:50 -08:00
|
|
|
* @type {Object}
|
|
|
|
*/
|
2013-01-04 16:58:23 -08:00
|
|
|
vjs.options = {
|
2011-11-29 11:40:05 -08:00
|
|
|
// Default order of fallback technology
|
2013-01-10 13:06:12 -08:00
|
|
|
'techOrder': ['html5','flash'],
|
|
|
|
// techOrder: ['flash','html5'],
|
2011-12-07 21:03:12 -08:00
|
|
|
|
2013-01-04 16:58:23 -08:00
|
|
|
'html5': {},
|
2013-05-23 13:10:29 -07:00
|
|
|
'flash': {},
|
2011-11-29 11:40:05 -08:00
|
|
|
|
2013-03-07 23:21:08 +02:00
|
|
|
// Default of web browser is 300x150. Should rely on source width/height.
|
|
|
|
'width': 300,
|
|
|
|
'height': 150,
|
2011-12-01 15:47:12 -08:00
|
|
|
// defaultVolume: 0.85,
|
2013-01-04 16:58:23 -08:00
|
|
|
'defaultVolume': 0.00, // The freakin seaguls are driving me crazy!
|
2011-11-29 11:40:05 -08:00
|
|
|
|
|
|
|
// Included control sets
|
2013-01-04 16:58:23 -08:00
|
|
|
'children': {
|
2013-01-10 13:06:12 -08:00
|
|
|
'mediaLoader': {},
|
|
|
|
'posterImage': {},
|
|
|
|
'textTrackDisplay': {},
|
|
|
|
'loadingSpinner': {},
|
|
|
|
'bigPlayButton': {},
|
|
|
|
'controlBar': {}
|
2013-08-05 14:19:20 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
// Default message to show when a video cannot be played.
|
2013-08-27 10:26:32 -07:00
|
|
|
'notSupportedMessage': 'Sorry, no compatible source and playback ' +
|
2013-08-05 14:19:20 -04:00
|
|
|
'technology were found for this video. Try using another browser ' +
|
|
|
|
'like <a href="http://bit.ly/ccMUEC">Chrome</a> or download the ' +
|
|
|
|
'latest <a href="http://adobe.ly/mwfN1">Adobe Flash Player</a>.'
|
2011-11-29 11:40:05 -08:00
|
|
|
};
|
|
|
|
|
2013-05-23 13:10:29 -07:00
|
|
|
// Set CDN Version of swf
|
|
|
|
// The added (+) blocks the replace from changing this GENERATED_CDN_VSN string
|
|
|
|
if (vjs.CDN_VERSION !== 'GENERATED'+'_CDN_VSN') {
|
|
|
|
videojs.options['flash']['swf'] = vjs.ACCESS_PROTOCOL + 'vjs.zencdn.net/'+vjs.CDN_VERSION+'/video-js.swf';
|
|
|
|
}
|
|
|
|
|
2012-12-30 21:45:50 -08:00
|
|
|
/**
|
|
|
|
* Global player list
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2013-01-04 16:58:23 -08:00
|
|
|
vjs.players = {};
|