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-12 22:23:22 -08:00
|
|
|
goog.provide('vjs');
|
|
|
|
goog.provide('videojs');
|
|
|
|
|
2013-01-10 13:06:12 -08:00
|
|
|
// HTML5 Shiv. Must be in <head> to support older browsers.
|
|
|
|
document.createElement('video');document.createElement('audio');
|
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
|
|
|
|
*/
|
|
|
|
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;
|
2012-01-14 18:13:13 -08:00
|
|
|
|
|
|
|
// CDN Version. Used to target right flash swf.
|
2013-01-10 13:06:12 -08:00
|
|
|
var CDN_VERSION = 'GENERATED_CDN_VSN';
|
2011-11-29 11:40:05 -08:00
|
|
|
|
2012-12-30 21:45:50 -08:00
|
|
|
/**
|
|
|
|
* Global Player instance options
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2013-01-04 16:58:23 -08:00
|
|
|
// var vjs = videojs;
|
|
|
|
|
|
|
|
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-01-10 13:06:12 -08:00
|
|
|
'flash': { swf: 'http://vjs.zencdn.net/c/video-js.swf' },
|
2011-11-29 11:40:05 -08:00
|
|
|
|
|
|
|
// Default of web browser is 300x150. Should rely on source width/height.
|
2013-01-04 16:58:23 -08:00
|
|
|
'width': 300,
|
|
|
|
'height': 150,
|
2012-04-06 16:42:09 -07:00
|
|
|
|
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': {}
|
2012-01-27 15:04:25 -08:00
|
|
|
}
|
2011-11-29 11:40:05 -08:00
|
|
|
};
|
|
|
|
|
2012-12-30 21:45:50 -08:00
|
|
|
/**
|
|
|
|
* Global player list
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2013-01-04 16:58:23 -08:00
|
|
|
vjs.players = {};
|
2012-12-30 21:45:50 -08:00
|
|
|
|
|
|
|
|
2012-01-13 09:26:18 -08:00
|
|
|
// Set CDN Version of swf
|
2013-01-10 13:06:12 -08:00
|
|
|
if (CDN_VERSION != 'GENERATED_CDN_VSN') {
|
|
|
|
videojs.options['flash']['swf'] = 'http://vjs.zencdn.net/'+CDN_VERSION+'/video-js.swf';
|
2012-12-30 21:45:50 -08:00
|
|
|
}
|