2011-11-29 11:40:05 -08:00
|
|
|
// HTML5 Shiv. Must be in <head> to support older browsers.
|
|
|
|
document.createElement("video");document.createElement("audio");
|
|
|
|
|
2013-01-04 16:58:23 -08:00
|
|
|
goog.provide('vjs');
|
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
|
|
|
|
if (typeof id == "string") {
|
|
|
|
|
|
|
|
// Adjust for jQuery ID syntax
|
|
|
|
if (id.indexOf("#") === 0) {
|
|
|
|
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-04 16:58:23 -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-04 16:58:23 -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-04 16:58:23 -08: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
|
|
|
|
|
|
|
// Shortcut
|
2013-01-04 16:58:23 -08:00
|
|
|
var videojs = vjs;
|
|
|
|
// videojs = vjs;
|
2012-01-14 18:13:13 -08:00
|
|
|
|
|
|
|
// CDN Version. Used to target right flash swf.
|
|
|
|
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-04 16:58:23 -08:00
|
|
|
'techOrder': ["html5","flash"],
|
2011-12-07 21:29:21 -08:00
|
|
|
// techOrder: ["flash","html5"],
|
2011-12-07 21:03:12 -08:00
|
|
|
|
2013-01-04 16:58:23 -08:00
|
|
|
'html5': {},
|
|
|
|
'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
|
2012-12-30 21:45:50 -08:00
|
|
|
// TODO: just use uppercase Class name
|
2013-01-04 16:58:23 -08:00
|
|
|
'children': {
|
2012-12-30 21:45:50 -08:00
|
|
|
"mediaLoader": {},
|
2012-03-19 15:50:05 -07:00
|
|
|
"posterImage": {},
|
2013-01-04 16:58:23 -08:00
|
|
|
// "textTrackDisplay": {},
|
2012-01-27 15:04:25 -08:00
|
|
|
"loadingSpinner": {},
|
|
|
|
"bigPlayButton": {},
|
2012-03-09 17:12:38 -08:00
|
|
|
"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
|
|
|
|
if (CDN_VERSION != "GENERATED_CDN_VSN") {
|
2013-01-04 16:58:23 -08:00
|
|
|
vjs.options.Flash.swf = "http://vjs.zencdn.net/"+CDN_VERSION+"/video-js.swf"
|
2012-12-30 21:45:50 -08:00
|
|
|
}
|