1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-23 12:19:08 +02:00
video.js/src/core.js

90 lines
2.1 KiB
JavaScript
Raw Normal View History

// HTML5 Shiv. Must be in <head> to support older browsers.
document.createElement("video");document.createElement("audio");
goog.provide('_V_');
var _V_ = function(id, options, ready){
2011-11-30 11:53:08 -08:00
var tag; // Element of ID
// 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.
if (_V_.players[id]) {
return _V_.players[id];
// Otherwise get element for ID
} else {
tag = _V_.el(id)
}
// 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
2011-11-30 11:53:08 -08:00
throw new TypeError("The element or ID supplied is not valid. (VideoJS)"); // Returns
}
// Element may have a player attr referring to an already created player instance.
// If not, set up a new player and return the instance.
return tag.player || new _V_.Player(tag, options, ready);
};
// Shortcut
VideoJS = _V_;
// CDN Version. Used to target right flash swf.
CDN_VERSION = "GENERATED_CDN_VSN";
/**
* Global Player instance options
* @type {Object}
*/
_V_.options = {
// Default order of fallback technology
techOrder: ["html5","flash"],
// techOrder: ["flash","html5"],
html5: {},
2012-01-27 15:04:25 -08:00
flash: { swf: "http://vjs.zencdn.net/c/video-js.swf" },
// Default of web browser is 300x150. Should rely on source width/height.
2012-04-06 16:42:09 -07:00
width: 300,
height: 150,
// defaultVolume: 0.85,
defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
// Included control sets
// TODO: just use uppercase Class name
children: {
"mediaLoader": {},
"posterImage": {},
// "textTrackDisplay": {},
2012-01-27 15:04:25 -08:00
"loadingSpinner": {},
"bigPlayButton": {},
"controlBar": {}
2012-01-27 15:04:25 -08:00
}
};
/**
* Global player list
* @type {Object}
*/
_V_.players = {};
// Set CDN Version of swf
if (CDN_VERSION != "GENERATED_CDN_VSN") {
_V_.options.flash.swf = "http://vjs.zencdn.net/"+CDN_VERSION+"/video-js.swf"
}