mirror of
https://github.com/videojs/video.js.git
synced 2025-07-15 01:34:23 +02:00
Promote 'features' to the prototype
This commit is contained in:
@ -13,11 +13,11 @@ vjs.MuteToggle = vjs.Button.extend({
|
||||
player.on('volumechange', vjs.bind(this, this.update));
|
||||
|
||||
// hide mute toggle if the current tech doesn't support volume control
|
||||
if (player.tech && player.tech.features && player.tech.features['volumeControl'] === false) {
|
||||
if (player.tech && player.tech['volumeControl'] === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
}
|
||||
player.on('loadstart', vjs.bind(this, function(){
|
||||
if (player.tech.features && player.tech.features['volumeControl'] === false) {
|
||||
if (player.tech['volumeControl'] === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
} else {
|
||||
this.removeClass('vjs-hidden');
|
||||
|
@ -72,7 +72,7 @@ vjs.PlaybackRateMenuButton.prototype.onClick = function(){
|
||||
|
||||
vjs.PlaybackRateMenuButton.prototype.playbackRateSupported = function(){
|
||||
return this.player().tech
|
||||
&& this.player().tech.features['playbackRate']
|
||||
&& this.player().tech['playbackRate']
|
||||
&& this.player().options()['playbackRates']
|
||||
&& this.player().options()['playbackRates'].length > 0
|
||||
;
|
||||
|
@ -11,11 +11,11 @@ vjs.VolumeControl = vjs.Component.extend({
|
||||
vjs.Component.call(this, player, options);
|
||||
|
||||
// hide volume controls when they're not supported by the current tech
|
||||
if (player.tech && player.tech.features && player.tech.features['volumeControl'] === false) {
|
||||
if (player.tech && player.tech['volumeControl'] === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
}
|
||||
player.on('loadstart', vjs.bind(this, function(){
|
||||
if (player.tech.features && player.tech.features['volumeControl'] === false) {
|
||||
if (player.tech['volumeControl'] === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
} else {
|
||||
this.removeClass('vjs-hidden');
|
||||
|
@ -11,11 +11,11 @@ vjs.VolumeMenuButton = vjs.MenuButton.extend({
|
||||
player.on('volumechange', vjs.bind(this, this.update));
|
||||
|
||||
// hide mute toggle if the current tech doesn't support volume control
|
||||
if (player.tech && player.tech.features && player.tech.features.volumeControl === false) {
|
||||
if (player.tech && player.tech.volumeControl === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
}
|
||||
player.on('loadstart', vjs.bind(this, function(){
|
||||
if (player.tech.features && player.tech.features.volumeControl === false) {
|
||||
if (player.tech.volumeControl === false) {
|
||||
this.addClass('vjs-hidden');
|
||||
} else {
|
||||
this.removeClass('vjs-hidden');
|
||||
|
@ -121,11 +121,10 @@ goog.exportSymbol('videojs.CaptionsButton', vjs.CaptionsButton);
|
||||
goog.exportSymbol('videojs.ChaptersButton', vjs.ChaptersButton);
|
||||
|
||||
goog.exportSymbol('videojs.MediaTechController', vjs.MediaTechController);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'features', vjs.MediaTechController.prototype.features);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype.features, 'volumeControl', vjs.MediaTechController.prototype.features.volumeControl);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype.features, 'fullscreenResize', vjs.MediaTechController.prototype.features.fullscreenResize);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype.features, 'progressEvents', vjs.MediaTechController.prototype.features.progressEvents);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype.features, 'timeupdateEvents', vjs.MediaTechController.prototype.features.timeupdateEvents);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'volumeControl', vjs.MediaTechController.prototype.volumeControl);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'fullscreenResize', vjs.MediaTechController.prototype.fullscreenResize);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'progressEvents', vjs.MediaTechController.prototype.progressEvents);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'timeupdateEvents', vjs.MediaTechController.prototype.timeupdateEvents);
|
||||
goog.exportProperty(vjs.MediaTechController.prototype, 'setPoster', vjs.MediaTechController.prototype.setPoster);
|
||||
|
||||
|
||||
|
@ -13,16 +13,16 @@ vjs.Html5 = vjs.MediaTechController.extend({
|
||||
/** @constructor */
|
||||
init: function(player, options, ready){
|
||||
// volume cannot be changed from 1 on iOS
|
||||
this.features['volumeControl'] = vjs.Html5.canControlVolume();
|
||||
this['volumeControl'] = vjs.Html5.canControlVolume();
|
||||
|
||||
// just in case; or is it excessively...
|
||||
this.features['playbackRate'] = vjs.Html5.canControlPlaybackRate();
|
||||
this['playbackRate'] = vjs.Html5.canControlPlaybackRate();
|
||||
|
||||
// In iOS, if you move a video element in the DOM, it breaks video playback.
|
||||
this.features['movingMediaElementInDOM'] = !vjs.IS_IOS;
|
||||
this['movingMediaElementInDOM'] = !vjs.IS_IOS;
|
||||
|
||||
// HTML video is able to automatically resize when going to fullscreen
|
||||
this.features['fullscreenResize'] = true;
|
||||
this['fullscreenResize'] = true;
|
||||
|
||||
// HTML video supports progress events
|
||||
this.features['progressEvents'] = true;
|
||||
@ -75,7 +75,7 @@ vjs.Html5.prototype.createEl = function(){
|
||||
// Check if this browser supports moving the element into the box.
|
||||
// On the iPhone video will break if you move the element,
|
||||
// So we have to create a brand new element.
|
||||
if (!el || this.features['movingMediaElementInDOM'] === false) {
|
||||
if (!el || this['movingMediaElementInDOM'] === false) {
|
||||
|
||||
// If the original tag is still there, clone and remove it.
|
||||
if (el) {
|
||||
|
@ -14,10 +14,6 @@ vjs.MediaTechController = vjs.Component.extend({
|
||||
init: function(player, options, ready){
|
||||
options = options || {};
|
||||
|
||||
// Make sure that `this.features` isn't directly tied to `vjs.MediaTechController.prototype.features`
|
||||
// Using `vjs.obj.create` allows us to receive default updates from the prototype if we haven't changed the value.
|
||||
this.features = vjs.obj.create(vjs.MediaTechController.prototype.features);
|
||||
|
||||
// we don't want the tech to report user activity automatically.
|
||||
// This is done manually in addControlsListeners
|
||||
options.reportTouchActivity = false;
|
||||
@ -266,17 +262,15 @@ vjs.MediaTechController.prototype.setCurrentTime = function() {
|
||||
*/
|
||||
vjs.MediaTechController.prototype.setPoster = function(){};
|
||||
|
||||
vjs.MediaTechController.prototype.features = {
|
||||
'volumeControl': true,
|
||||
vjs.MediaTechController.prototype[ 'volumeControl' ] = true;
|
||||
|
||||
// Resizing plugins using request fullscreen reloads the plugin
|
||||
'fullscreenResize': false,
|
||||
'playbackRate': false,
|
||||
vjs.MediaTechController.prototype[ 'fullscreenResize' ] = false;
|
||||
vjs.MediaTechController.prototype[ 'playbackRate' ] = false;
|
||||
|
||||
// Optional events that we can manually mimic with timers
|
||||
// currently not triggered by video-js-swf
|
||||
'progressEvents': false,
|
||||
'timeupdateEvents': false
|
||||
};
|
||||
vjs.MediaTechController.prototype[ 'progressEvents' ] = false;
|
||||
vjs.MediaTechController.prototype[ 'timeupdateEvents' ] = false;
|
||||
|
||||
vjs.media = {};
|
||||
|
@ -349,7 +349,6 @@ vjs.Player.prototype.unloadTech = function(){
|
||||
// vjs.log('loadedTech')
|
||||
// },
|
||||
|
||||
|
||||
// /* Player event handlers (how the player reacts to certain events)
|
||||
// ================================================================================ */
|
||||
|
||||
@ -1531,7 +1530,7 @@ vjs.Player.prototype.playbackRate = function(rate) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.tech && this.tech.features && this.tech.features['playbackRate']) {
|
||||
if (this.tech && this.tech['playbackRate']) {
|
||||
return this.techGet('playbackRate');
|
||||
} else {
|
||||
return 1.0;
|
||||
|
Reference in New Issue
Block a user