1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-13 10:32:26 +02:00

Created a jQuery plugin.

Added the ability to make Flash dominant over HTML5 video.
This commit is contained in:
Steve Heffernan 2010-09-09 19:23:57 -07:00
parent 07019598f1
commit 20b33afa10
2 changed files with 25 additions and 9 deletions

View File

@ -107,7 +107,8 @@ Set options when setting up the videos. The defaults are shown here.
controlsHiding: true, // Hide controls when mouse is not over the video controlsHiding: true, // Hide controls when mouse is not over the video
defaultVolume: 0.85, // Will be overridden by user's last volume if available defaultVolume: 0.85, // Will be overridden by user's last volume if available
flashVersion: 9, // Required flash version for fallback flashVersion: 9, // Required flash version for fallback
linksHiding: true // Hide download links when video is supported linksHiding: true, // Hide download links when video is supported
flashIsDominant: false // Always use Flash when available
}); });
### Or as the second option of VideoJS.setup ### Or as the second option of VideoJS.setup

View File

@ -25,9 +25,6 @@ var VideoJS = JRClass.extend({
// element: video tag // element: video tag
init: function(element, setOptions){ init: function(element, setOptions){
// Hide default controls
this.video.controls = false;
// Allow an ID string or an element // Allow an ID string or an element
if (typeof element == 'string') { if (typeof element == 'string') {
this.video = document.getElementById(element); this.video = document.getElementById(element);
@ -35,6 +32,9 @@ var VideoJS = JRClass.extend({
this.video = element; this.video = element;
} }
// Hide default controls
this.video.controls = false;
// Store reference to player on the video element. // Store reference to player on the video element.
// So you can acess the player later: document.getElementById("video_id").player.play(); // So you can acess the player later: document.getElementById("video_id").player.play();
this.video.player = this; this.video.player = this;
@ -45,7 +45,8 @@ var VideoJS = JRClass.extend({
controlsHiding: true, // Hide controls when not over the video controlsHiding: true, // Hide controls when not over the video
defaultVolume: 0.85, // Will be overridden by localStorage volume if available defaultVolume: 0.85, // Will be overridden by localStorage volume if available
flashVersion: 9, // Required flash version for fallback flashVersion: 9, // Required flash version for fallback
linksHiding: true // Hide download links when video is supported linksHiding: true, // Hide download links when video is supported
flashIsDominant: false // Always use Flash when available
}; };
// Override default options with global options // Override default options with global options
@ -65,8 +66,8 @@ var VideoJS = JRClass.extend({
// Check if browser can play HTML5 video // Check if browser can play HTML5 video
if (VideoJS.browserSupportsVideo()) { if (VideoJS.browserSupportsVideo()) {
// Force flash fallback when there's no supported source // Force flash fallback when there's no supported source, or flash is dominant
if (this.canPlaySource() == false) { if (this.canPlaySource() == false || this.options.flashIsDominant) {
this.replaceWithFlash(); this.replaceWithFlash();
return; return;
} }
@ -830,7 +831,7 @@ var VideoJS = JRClass.extend({
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Convenience Functions (mini library) // Convenience Functions (mini library)
// Functions not specific to video or VideoJS and could be replaced with a library like jQuery // Functions not specific to video or VideoJS and could probably be replaced with a library like jQuery
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var _V_ = { var _V_ = {
addClass: function(element, classToAdd){ addClass: function(element, classToAdd){
@ -976,7 +977,7 @@ VideoJS.setup = function(videos, options){
videos = VideoJS.getVideoJSTags(); videos = VideoJS.getVideoJSTags();
// If videos is not an array, add to an array // If videos is not an array, add to an array
} else if (typeof videos != 'object') { } else if (typeof videos != 'object' || videos.nodeType == 1) {
videos = [videos]; videos = [videos];
returnSingular = true; returnSingular = true;
} }
@ -1049,3 +1050,17 @@ Function.prototype.context = function(obj) {
} }
return temp return temp
} }
// jQuery Plugin
if (window.jQuery) {
(function($) {
$.fn.VideoJS = function(options) {
this.each(function() {
VideoJS.setup(this, options);
});
return this;
};
})(jQuery);
}