Media: Upgrade MediaElement.js to `4.2.5-74e01a40` fixing missing `mejs.MediaElement` reference.

ALso fixes:

* Accessibility for volume control
* Progress bar tooltip positioning and dimensions correctly set for media with long duration
* Better codec checking
* Minor CSS fix to avoid flickering effect on volume control

Props rafa8626.
See #39686.
Fixes #41640.

Built from https://develop.svn.wordpress.org/trunk@41320


git-svn-id: http://core.svn.wordpress.org/trunk@41151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-08-28 19:29:47 +00:00
parent c56801657a
commit a979e17e2b
10 changed files with 302 additions and 180 deletions

View File

@ -866,7 +866,7 @@ var MediaElement = function MediaElement(idOrNode, options, sources) {
if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') { if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') {
setTimeout(function () { setTimeout(function () {
t.mediaElement.renderer[methodName](args); t.mediaElement.renderer[methodName](args);
}, 100); }, 150);
} else { } else {
t.mediaElement.renderer[methodName](args); t.mediaElement.renderer[methodName](args);
} }
@ -975,6 +975,7 @@ var MediaElement = function MediaElement(idOrNode, options, sources) {
}; };
_window2.default.MediaElement = MediaElement; _window2.default.MediaElement = MediaElement;
_mejs2.default.MediaElement = MediaElement;
exports.default = MediaElement; exports.default = MediaElement;
@ -1207,6 +1208,21 @@ Object.assign(_player2.default.prototype, {
player.fullscreenBtn = fullscreenBtn; player.fullscreenBtn = fullscreenBtn;
t.options.keyActions.push({
keys: [70],
action: function action(player, media, key, event) {
if (!event.ctrlKey) {
if (typeof player.enterFullScreen !== 'undefined') {
if (player.isFullScreen) {
player.exitFullScreen();
} else {
player.enterFullScreen();
}
}
}
}
});
t.exitFullscreenCallback = function (e) { t.exitFullscreenCallback = function (e) {
var key = e.which || e.keyCode || 0; var key = e.which || e.keyCode || 0;
if (key === 27 && (Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN || t.isFullScreen)) { if (key === 27 && (Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN || t.isFullScreen)) {
@ -1548,6 +1564,39 @@ Object.assign(_player2.default.prototype, {
t.addControlElement(rail, 'progress'); t.addControlElement(rail, 'progress');
t.options.keyActions.push({
keys: [37, 227],
action: function action(player) {
if (!isNaN(player.duration) && player.duration > 0) {
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
player.container.querySelector('.' + _player.config.classPrefix + 'time-total').focus();
var newTime = Math.max(player.currentTime - player.options.defaultSeekBackwardInterval(player), 0);
player.setCurrentTime(newTime);
}
}
}, {
keys: [39, 228],
action: function action(player) {
if (!isNaN(player.duration) && player.duration > 0) {
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
player.container.querySelector('.' + _player.config.classPrefix + 'time-total').focus();
var newTime = Math.min(player.currentTime + player.options.defaultSeekForwardInterval(player), player.duration);
player.setCurrentTime(newTime);
}
}
});
controls.querySelector('.' + t.options.classPrefix + 'time-buffering').style.display = 'none'; controls.querySelector('.' + t.options.classPrefix + 'time-buffering').style.display = 'none';
t.rail = controls.querySelector('.' + t.options.classPrefix + 'time-rail'); t.rail = controls.querySelector('.' + t.options.classPrefix + 'time-rail');
@ -1625,7 +1674,7 @@ Object.assign(_player2.default.prototype, {
t.updateCurrent(t.newTime); t.updateCurrent(t.newTime);
} }
if (!_constants.IS_IOS && !_constants.IS_ANDROID && t.timefloat) { if (!_constants.IS_IOS && !_constants.IS_ANDROID) {
if (pos < 0) { if (pos < 0) {
pos = 0; pos = 0;
} }
@ -1645,18 +1694,27 @@ Object.assign(_player2.default.prototype, {
} }
} }
var half = t.timefloat.offsetWidth / 2; if (t.timefloat) {
if (x <= t.timefloat.offsetWidth + half) { var half = t.timefloat.offsetWidth / 2,
leftPos = half; offsetContainer = mejs.Utils.offset(t.container),
} else if (x >= t.container.offsetWidth - half) { tooltipStyles = getComputedStyle(t.timefloat);
leftPos = t.total.offsetWidth - half;
} else {
leftPos = pos;
}
t.timefloat.style.left = leftPos + 'px'; if (x - offsetContainer.left < t.timefloat.offsetWidth) {
t.timefloatcurrent.innerHTML = (0, _time.secondsToTimeCode)(t.newTime, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength); leftPos = half;
t.timefloat.style.display = 'block'; } else if (x - offsetContainer.left >= t.container.offsetWidth - half) {
leftPos = t.total.offsetWidth - half;
} else {
leftPos = pos;
}
if ((0, _dom.hasClass)(t.container, t.options.classPrefix + 'long-video')) {
leftPos += parseFloat(tooltipStyles.marginLeft) / 2 + t.timefloat.offsetWidth / 2;
}
t.timefloat.style.left = leftPos + 'px';
t.timefloatcurrent.innerHTML = (0, _time.secondsToTimeCode)(t.newTime, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength);
t.timefloat.style.display = 'block';
}
} }
} else if (!_constants.IS_IOS && !_constants.IS_ANDROID && t.timefloat) { } else if (!_constants.IS_IOS && !_constants.IS_ANDROID && t.timefloat) {
leftPos = t.timefloat.offsetWidth + width >= t.container.offsetWidth ? t.timefloat.offsetWidth / 2 : 0; leftPos = t.timefloat.offsetWidth + width >= t.container.offsetWidth ? t.timefloat.offsetWidth / 2 : 0;
@ -1725,16 +1783,35 @@ Object.assign(_player2.default.prototype, {
seekBackward = player.options.defaultSeekBackwardInterval(media); seekBackward = player.options.defaultSeekBackwardInterval(media);
var seekTime = t.getCurrentTime(); var seekTime = t.getCurrentTime();
var volume = t.container.querySelector('.' + t.options.classPrefix + 'volume-slider');
if (keyCode === 38 || keyCode === 40) {
if (volume) {
volume.style.display = 'block';
}
if (t.isVideo) {
t.showControls();
t.startControlsTimer();
}
var newVolume = keyCode === 38 ? Math.min(t.volume + 0.1, 1) : Math.max(t.volume - 0.1, 0),
mutePlayer = newVolume <= 0;
t.setVolume(newVolume);
t.setMuted(mutePlayer);
return;
} else {
if (volume) {
volume.style.display = 'none';
}
}
switch (keyCode) { switch (keyCode) {
case 37: case 37:
case 40:
if (t.getDuration() !== Infinity) { if (t.getDuration() !== Infinity) {
seekTime -= seekBackward; seekTime -= seekBackward;
} }
break; break;
case 39: case 39:
case 38:
if (t.getDuration() !== Infinity) { if (t.getDuration() !== Infinity) {
seekTime += seekForward; seekTime += seekForward;
} }
@ -1745,8 +1822,9 @@ Object.assign(_player2.default.prototype, {
case 35: case 35:
seekTime = duration; seekTime = duration;
break; break;
case 13:
case 32: case 32:
if (!_constants.IS_FIREFOX) { if (_constants.IS_FIREFOX) {
if (t.paused) { if (t.paused) {
t.play(); t.play();
} else { } else {
@ -1754,13 +1832,6 @@ Object.assign(_player2.default.prototype, {
} }
} }
return; return;
case 13:
if (t.paused) {
t.play();
} else {
t.pause();
}
return;
default: default:
return; return;
} }
@ -1776,6 +1847,7 @@ Object.assign(_player2.default.prototype, {
} }
t.setCurrentTime(seekTime); t.setCurrentTime(seekTime);
player.showControls();
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -1989,6 +2061,7 @@ Object.assign(_player2.default.prototype, {
time.innerHTML = '<span class="' + t.options.classPrefix + 'currenttime">' + (0, _time.secondsToTimeCode)(0, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength) + '</span>'; time.innerHTML = '<span class="' + t.options.classPrefix + 'currenttime">' + (0, _time.secondsToTimeCode)(0, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength) + '</span>';
t.addControlElement(time, 'current'); t.addControlElement(time, 'current');
player.updateCurrent();
t.updateTimeCallback = function () { t.updateTimeCallback = function () {
if (t.controlsAreVisible) { if (t.controlsAreVisible) {
player.updateCurrent(); player.updateCurrent();
@ -2017,10 +2090,16 @@ Object.assign(_player2.default.prototype, {
t.addControlElement(duration, 'duration'); t.addControlElement(duration, 'duration');
} }
media.addEventListener('timeupdate', t.updateTimeCallback); t.updateDurationCallback = function () {
if (t.controlsAreVisible) {
player.updateDuration();
}
};
media.addEventListener('timeupdate', t.updateDurationCallback);
}, },
cleanduration: function cleanduration(player, controls, layers, media) { cleanduration: function cleanduration(player, controls, layers, media) {
media.removeEventListener('timeupdate', player.updateTimeCallback); media.removeEventListener('timeupdate', player.updateDurationCallback);
}, },
updateCurrent: function updateCurrent() { updateCurrent: function updateCurrent() {
var t = this; var t = this;
@ -2870,6 +2949,60 @@ Object.assign(_player2.default.prototype, {
t.addControlElement(mute, 'volume'); t.addControlElement(mute, 'volume');
t.options.keyActions.push({
keys: [38],
action: function action(player) {
var volumeSlider = player.container.querySelector('.' + _player.config.classPrefix + 'volume-slider');
if (volumeSlider || player.container.querySelector('.' + _player.config.classPrefix + 'volume-slider').matches(':focus')) {
volumeSlider.style.display = 'block';
}
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newVolume = Math.min(player.volume + 0.1, 1);
player.setVolume(newVolume);
if (newVolume > 0) {
player.setMuted(false);
}
}
}, {
keys: [40],
action: function action(player) {
var volumeSlider = player.container.querySelector('.' + _player.config.classPrefix + 'volume-slider');
if (volumeSlider) {
volumeSlider.style.display = 'block';
}
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newVolume = Math.max(player.volume - 0.1, 0);
player.setVolume(newVolume);
if (newVolume <= 0.1) {
player.setMuted(true);
}
}
}, {
keys: [77],
action: function action(player) {
player.container.querySelector('.' + _player.config.classPrefix + 'volume-slider').style.display = 'block';
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
if (player.media.muted) {
player.setMuted(false);
} else {
player.setMuted(true);
}
}
});
if (mode === 'horizontal') { if (mode === 'horizontal') {
var anchor = _document2.default.createElement('a'); var anchor = _document2.default.createElement('a');
anchor.className = t.options.classPrefix + 'horizontal-volume-slider'; anchor.className = t.options.classPrefix + 'horizontal-volume-slider';
@ -2980,6 +3113,13 @@ Object.assign(_player2.default.prototype, {
} }
}; };
player.container.addEventListener('keydown', function (e) {
var hasFocus = !!e.target.closest('.' + t.options.classPrefix + 'container');
if (!hasFocus && mode === 'vertical') {
volumeSlider.style.display = 'none';
}
});
mute.addEventListener('mouseenter', function (e) { mute.addEventListener('mouseenter', function (e) {
if (e.target === mute) { if (e.target === mute) {
volumeSlider.style.display = 'block'; volumeSlider.style.display = 'block';
@ -3366,99 +3506,6 @@ var config = exports.config = {
} }
} }
} }
}, {
keys: [38],
action: function action(player) {
if (player.container.querySelector('.' + config.classPrefix + 'volume-button>button').matches(':focus') || player.container.querySelector('.' + config.classPrefix + 'volume-slider').matches(':focus')) {
player.container.querySelector('.' + config.classPrefix + 'volume-slider').style.display = '';
}
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newVolume = Math.min(player.volume + 0.1, 1);
player.setVolume(newVolume);
if (newVolume > 0) {
player.setMuted(false);
}
}
}, {
keys: [40],
action: function action(player) {
if (player.container.querySelector('.' + config.classPrefix + 'volume-button>button').matches(':focus') || player.container.querySelector('.' + config.classPrefix + 'volume-slider').matches(':focus')) {
player.container.querySelector('.' + config.classPrefix + 'volume-slider').style.display = '';
}
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newVolume = Math.max(player.volume - 0.1, 0);
player.setVolume(newVolume);
if (newVolume <= 0.1) {
player.setMuted(true);
}
}
}, {
keys: [37, 227],
action: function action(player) {
if (!isNaN(player.duration) && player.duration > 0) {
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newTime = Math.max(player.currentTime - player.options.defaultSeekBackwardInterval(player), 0);
player.setCurrentTime(newTime);
}
}
}, {
keys: [39, 228],
action: function action(player) {
if (!isNaN(player.duration) && player.duration > 0) {
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
var newTime = Math.min(player.currentTime + player.options.defaultSeekForwardInterval(player), player.duration);
player.setCurrentTime(newTime);
}
}
}, {
keys: [70],
action: function action(player, media, key, event) {
if (!event.ctrlKey) {
if (typeof player.enterFullScreen !== 'undefined') {
if (player.isFullScreen) {
player.exitFullScreen();
} else {
player.enterFullScreen();
}
}
}
}
}, {
keys: [77],
action: function action(player) {
player.container.querySelector('.' + config.classPrefix + 'volume-slider').style.display = '';
if (player.isVideo) {
player.showControls();
player.startControlsTimer();
}
if (player.media.muted) {
player.setMuted(false);
} else {
player.setMuted(true);
}
}
}] }]
}; };
@ -4004,7 +4051,7 @@ var MediaElementPlayer = function () {
if (t.options.enableAutosize) { if (t.options.enableAutosize) {
t.media.addEventListener('loadedmetadata', function (e) { t.media.addEventListener('loadedmetadata', function (e) {
var target = e !== undefined ? e.detail.target || e.target : t.media; var target = e !== undefined ? e.detail.target || e.target : t.media;
if (t.options.videoHeight <= 0 && !t.domNode.getAttribute('height') && target !== null && !isNaN(target.videoHeight)) { if (t.options.videoHeight <= 0 && !t.domNode.getAttribute('height') && !t.domNode.style.height && target !== null && !isNaN(target.videoHeight)) {
t.setPlayerSize(target.videoWidth, target.videoHeight); t.setPlayerSize(target.videoWidth, target.videoHeight);
t.setControlsSize(); t.setControlsSize();
t.media.setSize(target.videoWidth, target.videoHeight); t.media.setSize(target.videoWidth, target.videoHeight);
@ -4182,14 +4229,14 @@ var MediaElementPlayer = function () {
var errorContent = typeof t.options.customError === 'function' ? t.options.customError(t.media, t.media.originalNode) : t.options.customError, var errorContent = typeof t.options.customError === 'function' ? t.options.customError(t.media, t.media.originalNode) : t.options.customError,
imgError = ''; imgError = '';
if (errorContent) { if (!errorContent) {
var poster = t.media.originalNode.getAttribute('poster'); var poster = t.media.originalNode.getAttribute('poster');
if (poster) { if (poster) {
imgError = '<img src="' + poster + '" alt="' + _mejs2.default.i18n.t('mejs.download-file') + '">'; imgError = '<img src="' + poster + '" alt="' + _mejs2.default.i18n.t('mejs.download-file') + '">';
} }
if (e.message) { if (e.message) {
errorContent += '<p>' + e.message + '</p>'; errorContent = '<p>' + e.message + '</p>';
} }
if (e.urls) { if (e.urls) {
@ -4205,6 +4252,10 @@ var MediaElementPlayer = function () {
t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').innerHTML = '' + imgError + errorContainer.outerHTML; t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').innerHTML = '' + imgError + errorContainer.outerHTML;
t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').parentNode.style.display = 'block'; t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').parentNode.style.display = 'block';
} }
if (t.controlsEnabled) {
t.disableControls();
}
} }
}, { }, {
key: 'setPlayerSize', key: 'setPlayerSize',
@ -4871,6 +4922,12 @@ var MediaElementPlayer = function () {
hasError = true; hasError = true;
}); });
media.addEventListener('loadedmetadata', function () {
if (!t.controlsEnabled) {
t.enableControls();
}
});
media.addEventListener('keydown', function (e) { media.addEventListener('keydown', function (e) {
t.onkeydown(player, media, e); t.onkeydown(player, media, e);
hasError = false; hasError = false;
@ -4914,6 +4971,7 @@ var MediaElementPlayer = function () {
keyAction.action(player, media, e.keyCode, e); keyAction.action(player, media, e.keyCode, e);
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
return;
} }
} }
} }
@ -5024,6 +5082,8 @@ var MediaElementPlayer = function () {
t.node.style.width = nativeWidth; t.node.style.width = nativeWidth;
t.node.style.height = nativeHeight; t.node.style.height = nativeHeight;
t.setPlayerSize(0, 0);
if (!t.isDynamic) { if (!t.isDynamic) {
(function () { (function () {
t.node.setAttribute('controls', true); t.node.setAttribute('controls', true);
@ -5161,6 +5221,7 @@ var MediaElementPlayer = function () {
}(); }();
_window2.default.MediaElementPlayer = MediaElementPlayer; _window2.default.MediaElementPlayer = MediaElementPlayer;
_mejs2.default.MediaElementPlayer = MediaElementPlayer;
exports.default = MediaElementPlayer; exports.default = MediaElementPlayer;
@ -6109,7 +6170,7 @@ var NativeFlv = {
_createPlayer: function _createPlayer(settings) { _createPlayer: function _createPlayer(settings) {
flvjs.LoggingControl.enableDebug = settings.options.debug; flvjs.LoggingControl.enableDebug = settings.options.debug;
flvjs.LoggingControl.enableVerbose = settings.options.debug; flvjs.LoggingControl.enableVerbose = settings.options.debug;
var player = flvjs.createPlayer(settings.options); var player = flvjs.createPlayer(settings.options, settings.configs);
_window2.default['__ready__' + settings.id](player); _window2.default['__ready__' + settings.id](player);
return player; return player;
} }
@ -6168,6 +6229,7 @@ var FlvNativeRenderer = {
_flvOptions.cors = options.flv.cors; _flvOptions.cors = options.flv.cors;
_flvOptions.debug = options.flv.debug; _flvOptions.debug = options.flv.debug;
_flvOptions.path = options.flv.path; _flvOptions.path = options.flv.path;
var _flvConfigs = options.flv.configs;
flvPlayer.destroy(); flvPlayer.destroy();
for (var i = 0, total = events.length; i < total; i++) { for (var i = 0, total = events.length; i < total; i++) {
@ -6175,6 +6237,7 @@ var FlvNativeRenderer = {
} }
flvPlayer = NativeFlv._createPlayer({ flvPlayer = NativeFlv._createPlayer({
options: _flvOptions, options: _flvOptions,
configs: _flvConfigs,
id: id id: id
}); });
flvPlayer.attachMediaElement(node); flvPlayer.attachMediaElement(node);
@ -6259,6 +6322,7 @@ var FlvNativeRenderer = {
flvOptions.cors = options.flv.cors; flvOptions.cors = options.flv.cors;
flvOptions.debug = options.flv.debug; flvOptions.debug = options.flv.debug;
flvOptions.path = options.flv.path; flvOptions.path = options.flv.path;
var flvConfigs = options.flv.configs;
node.setSize = function (width, height) { node.setSize = function (width, height) {
node.style.width = width + 'px'; node.style.width = width + 'px';
@ -6290,6 +6354,7 @@ var FlvNativeRenderer = {
mediaElement.promises.push(NativeFlv.load({ mediaElement.promises.push(NativeFlv.load({
options: flvOptions, options: flvOptions,
configs: flvConfigs,
id: id id: id
})); }));
@ -6382,7 +6447,9 @@ var HlsNativeRenderer = {
autoplay = originalNode.autoplay; autoplay = originalNode.autoplay;
var hlsPlayer = null, var hlsPlayer = null,
node = null; node = null,
index = 0,
total = mediaFiles.length;
node = originalNode.cloneNode(true); node = originalNode.cloneNode(true);
options = Object.assign(options, mediaElement.options); options = Object.assign(options, mediaElement.options);
@ -6409,7 +6476,7 @@ var HlsNativeRenderer = {
node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value;
if (hlsPlayer !== null) { if (hlsPlayer !== null) {
hlsPlayer.destroy(); hlsPlayer.destroy();
for (var i = 0, total = events.length; i < total; i++) { for (var i = 0, _total = events.length; i < _total; i++) {
node.removeEventListener(events[i], attachNativeEvents); node.removeEventListener(events[i], attachNativeEvents);
} }
hlsPlayer = NativeHls._createPlayer({ hlsPlayer = NativeHls._createPlayer({
@ -6426,7 +6493,7 @@ var HlsNativeRenderer = {
}; };
}; };
for (var i = 0, total = props.length; i < total; i++) { for (var i = 0, _total2 = props.length; i < _total2; i++) {
assignGettersSetters(props[i]); assignGettersSetters(props[i]);
} }
@ -6444,7 +6511,7 @@ var HlsNativeRenderer = {
node.addEventListener(eventName, attachNativeEvents); node.addEventListener(eventName, attachNativeEvents);
}; };
for (var _i = 0, _total = events.length; _i < _total; _i++) { for (var _i = 0, _total3 = events.length; _i < _total3; _i++) {
assignEvents(events[_i]); assignEvents(events[_i]);
} }
@ -6452,7 +6519,8 @@ var HlsNativeRenderer = {
recoverSwapAudioCodecDate = void 0; recoverSwapAudioCodecDate = void 0;
var assignHlsEvents = function assignHlsEvents(name, data) { var assignHlsEvents = function assignHlsEvents(name, data) {
if (name === 'hlsError') { if (name === 'hlsError') {
console.warn(name, data); console.warn(data);
data = data[1];
if (data.fatal) { if (data.fatal) {
switch (data.type) { switch (data.type) {
@ -6467,15 +6535,23 @@ var HlsNativeRenderer = {
hlsPlayer.swapAudioCodec(); hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError(); hlsPlayer.recoverMediaError();
} else { } else {
var _message = 'Cannot recover, last media error recovery failed'; var message = 'Cannot recover, last media error recovery failed';
mediaElement.generateError(_message, node.src); mediaElement.generateError(message, node.src);
console.error(_message); console.error(message);
} }
break; break;
case 'networkError': case 'networkError':
var message = 'Network error'; if (data.details === 'manifestLoadError') {
mediaElement.generateError(message, node.src); if (index < total) {
console.error(message); node.setSrc(mediaFiles[index++].src);
node.load();
node.play();
}
} else {
var _message = 'Network error';
mediaElement.generateError(_message, mediaFiles);
console.error(_message);
}
break; break;
default: default:
hlsPlayer.destroy(); hlsPlayer.destroy();
@ -6506,10 +6582,10 @@ var HlsNativeRenderer = {
} }
}; };
if (mediaFiles && mediaFiles.length > 0) { if (total > 0) {
for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { for (; index < total; index++) {
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) {
node.setAttribute('src', mediaFiles[_i2].src); node.setAttribute('src', mediaFiles[index].src);
break; break;
} }
} }
@ -6649,19 +6725,19 @@ var HtmlMediaElement = {
}; };
}; };
for (var i = 0, total = props.length; i < total; i++) { for (var i = 0, _total = props.length; i < _total; i++) {
assignGettersSetters(props[i]); assignGettersSetters(props[i]);
} }
var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']), var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']),
assignEvents = function assignEvents(eventName) { assignEvents = function assignEvents(eventName) {
node.addEventListener(eventName, function (e) { node.addEventListener(eventName, function (e) {
var event = (0, _general.createEvent)(e.type, mediaElement); var event = (0, _general.createEvent)(e.type, e.target);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
}; };
for (var _i = 0, _total = events.length; _i < _total; _i++) { for (var _i = 0, _total2 = events.length; _i < _total2; _i++) {
assignEvents(events[_i]); assignEvents(events[_i]);
} }
@ -6683,15 +6759,29 @@ var HtmlMediaElement = {
return node; return node;
}; };
if (mediaFiles && mediaFiles.length > 0) { var index = 0,
for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { total = mediaFiles.length;
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { if (total > 0) {
node.setAttribute('src', mediaFiles[_i2].src); for (; index < total; index++) {
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) {
node.setAttribute('src', mediaFiles[index].src);
break; break;
} }
} }
} }
node.addEventListener('error', function (e) {
if (e.target.error.code === 4) {
if (index < total) {
node.src = mediaFiles[index++].src;
node.load();
node.play();
} else {
mediaElement.generateError('Media error: Format(s) not supported or source(s) not found', mediaFiles);
}
}
});
var event = (0, _general.createEvent)('rendererready', node); var event = (0, _general.createEvent)('rendererready', node);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
@ -7987,9 +8077,9 @@ if (window.Element && !Element.prototype.closest) {
})(); })();
if (/firefox/i.test(navigator.userAgent)) { if (/firefox/i.test(navigator.userAgent)) {
window.mediaElementJsOldGetComputedStyle = window.getComputedStyle; var getComputedStyle = window.getComputedStyle;
window.getComputedStyle = function (el, pseudoEl) { window.getComputedStyle = function (el, pseudoEl) {
var t = window.mediaElementJsOldGetComputedStyle(el, pseudoEl); var t = getComputedStyle(el, pseudoEl);
return t === null ? { getPropertyValue: function getPropertyValue() {} } : t; return t === null ? { getPropertyValue: function getPropertyValue() {} } : t;
}; };
} }

File diff suppressed because one or more lines are too long

View File

@ -866,7 +866,7 @@ var MediaElement = function MediaElement(idOrNode, options, sources) {
if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') { if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') {
setTimeout(function () { setTimeout(function () {
t.mediaElement.renderer[methodName](args); t.mediaElement.renderer[methodName](args);
}, 100); }, 150);
} else { } else {
t.mediaElement.renderer[methodName](args); t.mediaElement.renderer[methodName](args);
} }
@ -975,6 +975,7 @@ var MediaElement = function MediaElement(idOrNode, options, sources) {
}; };
_window2.default.MediaElement = MediaElement; _window2.default.MediaElement = MediaElement;
_mejs2.default.MediaElement = MediaElement;
exports.default = MediaElement; exports.default = MediaElement;
@ -1937,7 +1938,7 @@ var NativeFlv = {
_createPlayer: function _createPlayer(settings) { _createPlayer: function _createPlayer(settings) {
flvjs.LoggingControl.enableDebug = settings.options.debug; flvjs.LoggingControl.enableDebug = settings.options.debug;
flvjs.LoggingControl.enableVerbose = settings.options.debug; flvjs.LoggingControl.enableVerbose = settings.options.debug;
var player = flvjs.createPlayer(settings.options); var player = flvjs.createPlayer(settings.options, settings.configs);
_window2.default['__ready__' + settings.id](player); _window2.default['__ready__' + settings.id](player);
return player; return player;
} }
@ -1996,6 +1997,7 @@ var FlvNativeRenderer = {
_flvOptions.cors = options.flv.cors; _flvOptions.cors = options.flv.cors;
_flvOptions.debug = options.flv.debug; _flvOptions.debug = options.flv.debug;
_flvOptions.path = options.flv.path; _flvOptions.path = options.flv.path;
var _flvConfigs = options.flv.configs;
flvPlayer.destroy(); flvPlayer.destroy();
for (var i = 0, total = events.length; i < total; i++) { for (var i = 0, total = events.length; i < total; i++) {
@ -2003,6 +2005,7 @@ var FlvNativeRenderer = {
} }
flvPlayer = NativeFlv._createPlayer({ flvPlayer = NativeFlv._createPlayer({
options: _flvOptions, options: _flvOptions,
configs: _flvConfigs,
id: id id: id
}); });
flvPlayer.attachMediaElement(node); flvPlayer.attachMediaElement(node);
@ -2087,6 +2090,7 @@ var FlvNativeRenderer = {
flvOptions.cors = options.flv.cors; flvOptions.cors = options.flv.cors;
flvOptions.debug = options.flv.debug; flvOptions.debug = options.flv.debug;
flvOptions.path = options.flv.path; flvOptions.path = options.flv.path;
var flvConfigs = options.flv.configs;
node.setSize = function (width, height) { node.setSize = function (width, height) {
node.style.width = width + 'px'; node.style.width = width + 'px';
@ -2118,6 +2122,7 @@ var FlvNativeRenderer = {
mediaElement.promises.push(NativeFlv.load({ mediaElement.promises.push(NativeFlv.load({
options: flvOptions, options: flvOptions,
configs: flvConfigs,
id: id id: id
})); }));
@ -2210,7 +2215,9 @@ var HlsNativeRenderer = {
autoplay = originalNode.autoplay; autoplay = originalNode.autoplay;
var hlsPlayer = null, var hlsPlayer = null,
node = null; node = null,
index = 0,
total = mediaFiles.length;
node = originalNode.cloneNode(true); node = originalNode.cloneNode(true);
options = Object.assign(options, mediaElement.options); options = Object.assign(options, mediaElement.options);
@ -2237,7 +2244,7 @@ var HlsNativeRenderer = {
node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value;
if (hlsPlayer !== null) { if (hlsPlayer !== null) {
hlsPlayer.destroy(); hlsPlayer.destroy();
for (var i = 0, total = events.length; i < total; i++) { for (var i = 0, _total = events.length; i < _total; i++) {
node.removeEventListener(events[i], attachNativeEvents); node.removeEventListener(events[i], attachNativeEvents);
} }
hlsPlayer = NativeHls._createPlayer({ hlsPlayer = NativeHls._createPlayer({
@ -2254,7 +2261,7 @@ var HlsNativeRenderer = {
}; };
}; };
for (var i = 0, total = props.length; i < total; i++) { for (var i = 0, _total2 = props.length; i < _total2; i++) {
assignGettersSetters(props[i]); assignGettersSetters(props[i]);
} }
@ -2272,7 +2279,7 @@ var HlsNativeRenderer = {
node.addEventListener(eventName, attachNativeEvents); node.addEventListener(eventName, attachNativeEvents);
}; };
for (var _i = 0, _total = events.length; _i < _total; _i++) { for (var _i = 0, _total3 = events.length; _i < _total3; _i++) {
assignEvents(events[_i]); assignEvents(events[_i]);
} }
@ -2280,7 +2287,8 @@ var HlsNativeRenderer = {
recoverSwapAudioCodecDate = void 0; recoverSwapAudioCodecDate = void 0;
var assignHlsEvents = function assignHlsEvents(name, data) { var assignHlsEvents = function assignHlsEvents(name, data) {
if (name === 'hlsError') { if (name === 'hlsError') {
console.warn(name, data); console.warn(data);
data = data[1];
if (data.fatal) { if (data.fatal) {
switch (data.type) { switch (data.type) {
@ -2295,15 +2303,23 @@ var HlsNativeRenderer = {
hlsPlayer.swapAudioCodec(); hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError(); hlsPlayer.recoverMediaError();
} else { } else {
var _message = 'Cannot recover, last media error recovery failed'; var message = 'Cannot recover, last media error recovery failed';
mediaElement.generateError(_message, node.src); mediaElement.generateError(message, node.src);
console.error(_message); console.error(message);
} }
break; break;
case 'networkError': case 'networkError':
var message = 'Network error'; if (data.details === 'manifestLoadError') {
mediaElement.generateError(message, node.src); if (index < total) {
console.error(message); node.setSrc(mediaFiles[index++].src);
node.load();
node.play();
}
} else {
var _message = 'Network error';
mediaElement.generateError(_message, mediaFiles);
console.error(_message);
}
break; break;
default: default:
hlsPlayer.destroy(); hlsPlayer.destroy();
@ -2334,10 +2350,10 @@ var HlsNativeRenderer = {
} }
}; };
if (mediaFiles && mediaFiles.length > 0) { if (total > 0) {
for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { for (; index < total; index++) {
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) {
node.setAttribute('src', mediaFiles[_i2].src); node.setAttribute('src', mediaFiles[index].src);
break; break;
} }
} }
@ -2477,19 +2493,19 @@ var HtmlMediaElement = {
}; };
}; };
for (var i = 0, total = props.length; i < total; i++) { for (var i = 0, _total = props.length; i < _total; i++) {
assignGettersSetters(props[i]); assignGettersSetters(props[i]);
} }
var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']), var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']),
assignEvents = function assignEvents(eventName) { assignEvents = function assignEvents(eventName) {
node.addEventListener(eventName, function (e) { node.addEventListener(eventName, function (e) {
var event = (0, _general.createEvent)(e.type, mediaElement); var event = (0, _general.createEvent)(e.type, e.target);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
}; };
for (var _i = 0, _total = events.length; _i < _total; _i++) { for (var _i = 0, _total2 = events.length; _i < _total2; _i++) {
assignEvents(events[_i]); assignEvents(events[_i]);
} }
@ -2511,15 +2527,29 @@ var HtmlMediaElement = {
return node; return node;
}; };
if (mediaFiles && mediaFiles.length > 0) { var index = 0,
for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { total = mediaFiles.length;
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { if (total > 0) {
node.setAttribute('src', mediaFiles[_i2].src); for (; index < total; index++) {
if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) {
node.setAttribute('src', mediaFiles[index].src);
break; break;
} }
} }
} }
node.addEventListener('error', function (e) {
if (e.target.error.code === 4) {
if (index < total) {
node.src = mediaFiles[index++].src;
node.load();
node.play();
} else {
mediaElement.generateError('Media error: Format(s) not supported or source(s) not found', mediaFiles);
}
}
});
var event = (0, _general.createEvent)('rendererready', node); var event = (0, _general.createEvent)('rendererready', node);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
@ -3815,9 +3845,9 @@ if (window.Element && !Element.prototype.closest) {
})(); })();
if (/firefox/i.test(navigator.userAgent)) { if (/firefox/i.test(navigator.userAgent)) {
window.mediaElementJsOldGetComputedStyle = window.getComputedStyle; var getComputedStyle = window.getComputedStyle;
window.getComputedStyle = function (el, pseudoEl) { window.getComputedStyle = function (el, pseudoEl) {
var t = window.mediaElementJsOldGetComputedStyle(el, pseudoEl); var t = getComputedStyle(el, pseudoEl);
return t === null ? { getPropertyValue: function getPropertyValue() {} } : t; return t === null ? { getPropertyValue: function getPropertyValue() {} } : t;
}; };
} }

File diff suppressed because one or more lines are too long

View File

@ -517,6 +517,7 @@ Reference: http://blog.rrwd.nl/2015/04/04/the-screen-reader-text-class-why-and-h
} }
.mejs-volume-button > .mejs-volume-slider { .mejs-volume-button > .mejs-volume-slider {
-webkit-backface-visibility: hidden;
background: rgba(50, 50, 50, 0.7); background: rgba(50, 50, 50, 0.7);
border-radius: 0; border-radius: 0;
bottom: 100%; bottom: 100%;

File diff suppressed because one or more lines are too long

View File

@ -517,6 +517,7 @@ Reference: http://blog.rrwd.nl/2015/04/04/the-screen-reader-text-class-why-and-h
} }
.mejs__volume-button > .mejs__volume-slider { .mejs__volume-button > .mejs__volume-slider {
-webkit-backface-visibility: hidden;
background: rgba(50, 50, 50, 0.7); background: rgba(50, 50, 50, 0.7);
border-radius: 0; border-radius: 0;
bottom: 100%; bottom: 100%;

File diff suppressed because one or more lines are too long

View File

@ -354,7 +354,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), false, 1 ); $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), false, 1 );
$scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '4.2.5', 1 ); $scripts->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array('jquery'), '4.2.5-74e01a40', 1 );
did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array( did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array(
'language' => get_bloginfo( 'language' ), 'language' => get_bloginfo( 'language' ),
'strings' => array( 'strings' => array(
@ -446,7 +446,7 @@ function wp_default_scripts( &$scripts ) {
) ); ) );
$scripts->add( 'mediaelement-vimeo', "/wp-includes/js/mediaelement/renderers/vimeo.min.js", array('mediaelement'), '4.2.5', 1 ); $scripts->add( 'mediaelement-vimeo', "/wp-includes/js/mediaelement/renderers/vimeo.min.js", array('mediaelement'), '4.2.5-74e01a40', 1 );
$scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array('mediaelement'), false, 1 ); $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array('mediaelement'), false, 1 );
$mejs_settings = array( $mejs_settings = array(
'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
@ -949,7 +949,7 @@ function wp_default_styles( &$styles ) {
// External libraries and friends // External libraries and friends
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
$styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css", array(), '4.2.5' ); $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css", array(), '4.2.5-74e01a40' );
$styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) ); $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-alpha-41319'; $wp_version = '4.9-alpha-41320';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.