1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-25 11:13:52 +02:00

Merge branch 'media-tech-features2' of github.com:gkatsev/video.js into gkatsev-media-tech-features2

This commit is contained in:
Steve Heffernan 2014-09-02 16:11:26 -07:00
commit c90d7d36f6
11 changed files with 39 additions and 47 deletions

View File

@ -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['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
}
player.on('loadstart', vjs.bind(this, function(){
if (player.tech.features && player.tech.features['volumeControl'] === false) {
if (player.tech['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');

View File

@ -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['playbackRateFeature']
&& this.player().options()['playbackRates']
&& this.player().options()['playbackRates'].length > 0
;

View File

@ -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['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
}
player.on('loadstart', vjs.bind(this, function(){
if (player.tech.features && player.tech.features['volumeControl'] === false) {
if (player.tech['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');

View File

@ -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['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
}
player.on('loadstart', vjs.bind(this, function(){
if (player.tech.features && player.tech.features.volumeControl === false) {
if (player.tech['volumeControlFeature'] === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');

View File

@ -121,11 +121,11 @@ 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, 'volumeControlFeature', vjs.MediaTechController.prototype.volumeControlFeature);
goog.exportProperty(vjs.MediaTechController.prototype, 'fullscreenResizeFeature', vjs.MediaTechController.prototype.fullscreenResizeFeature);
goog.exportProperty(vjs.MediaTechController.prototype, 'playbackRateFeature', vjs.MediaTechController.prototype.playbackRateFeature);
goog.exportProperty(vjs.MediaTechController.prototype, 'progressEventsFeature', vjs.MediaTechController.prototype.progressEventsFeature);
goog.exportProperty(vjs.MediaTechController.prototype, 'timeupdateEventsFeature', vjs.MediaTechController.prototype.timeupdateEventsFeature);
goog.exportProperty(vjs.MediaTechController.prototype, 'setPoster', vjs.MediaTechController.prototype.setPoster);
@ -173,4 +173,4 @@ goog.exportSymbol('videojs.createTimeRange', vjs.createTimeRange);
goog.exportSymbol('videojs.util', vjs.util);
goog.exportProperty(vjs.util, 'mergeOptions', vjs.util.mergeOptions);
goog.exportProperty(vjs, 'addLanguage', vjs.addLanguage);
goog.exportProperty(vjs, 'addLanguage', vjs.addLanguage);

View File

@ -13,19 +13,19 @@ 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['volumeControlFeature'] = vjs.Html5.canControlVolume();
// just in case; or is it excessively...
this.features['playbackRate'] = vjs.Html5.canControlPlaybackRate();
this['playbackRateFeature'] = 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['fullscreenResizeFeature'] = true;
// HTML video supports progress events
this.features['progressEvents'] = true;
this['progressEventsFeature'] = true;
vjs.MediaTechController.call(this, player, options, ready);
this.setupTriggers();
@ -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) {

View File

@ -19,12 +19,12 @@ vjs.MediaTechController = vjs.Component.extend({
vjs.Component.call(this, player, options, ready);
// Manually track progress in cases where the browser/flash player doesn't report it.
if (!this.features['progressEvents']) {
if (!this['progressEventsFeature']) {
this.manualProgressOn();
}
// Manually track timeudpates in cases where the browser/flash player doesn't report it.
if (!this.features['timeupdateEvents']) {
if (!this['timeupdateEventsFeature']) {
this.manualTimeUpdatesOn();
}
@ -210,7 +210,7 @@ vjs.MediaTechController.prototype.manualTimeUpdatesOn = function(){
// Watch for native timeupdate event
this.one('timeupdate', function(){
// Update known progress support for this playback technology
this.features['timeupdateEvents'] = true;
this['timeupdateEventsFeature'] = true;
// Turn off manual progress tracking
this.manualTimeUpdatesOff();
});
@ -261,17 +261,15 @@ vjs.MediaTechController.prototype.setCurrentTime = function() {
*/
vjs.MediaTechController.prototype.setPoster = function(){};
vjs.MediaTechController.prototype.features = {
'volumeControl': true,
vjs.MediaTechController.prototype['volumeControlFeature'] = true;
// Resizing plugins using request fullscreen reloads the plugin
'fullscreenResize': false,
'playbackRate': false,
// Resizing plugins using request fullscreen reloads the plugin
vjs.MediaTechController.prototype['fullscreenResizeFeature'] = false;
vjs.MediaTechController.prototype['playbackRateFeature'] = 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['progressEventsFeature'] = false;
vjs.MediaTechController.prototype['timeupdateEventsFeature'] = false;
vjs.media = {};

View File

@ -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['playbackRateFeature']) {
return this.techGet('playbackRate');
} else {
return 1.0;

12
test/unit/controls.js vendored
View File

@ -12,9 +12,7 @@ test('should hide volume control if it\'s not supported', function(){
language: noop,
languages: noop,
tech: {
features: {
'volumeControl': false
}
'volumeControlFeature': false
},
volume: function(){},
muted: function(){},
@ -47,9 +45,7 @@ test('should test and toggle volume control on `loadstart`', function(){
return false;
},
tech: {
features: {
'volumeControl': true
}
'volumeControlFeature': true
},
reportUserActivity: function(){}
};
@ -62,7 +58,7 @@ test('should test and toggle volume control on `loadstart`', function(){
ok(muteToggle.el().className.indexOf('vjs-hidden') < 0,
'muteToggle is hidden initially');
player.tech.features['volumeControl'] = false;
player.tech['volumeControlFeature'] = false;
for (i = 0; i < listeners.length; i++) {
listeners[i]();
}
@ -72,7 +68,7 @@ test('should test and toggle volume control on `loadstart`', function(){
ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0,
'muteToggle does not hide itself');
player.tech.features['volumeControl'] = true;
player.tech['volumeControlFeature'] = true;
for (i = 0; i < listeners.length; i++) {
listeners[i]();
}

View File

@ -1,14 +1,14 @@
var noop = function() {}, clock, features;
var noop = function() {}, clock, progessEventsFeature;
module('Media Tech', {
'setup': function() {
clock = sinon.useFakeTimers();
features = videojs.util.mergeOptions({}, videojs.MediaTechController.prototype.features);
videojs.MediaTechController.prototype.features['progressEvents'] = false;
progessEventsFeature = videojs.MediaTechController.prototype['progessEventsFeature'];
videojs.MediaTechController.prototype['progressEventsFeature'] = false;
},
'teardown': function() {
clock.restore();
videojs.MediaTechController.prototype.features = features;
videojs.MediaTechController.prototype['progessEventsFeature'] = progessEventsFeature;
}
});

View File

@ -42,7 +42,6 @@ vjs.MediaFaker.prototype.muted = function(){ return false; };
vjs.MediaFaker.prototype.pause = function(){ return false; };
vjs.MediaFaker.prototype.paused = function(){ return true; };
vjs.MediaFaker.prototype.supportsFullScreen = function(){ return false; };
vjs.MediaFaker.prototype.features = {};
vjs.MediaFaker.prototype.buffered = function(){ return {}; };
vjs.MediaFaker.prototype.duration = function(){ return {}; };