Skip to content

Commit

Permalink
Extracted flash.js. Changed video.js source file to main.js, to avoid…
Browse files Browse the repository at this point in the history
… confusion.
  • Loading branch information
heff committed Dec 16, 2010
1 parent 81aef82 commit 54308bb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 76 deletions.
3 changes: 2 additions & 1 deletion dev/combine_sources.sh
Expand Up @@ -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
Expand Down
74 changes: 74 additions & 0 deletions dev/src/flash.js
@@ -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;
}
}
};
1 change: 1 addition & 0 deletions dev/src/html5.js
@@ -1,6 +1,7 @@
/* HTML5 Player Type
================================================================================ */
VideoJS.fn.extend({

html5Supported: function(){
if (VideoJS.browserSupportsVideo() && this.canPlaySource()) {
return true;
Expand Down
75 changes: 0 additions & 75 deletions dev/src/video.js → dev/src/main.js
Expand Up @@ -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({
Expand Down

0 comments on commit 54308bb

Please sign in to comment.