Comparar commits

..

16 Commits

Autor SHA1 Mensagem Data
Jon-Carlos 242abef337 v5.11.6 dist 2016-08-25 23:18:08 +00:00
Jon-Carlos a17de688f3 v5.11.6 2016-08-25 23:17:28 +00:00
Jon-Carlos Rivera fdd8550307 @imbcmdth Added exception handling to event dispatcher. closes #3580
* Guard against exceptions in an event handler to stop them from breaking further processing of event handlers

* Added a test for try/catch behavior for exceptions originating in event handlers
2016-08-25 19:08:56 -04:00
Justin eff1cf34db v5.11.5 2016-08-25 15:49:03 +00:00
Justin Barabander a2167a6b95 @jbarabander updated Audio to Audio Track and added to en.json. closes #3574 2016-08-25 11:01:13 -04:00
Pat O'Neill 1d2d08584e @misteroneill fixed IE8 media error test failure. closes #3568 2016-08-24 13:48:39 -04:00
Justin Barabander 46d713589b @jbarabander added title attribute to audio button. Fixes #3528. closes #3565 2016-08-24 11:30:37 -04:00
David Snyder 23d1fcd882 @snyderizer fixed switching between audio tracks. Fixes #3510. closes #3538 2016-08-24 11:24:55 -04:00
Pat O'Neill b56ed61523 @misteroneill fixed wrapping native and emulated MediaErrors. closes #3562 2016-08-24 11:00:21 -04:00
Gary Katsevman 13d16c1d76 v5.11.4 2016-08-16 14:27:22 -04:00
Gary Katsevman 5178c122a5 v5.11.3 2016-08-15 18:11:54 -04:00
Gary Katsevman db0e821f38 Add DOMException to jshint to appease it 2016-08-15 18:02:41 -04:00
mister-ben fa1c6430f4 @mister-ben silenced chrome's play() request was interrupted by pause() error. closes #3518 2016-08-15 17:49:52 -04:00
Matthew Boles bf2eabf82d @mboles updated duration() method documentation. closes #3515 2016-08-15 17:46:59 -04:00
mister-ben 2f5a0ca48b @mister-ben fixed android treating swipe as a tap. closes #3514 2016-08-15 17:45:38 -04:00
Vineet 2c84f45ff3 @vdeshpande fixed control text for fullscreen button. closes #3485 2016-08-15 17:44:01 -04:00
28 arquivos alterados com 402 adições e 152 exclusões
+2
Ver Arquivo
@@ -24,6 +24,8 @@
"exports",
"process",
"DOMException",
"q",
"asyncTest",
"deepEqual",
+18
Ver Arquivo
@@ -6,6 +6,24 @@ _(none)_
--------------------
## 5.11.6 (2016-08-25)
* @imbcmdth Added exception handling to event dispatcher ([view](https://github.com/videojs/video.js/pull/3580))
## 5.11.5 (2016-08-25)
* @misteroneill fixed wrapping native and emulated MediaErrors ([view](https://github.com/videojs/video.js/pull/3562))
* @snyderizer fixed switching between audio tracks. Fixes #3510 ([view](https://github.com/videojs/video.js/pull/3538))
* @jbarabander added title attribute to audio button. Fixes #3528 ([view](https://github.com/videojs/video.js/pull/3565))
* @misteroneill fixed IE8 media error test failure ([view](https://github.com/videojs/video.js/pull/3568))
## 5.11.4 (2016-08-16)
_(none)_
## 5.11.3 (2016-08-15)
* @vdeshpande fixed control text for fullscreen button ([view](https://github.com/videojs/video.js/pull/3485))
* @mister-ben fixed android treating swipe as a tap ([view](https://github.com/videojs/video.js/pull/3514))
* @mboles updated duration() method documentation ([view](https://github.com/videojs/video.js/pull/3515))
* @mister-ben silenced chrome's play() request was interrupted by pause() error ([view](https://github.com/videojs/video.js/pull/3518))
## 5.11.2 (2016-08-09)
_(none)_
+1 -1
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "5.11.2",
"version": "5.11.6",
"keywords": [
"videojs",
"html5",
+79 -42
Ver Arquivo
@@ -1,6 +1,6 @@
/**
* @license
* Video.js 5.11.2 <http://videojs.com/>
* Video.js 5.11.6 <http://videojs.com/>
* Copyright Brightcove, Inc. <https://www.brightcove.com/>
* Available under Apache License Version 2.0
* <https://github.com/videojs/video.js/blob/master/LICENSE>
@@ -3218,10 +3218,6 @@ var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
var _objectAssign = _dereq_('object.assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
@@ -4446,8 +4442,11 @@ var Component = (function () {
this.on('touchstart', function (event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length === 1) {
// Copy the touches object to prevent modifying the original
firstTouch = _objectAssign2['default']({}, event.touches[0]);
// Copy pageX/pageY from the object
firstTouch = {
pageX: event.touches[0].pageX,
pageY: event.touches[0].pageY
};
// Record start time so we can detect a tap vs. "touch and hold"
touchStart = new Date().getTime();
// Reset couldBeTap tracking
@@ -4743,7 +4742,7 @@ Component.registerComponent('Component', Component);
exports['default'] = Component;
module.exports = exports['default'];
},{"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/to-title-case.js":151,"global/window":2,"object.assign":45}],68:[function(_dereq_,module,exports){
},{"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/to-title-case.js":151,"global/window":2}],68:[function(_dereq_,module,exports){
/**
* @file audio-track-button.js
*/
@@ -4842,6 +4841,7 @@ var AudioTrackButton = (function (_TrackButton) {
return AudioTrackButton;
})(_trackButtonJs2['default']);
AudioTrackButton.prototype.controlText_ = 'Audio Track';
_componentJs2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
exports['default'] = AudioTrackButton;
module.exports = exports['default'];
@@ -4930,9 +4930,7 @@ var AudioTrackMenuItem = (function (_MenuItem) {
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
if (track === this.track) {
track.enabled = true;
}
track.enabled = track === this.track;
}
};
@@ -5120,10 +5118,11 @@ var _componentJs2 = _interopRequireDefault(_componentJs);
var FullscreenToggle = (function (_Button) {
_inherits(FullscreenToggle, _Button);
function FullscreenToggle() {
function FullscreenToggle(player, options) {
_classCallCheck(this, FullscreenToggle);
_Button.apply(this, arguments);
_Button.call(this, player, options);
this.on(player, 'fullscreenchange', this.handleFullscreenChange);
}
/**
@@ -5137,6 +5136,20 @@ var FullscreenToggle = (function (_Button) {
return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* Handles Fullscreenchange on the component and change control text accordingly
*
* @method handleFullscreenChange
*/
FullscreenToggle.prototype.handleFullscreenChange = function handleFullscreenChange() {
if (this.player_.isFullscreen()) {
this.controlText('Non-Fullscreen');
} else {
this.controlText('Fullscreen');
}
};
/**
* Handles click for full screen
*
@@ -5146,10 +5159,8 @@ var FullscreenToggle = (function (_Button) {
FullscreenToggle.prototype.handleClick = function handleClick() {
if (!this.player_.isFullscreen()) {
this.player_.requestFullscreen();
this.controlText('Non-Fullscreen');
} else {
this.player_.exitFullscreen();
this.controlText('Fullscreen');
}
};
@@ -8875,25 +8886,45 @@ var _objectAssign = _dereq_('object.assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
/*
* Custom MediaError to mimic the HTML5 MediaError
* Custom MediaError class which mimics the standard HTML5 MediaError class.
*
* @param {Number} code The media error code
* @param {Number|String|Object|MediaError} value
* This can be of multiple types:
* - Number: should be a standard error code
* - String: an error message (the code will be 0)
* - Object: arbitrary properties
* - MediaError (native): used to populate a video.js MediaError object
* - MediaError (video.js): will return itself if it's already a
* video.js MediaError object.
*/
var MediaError = function MediaError(code) {
if (typeof code === 'number') {
this.code = code;
} else if (typeof code === 'string') {
function MediaError(value) {
// Allow redundant calls to this constructor to avoid having `instanceof`
// checks peppered around the code.
if (value instanceof MediaError) {
return value;
}
if (typeof value === 'number') {
this.code = value;
} else if (typeof value === 'string') {
// default code is zero, so this is a custom error
this.message = code;
} else if (typeof code === 'object') {
// object
_objectAssign2['default'](this, code);
this.message = value;
} else if (typeof value === 'object') {
// We assign the `code` property manually because native MediaError objects
// do not expose it as an own/enumerable property of the object.
if (typeof value.code === 'number') {
this.code = value.code;
}
_objectAssign2['default'](this, value);
}
if (!this.message) {
this.message = MediaError.defaultMessages[this.code] || '';
}
};
}
/*
* The error code that refers two one of the defined
@@ -11569,7 +11600,8 @@ var Player = (function (_Component) {
};
/**
* Get the length in time of the video in seconds
* Normally gets the length in time of the video in seconds;
* in all but the rarest use cases an argument will NOT be passed to the method
* ```js
* var lengthOfVideo = myPlayer.duration();
* ```
@@ -12463,12 +12495,7 @@ var Player = (function (_Component) {
return this;
}
// error instance
if (err instanceof _mediaErrorJs2['default']) {
this.error_ = err;
} else {
this.error_ = new _mediaErrorJs2['default'](err);
}
this.error_ = new _mediaErrorJs2['default'](err);
// add the vjs-error classname to the player
this.addClass('vjs-error');
@@ -15266,7 +15293,13 @@ var Html5 = (function (_Tech) {
*/
Html5.prototype.play = function play() {
this.el_.play();
var playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, function (e) {});
}
};
/**
@@ -16720,11 +16753,7 @@ var Tech = (function (_Component) {
Tech.prototype.error = function error(err) {
if (err !== undefined) {
if (err instanceof _mediaErrorJs2['default']) {
this.error_ = err;
} else {
this.error_ = new _mediaErrorJs2['default'](err);
}
this.error_ = new _mediaErrorJs2['default'](err);
this.trigger('error');
}
return this.error_;
@@ -20703,6 +20732,10 @@ var _guidJs = _dereq_('./guid.js');
var Guid = _interopRequireWildcard(_guidJs);
var _logJs = _dereq_('./log.js');
var _logJs2 = _interopRequireDefault(_logJs);
var _globalWindow = _dereq_('global/window');
var _globalWindow2 = _interopRequireDefault(_globalWindow);
@@ -20757,7 +20790,11 @@ function on(elem, type, fn) {
if (event.isImmediatePropagationStopped()) {
break;
} else {
handlersCopy[m].call(elem, event, hash);
try {
handlersCopy[m].call(elem, event, hash);
} catch (e) {
_logJs2['default'].error(e);
}
}
}
}
@@ -21080,7 +21117,7 @@ function _handleMultipleEvents(fn, elem, types, callback) {
});
}
},{"./dom.js":142,"./guid.js":146,"global/document":1,"global/window":2}],144:[function(_dereq_,module,exports){
},{"./dom.js":142,"./guid.js":146,"./log.js":147,"global/document":1,"global/window":2}],144:[function(_dereq_,module,exports){
/**
* @file fn.js
*/
@@ -21859,7 +21896,7 @@ setup.autoSetupTimeout(1, videojs);
*
* @type {String}
*/
videojs.VERSION = '5.11.2';
videojs.VERSION = '5.11.6';
/**
* The global options object. These are the settings that take effect
+8 -9
Ver Arquivo
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+1
Ver Arquivo
@@ -21,6 +21,7 @@ videojs.addLanguage("en",{
"Close Modal Dialog": "Close Modal Dialog",
"Descriptions": "Descriptions",
"descriptions off": "descriptions off",
"Audio Track": "Audio Track",
"You aborted the media playback": "You aborted the media playback",
"A network error caused the media download to fail part-way.": "A network error caused the media download to fail part-way.",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "The media could not be loaded, either because the server or network failed or because the format is not supported.",
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
+79 -42
Ver Arquivo
@@ -1,6 +1,6 @@
/**
* @license
* Video.js 5.11.2 <http://videojs.com/>
* Video.js 5.11.6 <http://videojs.com/>
* Copyright Brightcove, Inc. <https://www.brightcove.com/>
* Available under Apache License Version 2.0
* <https://github.com/videojs/video.js/blob/master/LICENSE>
@@ -3222,10 +3222,6 @@ var _utilsToTitleCaseJs = _dereq_('./utils/to-title-case.js');
var _utilsToTitleCaseJs2 = _interopRequireDefault(_utilsToTitleCaseJs);
var _objectAssign = _dereq_('object.assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _utilsMergeOptionsJs = _dereq_('./utils/merge-options.js');
var _utilsMergeOptionsJs2 = _interopRequireDefault(_utilsMergeOptionsJs);
@@ -4450,8 +4446,11 @@ var Component = (function () {
this.on('touchstart', function (event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length === 1) {
// Copy the touches object to prevent modifying the original
firstTouch = _objectAssign2['default']({}, event.touches[0]);
// Copy pageX/pageY from the object
firstTouch = {
pageX: event.touches[0].pageX,
pageY: event.touches[0].pageY
};
// Record start time so we can detect a tap vs. "touch and hold"
touchStart = new Date().getTime();
// Reset couldBeTap tracking
@@ -4747,7 +4746,7 @@ Component.registerComponent('Component', Component);
exports['default'] = Component;
module.exports = exports['default'];
},{"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/to-title-case.js":151,"global/window":2,"object.assign":45}],68:[function(_dereq_,module,exports){
},{"./utils/dom.js":142,"./utils/events.js":143,"./utils/fn.js":144,"./utils/guid.js":146,"./utils/log.js":147,"./utils/merge-options.js":148,"./utils/to-title-case.js":151,"global/window":2}],68:[function(_dereq_,module,exports){
/**
* @file audio-track-button.js
*/
@@ -4846,6 +4845,7 @@ var AudioTrackButton = (function (_TrackButton) {
return AudioTrackButton;
})(_trackButtonJs2['default']);
AudioTrackButton.prototype.controlText_ = 'Audio Track';
_componentJs2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
exports['default'] = AudioTrackButton;
module.exports = exports['default'];
@@ -4934,9 +4934,7 @@ var AudioTrackMenuItem = (function (_MenuItem) {
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
if (track === this.track) {
track.enabled = true;
}
track.enabled = track === this.track;
}
};
@@ -5124,10 +5122,11 @@ var _componentJs2 = _interopRequireDefault(_componentJs);
var FullscreenToggle = (function (_Button) {
_inherits(FullscreenToggle, _Button);
function FullscreenToggle() {
function FullscreenToggle(player, options) {
_classCallCheck(this, FullscreenToggle);
_Button.apply(this, arguments);
_Button.call(this, player, options);
this.on(player, 'fullscreenchange', this.handleFullscreenChange);
}
/**
@@ -5141,6 +5140,20 @@ var FullscreenToggle = (function (_Button) {
return 'vjs-fullscreen-control ' + _Button.prototype.buildCSSClass.call(this);
};
/**
* Handles Fullscreenchange on the component and change control text accordingly
*
* @method handleFullscreenChange
*/
FullscreenToggle.prototype.handleFullscreenChange = function handleFullscreenChange() {
if (this.player_.isFullscreen()) {
this.controlText('Non-Fullscreen');
} else {
this.controlText('Fullscreen');
}
};
/**
* Handles click for full screen
*
@@ -5150,10 +5163,8 @@ var FullscreenToggle = (function (_Button) {
FullscreenToggle.prototype.handleClick = function handleClick() {
if (!this.player_.isFullscreen()) {
this.player_.requestFullscreen();
this.controlText('Non-Fullscreen');
} else {
this.player_.exitFullscreen();
this.controlText('Fullscreen');
}
};
@@ -8879,25 +8890,45 @@ var _objectAssign = _dereq_('object.assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
/*
* Custom MediaError to mimic the HTML5 MediaError
* Custom MediaError class which mimics the standard HTML5 MediaError class.
*
* @param {Number} code The media error code
* @param {Number|String|Object|MediaError} value
* This can be of multiple types:
* - Number: should be a standard error code
* - String: an error message (the code will be 0)
* - Object: arbitrary properties
* - MediaError (native): used to populate a video.js MediaError object
* - MediaError (video.js): will return itself if it's already a
* video.js MediaError object.
*/
var MediaError = function MediaError(code) {
if (typeof code === 'number') {
this.code = code;
} else if (typeof code === 'string') {
function MediaError(value) {
// Allow redundant calls to this constructor to avoid having `instanceof`
// checks peppered around the code.
if (value instanceof MediaError) {
return value;
}
if (typeof value === 'number') {
this.code = value;
} else if (typeof value === 'string') {
// default code is zero, so this is a custom error
this.message = code;
} else if (typeof code === 'object') {
// object
_objectAssign2['default'](this, code);
this.message = value;
} else if (typeof value === 'object') {
// We assign the `code` property manually because native MediaError objects
// do not expose it as an own/enumerable property of the object.
if (typeof value.code === 'number') {
this.code = value.code;
}
_objectAssign2['default'](this, value);
}
if (!this.message) {
this.message = MediaError.defaultMessages[this.code] || '';
}
};
}
/*
* The error code that refers two one of the defined
@@ -11573,7 +11604,8 @@ var Player = (function (_Component) {
};
/**
* Get the length in time of the video in seconds
* Normally gets the length in time of the video in seconds;
* in all but the rarest use cases an argument will NOT be passed to the method
* ```js
* var lengthOfVideo = myPlayer.duration();
* ```
@@ -12467,12 +12499,7 @@ var Player = (function (_Component) {
return this;
}
// error instance
if (err instanceof _mediaErrorJs2['default']) {
this.error_ = err;
} else {
this.error_ = new _mediaErrorJs2['default'](err);
}
this.error_ = new _mediaErrorJs2['default'](err);
// add the vjs-error classname to the player
this.addClass('vjs-error');
@@ -15270,7 +15297,13 @@ var Html5 = (function (_Tech) {
*/
Html5.prototype.play = function play() {
this.el_.play();
var playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, function (e) {});
}
};
/**
@@ -16724,11 +16757,7 @@ var Tech = (function (_Component) {
Tech.prototype.error = function error(err) {
if (err !== undefined) {
if (err instanceof _mediaErrorJs2['default']) {
this.error_ = err;
} else {
this.error_ = new _mediaErrorJs2['default'](err);
}
this.error_ = new _mediaErrorJs2['default'](err);
this.trigger('error');
}
return this.error_;
@@ -20707,6 +20736,10 @@ var _guidJs = _dereq_('./guid.js');
var Guid = _interopRequireWildcard(_guidJs);
var _logJs = _dereq_('./log.js');
var _logJs2 = _interopRequireDefault(_logJs);
var _globalWindow = _dereq_('global/window');
var _globalWindow2 = _interopRequireDefault(_globalWindow);
@@ -20761,7 +20794,11 @@ function on(elem, type, fn) {
if (event.isImmediatePropagationStopped()) {
break;
} else {
handlersCopy[m].call(elem, event, hash);
try {
handlersCopy[m].call(elem, event, hash);
} catch (e) {
_logJs2['default'].error(e);
}
}
}
}
@@ -21084,7 +21121,7 @@ function _handleMultipleEvents(fn, elem, types, callback) {
});
}
},{"./dom.js":142,"./guid.js":146,"global/document":1,"global/window":2}],144:[function(_dereq_,module,exports){
},{"./dom.js":142,"./guid.js":146,"./log.js":147,"global/document":1,"global/window":2}],144:[function(_dereq_,module,exports){
/**
* @file fn.js
*/
@@ -21863,7 +21900,7 @@ setup.autoSetupTimeout(1, videojs);
*
* @type {String}
*/
videojs.VERSION = '5.11.2';
videojs.VERSION = '5.11.6';
/**
* The global options object. These are the settings that take effect
+10 -10
Ver Arquivo
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+8 -9
Ver Arquivo
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+1 -1
Ver Arquivo
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+1
Ver Arquivo
@@ -21,6 +21,7 @@
"Close Modal Dialog": "Close Modal Dialog",
"Descriptions": "Descriptions",
"descriptions off": "descriptions off",
"Audio Track": "Audio Track",
"You aborted the media playback": "You aborted the media playback",
"A network error caused the media download to fail part-way.": "A network error caused the media download to fail part-way.",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "The media could not be loaded, either because the server or network failed or because the format is not supported.",
+1 -1
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "video.js",
"description": "An HTML5 and Flash video player with a common API and skin for both.",
"version": "5.11.2",
"version": "5.11.6",
"copyright": "Copyright Brightcove, Inc. <https://www.brightcove.com/>",
"license": "Apache-2.0",
"keywords": [
+5 -3
Ver Arquivo
@@ -11,7 +11,6 @@ import * as Guid from './utils/guid.js';
import * as Events from './utils/events.js';
import log from './utils/log.js';
import toTitleCase from './utils/to-title-case.js';
import assign from 'object.assign';
import mergeOptions from './utils/merge-options.js';
@@ -1176,8 +1175,11 @@ class Component {
this.on('touchstart', function(event) {
// If more than one finger, don't consider treating this as a click
if (event.touches.length === 1) {
// Copy the touches object to prevent modifying the original
firstTouch = assign({}, event.touches[0]);
// Copy pageX/pageY from the object
firstTouch = {
pageX: event.touches[0].pageX,
pageY: event.touches[0].pageY
};
// Record start time so we can detect a tap vs. "touch and hold"
touchStart = new Date().getTime();
// Reset couldBeTap tracking
@@ -59,6 +59,6 @@ class AudioTrackButton extends TrackButton {
return items;
}
}
AudioTrackButton.prototype.controlText_ = 'Audio Track';
Component.registerComponent('AudioTrackButton', AudioTrackButton);
export default AudioTrackButton;
@@ -51,9 +51,7 @@ class AudioTrackMenuItem extends MenuItem {
for (let i = 0; i < tracks.length; i++) {
let track = tracks[i];
if (track === this.track) {
track.enabled = true;
}
track.enabled = track === this.track;
}
}
+17 -3
Ver Arquivo
@@ -12,6 +12,11 @@ import Component from '../component.js';
*/
class FullscreenToggle extends Button {
constructor(player, options) {
super(player, options);
this.on(player, 'fullscreenchange', this.handleFullscreenChange);
}
/**
* Allow sub components to stack CSS class names
*
@@ -21,7 +26,18 @@ class FullscreenToggle extends Button {
buildCSSClass() {
return `vjs-fullscreen-control ${super.buildCSSClass()}`;
}
/**
* Handles Fullscreenchange on the component and change control text accordingly
*
* @method handleFullscreenChange
*/
handleFullscreenChange() {
if (this.player_.isFullscreen()) {
this.controlText('Non-Fullscreen');
} else {
this.controlText('Fullscreen');
}
}
/**
* Handles click for full screen
*
@@ -30,10 +46,8 @@ class FullscreenToggle extends Button {
handleClick() {
if (!this.player_.isFullscreen()) {
this.player_.requestFullscreen();
this.controlText('Non-Fullscreen');
} else {
this.player_.exitFullscreen();
this.controlText('Fullscreen');
}
}
+31 -10
Ver Arquivo
@@ -4,24 +4,45 @@
import assign from 'object.assign';
/*
* Custom MediaError to mimic the HTML5 MediaError
* Custom MediaError class which mimics the standard HTML5 MediaError class.
*
* @param {Number} code The media error code
* @param {Number|String|Object|MediaError} value
* This can be of multiple types:
* - Number: should be a standard error code
* - String: an error message (the code will be 0)
* - Object: arbitrary properties
* - MediaError (native): used to populate a video.js MediaError object
* - MediaError (video.js): will return itself if it's already a
* video.js MediaError object.
*/
let MediaError = function(code){
if (typeof code === 'number') {
this.code = code;
} else if (typeof code === 'string') {
function MediaError(value) {
// Allow redundant calls to this constructor to avoid having `instanceof`
// checks peppered around the code.
if (value instanceof MediaError) {
return value;
}
if (typeof value === 'number') {
this.code = value;
} else if (typeof value === 'string') {
// default code is zero, so this is a custom error
this.message = code;
} else if (typeof code === 'object') { // object
assign(this, code);
this.message = value;
} else if (typeof value === 'object') {
// We assign the `code` property manually because native MediaError objects
// do not expose it as an own/enumerable property of the object.
if (typeof value.code === 'number') {
this.code = value.code;
}
assign(this, value);
}
if (!this.message) {
this.message = MediaError.defaultMessages[this.code] || '';
}
};
}
/*
* The error code that refers two one of the defined
+3 -7
Ver Arquivo
@@ -1418,7 +1418,8 @@ class Player extends Component {
}
/**
* Get the length in time of the video in seconds
* Normally gets the length in time of the video in seconds;
* in all but the rarest use cases an argument will NOT be passed to the method
* ```js
* var lengthOfVideo = myPlayer.duration();
* ```
@@ -2276,12 +2277,7 @@ class Player extends Component {
return this;
}
// error instance
if (err instanceof MediaError) {
this.error_ = err;
} else {
this.error_ = new MediaError(err);
}
this.error_ = new MediaError(err);
// add the vjs-error classname to the player
this.addClass('vjs-error');
+9 -1
Ver Arquivo
@@ -423,7 +423,15 @@ class Html5 extends Tech {
*
* @method play
*/
play() { this.el_.play(); }
play() {
const playPromise = this.el_.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
playPromise.then(null, (e) => {});
}
}
/**
* Pause for html5 tech
+1 -5
Ver Arquivo
@@ -282,11 +282,7 @@ class Tech extends Component {
*/
error(err) {
if (err !== undefined) {
if (err instanceof MediaError) {
this.error_ = err;
} else {
this.error_ = new MediaError(err);
}
this.error_ = new MediaError(err);
this.trigger('error');
}
return this.error_;
+8 -3
Ver Arquivo
@@ -7,8 +7,9 @@
* robust as jquery's, so there's probably some differences.
*/
import * as Dom from './dom.js';
import * as Guid from './guid.js';
import * as Dom from './dom.js';
import * as Guid from './guid.js';
import log from './log.js';
import window from 'global/window';
import document from 'global/document';
@@ -57,7 +58,11 @@ export function on(elem, type, fn){
if (event.isImmediatePropagationStopped()) {
break;
} else {
handlersCopy[m].call(elem, event, hash);
try {
handlersCopy[m].call(elem, event, hash);
} catch (e) {
log.error(e);
}
}
}
}
+12
Ver Arquivo
@@ -2,6 +2,7 @@ import VolumeControl from '../../src/js/control-bar/volume-control/volume-contro
import MuteToggle from '../../src/js/control-bar/mute-toggle.js';
import PlaybackRateMenuButton from '../../src/js/control-bar/playback-rate-menu/playback-rate-menu-button.js';
import Slider from '../../src/js/slider/slider.js';
import FullscreenToggle from '../../src/js/control-bar/fullscreen-toggle.js';
import TestHelpers from './test-helpers.js';
import document from 'global/document';
@@ -112,3 +113,14 @@ test('should hide playback rate control if it\'s not supported', function(){
ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden');
});
QUnit.test('Fullscreen control text should be correct when fullscreenchange is triggered', function() {
const player = TestHelpers.makePlayer();
const fullscreentoggle = new FullscreenToggle(player);
player.isFullscreen(true);
player.trigger('fullscreenchange');
QUnit.equal(fullscreentoggle.controlText(), 'Non-Fullscreen', 'Control Text is correct while switching to fullscreen mode');
player.isFullscreen(false);
player.trigger('fullscreenchange');
QUnit.equal(fullscreentoggle.controlText(), 'Fullscreen', 'Control Text is correct while switching back to normal mode');
});
+18
Ver Arquivo
@@ -239,3 +239,21 @@ test('should have relatedTarget correctly set on the event', function() {
Events.trigger(el2, { type:'click', relatedTarget:undefined });
});
QUnit.test('should execute remaining handlers after an exception in an event handler', function(assert) {
assert.expect(1);
const el = document.createElement('div');
const listener1 = function() {
throw new Error('GURU MEDITATION ERROR');
};
const listener2 = function() {
assert.ok(true, 'Click Triggered');
};
Events.on(el, 'click', listener1);
Events.on(el, 'click', listener2);
// 1 click
Events.trigger(el, 'click');
});
+69
Ver Arquivo
@@ -0,0 +1,69 @@
/* eslint-env qunit */
import window from 'global/window';
import MediaError from '../../src/js/media-error';
const isModernBrowser = window.MediaError && Object.create && Object.defineProperty;
/**
* Creates a real native MediaError object.
*
* @param {Number} code
* @param {String} [message]
* @return {MediaError}
*/
const createNativeMediaError = (code, message) => {
const err = Object.create(window.MediaError);
Object.defineProperty(err, 'code', {value: code});
if (message) {
err.message = message;
}
return err;
};
QUnit.module('MediaError');
QUnit.test('can be constructed from a number', function(assert) {
const mediaError = new MediaError(1);
assert.strictEqual(mediaError.code, 1);
assert.strictEqual(mediaError.message, MediaError.defaultMessages['1']);
});
QUnit.test('can be constructed from a string', function(assert) {
const mediaError = new MediaError('hello, world');
assert.strictEqual(mediaError.code, 0);
assert.strictEqual(mediaError.message, 'hello, world');
});
QUnit.test('can be constructed from an object', function(assert) {
const mediaError = new MediaError({code: 2});
const mediaErrorMsg = new MediaError({code: 2, message: 'hello, world'});
assert.strictEqual(mediaError.code, 2);
assert.strictEqual(mediaError.message, MediaError.defaultMessages['2']);
assert.strictEqual(mediaErrorMsg.code, 2);
assert.strictEqual(mediaErrorMsg.message, 'hello, world');
});
if (isModernBrowser) {
QUnit.test('can be constructed from a native MediaError object', function(assert) {
const mediaError = new MediaError(createNativeMediaError(3));
const mediaErrorMsg = new MediaError(createNativeMediaError(4, 'hello, world'));
assert.strictEqual(mediaError.code, 3);
assert.strictEqual(mediaError.message, MediaError.defaultMessages['3']);
assert.strictEqual(mediaErrorMsg.code, 4);
assert.strictEqual(mediaErrorMsg.message, 'hello, world');
});
}
QUnit.test('can be constructed redundantly', function(assert) {
const mediaError = new MediaError(2);
const redundantMediaError = new MediaError(mediaError);
assert.strictEqual(redundantMediaError, mediaError);
});
+17
Ver Arquivo
@@ -442,3 +442,20 @@ test('Html5#reset calls Html5.resetMediaElement when called', function() {
Html5.resetMediaElement = oldResetMedia;
});
QUnit.test('Exception in play promise should be caught', function() {
const oldEl = tech.el_;
tech.el_ = {
play: () => {
return new Promise(function(resolve, reject) {
reject(new DOMException());
});
}
};
tech.play();
QUnit.ok(true, 'error was caught');
tech.el_ = oldEl;
});