Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit tech 'features' from 'MediaTechController' #1412

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/control-bar/mute-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/js/control-bar/playback-rate-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down
4 changes: 2 additions & 2 deletions src/js/control-bar/volume-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/js/control-bar/volume-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 4 additions & 5 deletions src/js/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
10 changes: 5 additions & 5 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

vjs.MediaTechController.call(this, player, options, ready);
this.setupTriggers();
Expand Down Expand Up @@ -72,7 +72,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) {
Expand Down
19 changes: 9 additions & 10 deletions src/js/media/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vjs.MediaTechController = vjs.Component.extend({
/** @constructor */
init: function(player, options, ready){
options = options || {};

// we don't want the tech to report user activity automatically.
// This is done manually in addControlsListeners
options.reportTouchActivity = false;
Expand Down Expand Up @@ -161,17 +162,15 @@ vjs.MediaTechController.prototype.onTap = function(){
*/
vjs.MediaTechController.prototype.setPoster = function(){};

vjs.MediaTechController.prototype.features = {
'volumeControl': true,
vjs.MediaTechController.prototype[ 'volumeControl' ] = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept these as strings for now, but I can change it.


// Resizing plugins using request fullscreen reloads the plugin
'fullscreenResize': false,
'playbackRate': false,
// Resizing plugins using request fullscreen reloads the plugin
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
};
// Optional events that we can manually mimic with timers
// currently not triggered by video-js-swf
vjs.MediaTechController.prototype[ 'progressEvents' ] = false;
vjs.MediaTechController.prototype[ 'timeupdateEvents' ] = false;

vjs.media = {};
10 changes: 5 additions & 5 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ vjs.Player.prototype.loadTech = function(techName, source){
this.player_.triggerReady();

// Manually track progress in cases where the browser/flash player doesn't report it.
if (!this.features['progressEvents']) {
if (!this['progressEvents']) {
this.player_.manualProgressOn();
}

// Manually track timeudpates in cases where the browser/flash player doesn't report it.
if (!this.features['timeupdateEvents']) {
if (!this['timeupdateEvents']) {
this.player_.manualTimeUpdatesOn();
}
};
Expand Down Expand Up @@ -386,7 +386,7 @@ vjs.Player.prototype.manualProgressOn = function(){
this.tech.one('progress', function(){

// Update known progress support for this playback technology
this.features['progressEvents'] = true;
this['progressEvents'] = true;

// Turn off manual progress tracking
this.player_.manualProgressOff();
Expand Down Expand Up @@ -431,7 +431,7 @@ vjs.Player.prototype.manualTimeUpdatesOn = function(){
if (this.tech) {
this.tech.one('timeupdate', function(){
// Update known progress support for this playback technology
this.features['timeupdateEvents'] = true;
this['timeupdateEvents'] = true;
// Turn off manual progress tracking
this.player_.manualTimeUpdatesOff();
});
Expand Down Expand Up @@ -1641,7 +1641,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;
Expand Down