1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

Extracted flash.js. Changed video.js source file to main.js, to avoid confusion.

This commit is contained in:
Steve Heffernan 2010-12-16 13:15:34 -08:00
parent 81aef822db
commit 54308bb616
4 changed files with 77 additions and 76 deletions

View File

@ -2,8 +2,9 @@
# Combines Source Files. In terminal, sh combine_sources.sh
cat src/_begin.js > combined.js
cat src/video.js >> combined.js
cat src/main.js >> combined.js
cat src/html5.js >> combined.js
cat src/flash.js >> combined.js
cat src/behaviors.js >> combined.js
cat src/lib.js >> combined.js
cat src/video-js.jquery.js >> combined.js

74
dev/src/flash.js Normal file
View File

@ -0,0 +1,74 @@
/* Flash Player Type
================================================================================ */
VideoJS.fn.extend({
flashSupported: function(){
if (!this.flashElement) { this.flashElement = this.getFlashElement(); }
// Check if object exists & Flash Player version is supported
return !!(this.flashElement && this.flashPlayerVersionSupported());
},
flashInit: function(){
this.replaceWithFlash();
this.element = this.flashElement;
this.video.src = ""; // Stop video from downloading if HTML5 is still supported
var flashPlayerType = VideoJS.flashPlayers[this.options.flashPlayer];
this.extend(flashPlayerType.api);
(flashPlayerType.init.context(this))();
},
// Get Flash Fallback object element from Embed Code
getFlashElement: function(){
var children = this.video.children;
for (var i=0,j=children.length; i<j; i++) {
if (children[i].className == "vjs-flash-fallback") {
return children[i];
}
}
},
// Used to force a browser to fall back when it's an HTML5 browser but there's no supported sources
replaceWithFlash: function(){
// this.flashElement = this.video.removeChild(this.flashElement);
if (this.flashElement) {
this.box.insertBefore(this.flashElement, this.video);
this.video.style.display = "none"; // Removing it was breaking later players
}
},
// Check if browser can use this flash player
flashPlayerVersionSupported: function(){
var playerVersion = (this.options.flashPlayerVersion) ? this.options.flashPlayerVersion : VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion;
return VideoJS.getFlashVersion() >= playerVersion;
}
});
/* Flash Object Fallback (Flash Player Type)
================================================================================ */
VideoJS.flashPlayers = {};
VideoJS.flashPlayers.htmlObject = {
flashPlayerVersion: 9,
init: function() { return true; },
api: { // No video API available with HTML Object embed method
width: function(width){
if (width !== undefined) {
this.element.width = width;
this.box.style.width = width+"px";
this.triggerResizeListeners();
return this;
}
return this.element.width;
},
height: function(height){
if (height !== undefined) {
this.element.height = height;
this.box.style.height = height+"px";
this.triggerResizeListeners();
return this;
}
return this.element.height;
}
}
};

View File

@ -1,6 +1,7 @@
/* HTML5 Player Type
================================================================================ */
VideoJS.fn.extend({
html5Supported: function(){
if (VideoJS.browserSupportsVideo() && this.canPlaySource()) {
return true;

View File

@ -141,81 +141,6 @@ var VideoJS = JRClass.extend({
VideoJS.fn = VideoJS.prototype;
VideoJS.options = {}; // Globally set options
////////////////////////////////////////////////////////////////////////////////
// Player Types
////////////////////////////////////////////////////////////////////////////////
/* Flash Object Fallback (Player Type)
================================================================================ */
VideoJS.fn.extend({
flashSupported: function(){
if (!this.flashElement) { this.flashElement = this.getFlashElement(); }
// Check if object exists & Flash Player version is supported
if (this.flashElement && this.flashPlayerVersionSupported()) {
return true;
} else {
return false;
}
},
flashInit: function(){
this.replaceWithFlash();
this.element = this.flashElement;
this.video.src = ""; // Stop video from downloading if HTML5 is still supported
var flashPlayerType = VideoJS.flashPlayers[this.options.flashPlayer];
this.extend(flashPlayerType.api);
(flashPlayerType.init.context(this))();
},
// Get Flash Fallback object element from Embed Code
getFlashElement: function(){
var children = this.video.children;
for (var i=0,j=children.length; i<j; i++) {
if (children[i].className == "vjs-flash-fallback") {
return children[i];
}
}
},
// Used to force a browser to fall back when it's an HTML5 browser but there's no supported sources
replaceWithFlash: function(){
// this.flashElement = this.video.removeChild(this.flashElement);
if (this.flashElement) {
this.box.insertBefore(this.flashElement, this.video);
this.video.style.display = "none"; // Removing it was breaking later players
}
},
// Check if browser can use this flash player
flashPlayerVersionSupported: function(){
var playerVersion = (this.options.flashPlayerVersion) ? this.options.flashPlayerVersion : VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion;
return VideoJS.getFlashVersion() >= playerVersion;
}
});
VideoJS.flashPlayers = {};
VideoJS.flashPlayers.htmlObject = {
flashPlayerVersion: 9,
init: function() { return true; },
api: { // No video API available with HTML Object embed method
width: function(width){
if (width !== undefined) {
this.element.width = width;
this.box.style.width = width+"px";
this.triggerResizeListeners();
return this;
}
return this.element.width;
},
height: function(height){
if (height !== undefined) {
this.element.height = height;
this.box.style.height = height+"px";
this.triggerResizeListeners();
return this;
}
return this.element.height;
}
}
};
/* Download Links Fallback (Player Type)
================================================================================ */
VideoJS.fn.extend({