Media: Add MediaElement.js 2.2 back-compat for MediaElement.js 4.2

* Introduces `mediaelement-migrate.js`.
* Upgrades ME.js from 4.2.5-74e01a40 to 4.2.6-78496d1.

Props rafa8626, bradyvercher.
See #39686.
Fixes #42189.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-16 18:07:52 +00:00
parent 4085a1b266
commit 2e602a8560
16 changed files with 1037 additions and 711 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,84 @@
/* global console, MediaElementPlayer, mejs */
(function ( window, $ ) {
// Reintegrate `plugins` since they don't exist in MEJS anymore; it won't affect anything in the player
if (mejs.plugins === undefined) {
mejs.plugins = {};
mejs.plugins.silverlight = [];
mejs.plugins.silverlight.push({
types: []
});
}
// Inclusion of old `HtmlMediaElementShim` if it doesn't exist
mejs.HtmlMediaElementShim = mejs.HtmlMediaElementShim || {
getTypeFromFile: mejs.Utils.getTypeFromFile
};
// Add missing global variables for backward compatibility
if (mejs.MediaFeatures === undefined) {
mejs.MediaFeatures = mejs.Features;
}
if (mejs.Utility === undefined) {
mejs.Utility = mejs.Utils;
}
/**
* Create missing variables and have default `classPrefix` overridden to avoid issues.
*
* `media` is now a fake wrapper needed to simplify manipulation of various media types,
* so in order to access the `video` or `audio` tag, use `media.originalNode` or `player.node`;
* `player.container` used to be jQuery but now is a HTML element, and many elements inside
* the player rely on it being a HTML now, so its conversion is difficult; however, a
* `player.$container` new variable has been added to be used as jQuery object
*/
var init = MediaElementPlayer.prototype.init;
MediaElementPlayer.prototype.init = function () {
this.options.classPrefix = 'mejs-';
this.$media = this.$node = $( this.node );
init.call( this );
};
var ready = MediaElementPlayer.prototype._meReady;
MediaElementPlayer.prototype._meReady = function () {
this.container = $( this.container) ;
this.controls = $( this.controls );
this.layers = $( this.layers );
ready.apply( this, arguments );
};
// Override method so certain elements can be called with jQuery
MediaElementPlayer.prototype.getElement = function ( el ) {
return $ !== undefined && el instanceof $ ? el[0] : el;
};
// Add jQuery ONLY to most of custom features' arguments for backward compatibility; default features rely 100%
// on the arguments being HTML elements to work properly
MediaElementPlayer.prototype.buildfeatures = function ( player, controls, layers, media ) {
var defaultFeatures = [
'playpause',
'current',
'progress',
'duration',
'tracks',
'volume',
'fullscreen'
];
for (var i = 0, total = this.options.features.length; i < total; i++) {
var feature = this.options.features[i];
if (this['build' + feature]) {
try {
// Use jQuery for non-default features
if (defaultFeatures.indexOf(feature) === -1) {
this['build' + feature]( player, $(controls), $(layers), media );
} else {
this['build' + feature]( player, controls, layers, media );
}
} catch (e) {
console.error( 'error building ' + feature, e );
}
}
}
};
})( window, jQuery );

View File

@ -315,8 +315,8 @@ i18n.language = function () {
throw new TypeError('Language code must be a string value'); throw new TypeError('Language code must be a string value');
} }
if (!/^[a-z]{2}(\-[a-z]{2})?$/i.test(args[0])) { if (!/^(([a-z]{2}((\-|_)[a-z]{2})?)|([a-z]{3}))$/i.test(args[0])) {
throw new TypeError('Language code must have format `xx` or `xx-xx`'); throw new TypeError('Language code must have format `xx`, `xxx`, `xx_XX` or `xx-xx`');
} }
i18n.lang = args[0]; i18n.lang = args[0];
@ -864,9 +864,23 @@ var MediaElement = function MediaElement(idOrNode, options, sources) {
triggerAction = function triggerAction(methodName, args) { triggerAction = function triggerAction(methodName, args) {
try { try {
if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') { if (methodName === 'play' && t.mediaElement.rendererName === 'native_dash') {
setTimeout(function () { var response = t.mediaElement.renderer[methodName](args);
t.mediaElement.renderer[methodName](args); if (response && typeof response.then === 'function') {
}, 150); response.catch(function () {
if (t.mediaElement.paused) {
setTimeout(function () {
var tmpResponse = t.mediaElement.renderer.play();
if (tmpResponse !== undefined) {
tmpResponse.catch(function () {
if (!t.mediaElement.renderer.paused) {
t.mediaElement.renderer.pause();
}
});
}
}, 150);
}
});
}
} else { } else {
t.mediaElement.renderer[methodName](args); t.mediaElement.renderer[methodName](args);
} }
@ -994,7 +1008,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var mejs = {}; var mejs = {};
mejs.version = '4.2.5'; mejs.version = '4.2.6';
mejs.html5media = { mejs.html5media = {
properties: ['volume', 'src', 'currentTime', 'muted', 'duration', 'paused', 'ended', 'buffered', 'error', 'networkState', 'readyState', 'seeking', 'seekable', 'currentSrc', 'preload', 'bufferedBytes', 'bufferedTime', 'initialTime', 'startOffsetTime', 'defaultPlaybackRate', 'playbackRate', 'played', 'autoplay', 'loop', 'controls'], properties: ['volume', 'src', 'currentTime', 'muted', 'duration', 'paused', 'ended', 'buffered', 'error', 'networkState', 'readyState', 'seeking', 'seekable', 'currentSrc', 'preload', 'bufferedBytes', 'bufferedTime', 'initialTime', 'startOffsetTime', 'defaultPlaybackRate', 'playbackRate', 'played', 'autoplay', 'loop', 'controls'],
@ -1562,6 +1576,7 @@ var FlashMediaElementRenderer = {
create: function create(mediaElement, options, mediaFiles) { create: function create(mediaElement, options, mediaFiles) {
var flash = {}; var flash = {};
var isActive = false;
flash.options = options; flash.options = options;
flash.id = mediaElement.id + '_' + flash.options.prefix; flash.id = mediaElement.id + '_' + flash.options.prefix;
@ -1629,21 +1644,23 @@ var FlashMediaElementRenderer = {
var methods = _mejs2.default.html5media.methods, var methods = _mejs2.default.html5media.methods,
assignMethods = function assignMethods(methodName) { assignMethods = function assignMethods(methodName) {
flash[methodName] = function () { flash[methodName] = function () {
if (flash.flashApi !== null) { if (isActive) {
if (flash.flashApi['fire_' + methodName]) { if (flash.flashApi !== null) {
try { if (flash.flashApi['fire_' + methodName]) {
flash.flashApi['fire_' + methodName](); try {
} catch (e) { flash.flashApi['fire_' + methodName]();
} catch (e) {
}
} else {
} }
} else { } else {
flash.flashApiStack.push({
type: 'call',
methodName: methodName
});
} }
} else {
flash.flashApiStack.push({
type: 'call',
methodName: methodName
});
} }
}; };
}; };
@ -1715,16 +1732,28 @@ var FlashMediaElementRenderer = {
flashVars.push('pseudostreamtype=' + flash.options.pseudoStreamingType); flashVars.push('pseudostreamtype=' + flash.options.pseudoStreamingType);
} }
if (flash.options.streamDelimiter) {
flashVars.push('streamdelimiter=' + encodeURIComponent(flash.options.streamDelimiter));
}
if (flash.options.proxyType) {
flashVars.push('proxytype=' + flash.options.proxyType);
}
mediaElement.appendChild(flash.flashWrapper); mediaElement.appendChild(flash.flashWrapper);
mediaElement.originalNode.style.display = 'none'; mediaElement.originalNode.style.display = 'none';
var settings = []; var settings = [];
if (_constants.IS_IE) { if (_constants.IS_IE || _constants.IS_EDGE) {
var specialIEContainer = _document2.default.createElement('div'); var specialIEContainer = _document2.default.createElement('div');
flash.flashWrapper.appendChild(specialIEContainer); flash.flashWrapper.appendChild(specialIEContainer);
settings = ['classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"', 'codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '"']; if (_constants.IS_EDGE) {
settings = ['type="application/x-shockwave-flash"', 'data="' + flash.options.pluginPath + flash.options.filename + '"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '\'"'];
} else {
settings = ['classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"', 'codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '"'];
}
if (!isVideo) { if (!isVideo) {
settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); settings.push('style="clip: rect(0 0 0 0); position: absolute;"');
@ -1733,10 +1762,13 @@ var FlashMediaElementRenderer = {
specialIEContainer.outerHTML = '<object ' + settings.join(' ') + '>' + ('<param name="movie" value="' + flash.options.pluginPath + flash.options.filename + '?x=' + new Date() + '" />') + ('<param name="flashvars" value="' + flashVars.join('&amp;') + '" />') + '<param name="quality" value="high" />' + '<param name="bgcolor" value="#000000" />' + '<param name="wmode" value="transparent" />' + ('<param name="allowScriptAccess" value="' + flash.options.shimScriptAccess + '" />') + '<param name="allowFullScreen" value="true" />' + ('<div>' + _i18n2.default.t('mejs.install-flash') + '</div>') + '</object>'; specialIEContainer.outerHTML = '<object ' + settings.join(' ') + '>' + ('<param name="movie" value="' + flash.options.pluginPath + flash.options.filename + '?x=' + new Date() + '" />') + ('<param name="flashvars" value="' + flashVars.join('&amp;') + '" />') + '<param name="quality" value="high" />' + '<param name="bgcolor" value="#000000" />' + '<param name="wmode" value="transparent" />' + ('<param name="allowScriptAccess" value="' + flash.options.shimScriptAccess + '" />') + '<param name="allowFullScreen" value="true" />' + ('<div>' + _i18n2.default.t('mejs.install-flash') + '</div>') + '</object>';
} else { } else {
settings = ['id="__' + flash.id + '"', 'name="__' + flash.id + '"', 'play="true"', 'loop="false"', 'quality="high"', 'bgcolor="#000000"', 'wmode="transparent"', 'allowScriptAccess="' + flash.options.shimScriptAccess + '"', 'allowFullScreen="true"', 'type="application/x-shockwave-flash"', 'pluginspage="//www.macromedia.com/go/getflashplayer"', 'src="' + flash.options.pluginPath + flash.options.filename + '"', 'flashvars="' + flashVars.join('&') + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '"']; settings = ['id="__' + flash.id + '"', 'name="__' + flash.id + '"', 'play="true"', 'loop="false"', 'quality="high"', 'bgcolor="#000000"', 'wmode="transparent"', 'allowScriptAccess="' + flash.options.shimScriptAccess + '"', 'allowFullScreen="true"', 'type="application/x-shockwave-flash"', 'pluginspage="//www.macromedia.com/go/getflashplayer"', 'src="' + flash.options.pluginPath + flash.options.filename + '"', 'flashvars="' + flashVars.join('&') + '"'];
if (!isVideo) { if (isVideo) {
settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); settings.push('width="' + flashWidth + '"');
settings.push('height="' + flashHeight + '"');
} else {
settings.push('style="position: fixed; left: -9999em; top: -9999em;"');
} }
flash.flashWrapper.innerHTML = '<embed ' + settings.join(' ') + '>'; flash.flashWrapper.innerHTML = '<embed ' + settings.join(' ') + '>';
@ -1745,11 +1777,13 @@ var FlashMediaElementRenderer = {
flash.flashNode = flash.flashWrapper.lastChild; flash.flashNode = flash.flashWrapper.lastChild;
flash.hide = function () { flash.hide = function () {
isActive = false;
if (isVideo) { if (isVideo) {
flash.flashNode.style.display = 'none'; flash.flashNode.style.display = 'none';
} }
}; };
flash.show = function () { flash.show = function () {
isActive = true;
if (isVideo) { if (isVideo) {
flash.flashNode.style.display = ''; flash.flashNode.style.display = '';
} }
@ -1814,7 +1848,11 @@ if (hasFlash) {
pseudoStreamingStartQueryParam: 'start', pseudoStreamingStartQueryParam: 'start',
pseudoStreamingType: 'byte' pseudoStreamingType: 'byte',
proxyType: '',
streamDelimiter: ''
}, },
canPlayType: function canPlayType(type) { canPlayType: function canPlayType(type) {
@ -1924,7 +1962,7 @@ var NativeFlv = {
NativeFlv._createPlayer(settings); NativeFlv._createPlayer(settings);
}); });
} else { } else {
settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.3.2/flv.min.js'; settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.3.3/flv.min.js';
NativeFlv.promise = NativeFlv.promise || (0, _dom.loadScript)(settings.options.path); NativeFlv.promise = NativeFlv.promise || (0, _dom.loadScript)(settings.options.path);
NativeFlv.promise.then(function () { NativeFlv.promise.then(function () {
@ -1949,7 +1987,7 @@ var FlvNativeRenderer = {
options: { options: {
prefix: 'native_flv', prefix: 'native_flv',
flv: { flv: {
path: 'https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.3.2/flv.min.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.3.3/flv.min.js',
cors: true, cors: true,
debug: false debug: false
@ -2173,7 +2211,7 @@ var NativeHls = {
NativeHls._createPlayer(settings); NativeHls._createPlayer(settings);
}); });
} else { } else {
settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.7.11/hls.min.js'; settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.8.4/hls.min.js';
NativeHls.promise = NativeHls.promise || (0, _dom.loadScript)(settings.options.path); NativeHls.promise = NativeHls.promise || (0, _dom.loadScript)(settings.options.path);
NativeHls.promise.then(function () { NativeHls.promise.then(function () {
@ -2196,7 +2234,7 @@ var HlsNativeRenderer = {
options: { options: {
prefix: 'native_hls', prefix: 'native_hls',
hls: { hls: {
path: 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.7.11/hls.min.js', path: 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.8.4/hls.min.js',
autoStartLoad: false, autoStartLoad: false,
debug: false debug: false
@ -2310,15 +2348,19 @@ var HlsNativeRenderer = {
break; break;
case 'networkError': case 'networkError':
if (data.details === 'manifestLoadError') { if (data.details === 'manifestLoadError') {
if (index < total) { if (index < total && mediaFiles[index + 1] !== undefined) {
node.setSrc(mediaFiles[index++].src); node.setSrc(mediaFiles[index++].src);
node.load(); node.load();
node.play(); node.play();
} else {
var _message = 'Network error';
mediaElement.generateError(_message, mediaFiles);
console.error(_message);
} }
} else { } else {
var _message = 'Network error'; var _message2 = 'Network error';
mediaElement.generateError(_message, mediaFiles); mediaElement.generateError(_message2, mediaFiles);
console.error(_message); console.error(_message2);
} }
break; break;
default: default:
@ -2466,6 +2508,7 @@ var HtmlMediaElement = {
create: function create(mediaElement, options, mediaFiles) { create: function create(mediaElement, options, mediaFiles) {
var id = mediaElement.id + '_' + options.prefix; var id = mediaElement.id + '_' + options.prefix;
var isActive = false;
var node = null; var node = null;
@ -2500,8 +2543,10 @@ var HtmlMediaElement = {
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, e.target); if (isActive) {
mediaElement.dispatchEvent(event); var _event = (0, _general.createEvent)(e.type, e.target);
mediaElement.dispatchEvent(_event);
}
}); });
}; };
@ -2516,12 +2561,14 @@ var HtmlMediaElement = {
}; };
node.hide = function () { node.hide = function () {
isActive = false;
node.style.display = 'none'; node.style.display = 'none';
return node; return node;
}; };
node.show = function () { node.show = function () {
isActive = true;
node.style.display = ''; node.style.display = '';
return node; return node;
@ -2539,8 +2586,8 @@ var HtmlMediaElement = {
} }
node.addEventListener('error', function (e) { node.addEventListener('error', function (e) {
if (e.target.error.code === 4) { if (e.target.error.code === 4 && isActive) {
if (index < total) { if (index < total && mediaFiles[index + 1] !== undefined) {
node.src = mediaFiles[index++].src; node.src = mediaFiles[index++].src;
node.load(); node.load();
node.play(); node.play();
@ -2885,9 +2932,6 @@ var YouTubeIframeRenderer = {
showinfo: 0, showinfo: 0,
modestbranding: 0, modestbranding: 0,
html5: 1, html5: 1,
playsinline: 0,
start: 0,
end: 0,
iv_load_policy: 3 iv_load_policy: 3
}, youtube.options.youtube), }, youtube.options.youtube),
origin: _window2.default.location.host, origin: _window2.default.location.host,
@ -2917,7 +2961,7 @@ var YouTubeIframeRenderer = {
youTubeIframe = youTubeApi.getIframe(); youTubeIframe = youTubeApi.getIframe();
if (mediaElement.originalNode.getAttribute('muted')) { if (mediaElement.originalNode.muted) {
youTubeApi.mute(); youTubeApi.mute();
} }
@ -2991,14 +3035,16 @@ var YouTubeIframeRenderer = {
} }
}; };
if (isAudio) { if (isAudio || mediaElement.originalNode.hasAttribute('playsinline')) {
youtubeSettings.playerVars.playsinline = 1; youtubeSettings.playerVars.playsinline = 1;
} }
if (mediaElement.originalNode.controls) {
youtubeSettings.playerVars.controls = 1;
}
if (mediaElement.originalNode.autoplay) { if (mediaElement.originalNode.autoplay) {
youtubeSettings.playerVars.autoplay = 1; youtubeSettings.playerVars.autoplay = 1;
} }
if (mediaElement.originalNode.loop) { if (mediaElement.originalNode.loop) {
youtubeSettings.playerVars.loop = 1; youtubeSettings.playerVars.loop = 1;
} }
@ -3072,7 +3118,7 @@ _renderer.renderer.add(YouTubeIframeRenderer);
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.cancelFullScreen = exports.requestFullScreen = exports.isFullScreen = exports.FULLSCREEN_EVENT_NAME = exports.HAS_NATIVE_FULLSCREEN_ENABLED = exports.HAS_TRUE_NATIVE_FULLSCREEN = exports.HAS_IOS_FULLSCREEN = exports.HAS_MS_NATIVE_FULLSCREEN = exports.HAS_MOZ_NATIVE_FULLSCREEN = exports.HAS_WEBKIT_NATIVE_FULLSCREEN = exports.HAS_NATIVE_FULLSCREEN = exports.SUPPORTS_NATIVE_HLS = exports.SUPPORT_POINTER_EVENTS = exports.HAS_MSE = exports.IS_STOCK_ANDROID = exports.IS_SAFARI = exports.IS_FIREFOX = exports.IS_CHROME = exports.IS_EDGE = exports.IS_IE = exports.IS_ANDROID = exports.IS_IOS = exports.IS_IPOD = exports.IS_IPHONE = exports.IS_IPAD = exports.UA = exports.NAV = undefined; exports.cancelFullScreen = exports.requestFullScreen = exports.isFullScreen = exports.FULLSCREEN_EVENT_NAME = exports.HAS_NATIVE_FULLSCREEN_ENABLED = exports.HAS_TRUE_NATIVE_FULLSCREEN = exports.HAS_IOS_FULLSCREEN = exports.HAS_MS_NATIVE_FULLSCREEN = exports.HAS_MOZ_NATIVE_FULLSCREEN = exports.HAS_WEBKIT_NATIVE_FULLSCREEN = exports.HAS_NATIVE_FULLSCREEN = exports.SUPPORTS_NATIVE_HLS = exports.SUPPORT_PASSIVE_EVENT = exports.SUPPORT_POINTER_EVENTS = exports.HAS_MSE = exports.IS_STOCK_ANDROID = exports.IS_SAFARI = exports.IS_FIREFOX = exports.IS_CHROME = exports.IS_EDGE = exports.IS_IE = exports.IS_ANDROID = exports.IS_IOS = exports.IS_IPOD = exports.IS_IPHONE = exports.IS_IPAD = exports.UA = exports.NAV = undefined;
var _window = _dereq_(3); var _window = _dereq_(3);
@ -3119,6 +3165,20 @@ var SUPPORT_POINTER_EVENTS = exports.SUPPORT_POINTER_EVENTS = function () {
return !!supports; return !!supports;
}(); }();
var SUPPORT_PASSIVE_EVENT = exports.SUPPORT_PASSIVE_EVENT = function () {
var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});
_window2.default.addEventListener('test', null, opts);
} catch (e) {}
return supportsPassive;
}();
var html5Elements = ['source', 'track', 'audio', 'video']; var html5Elements = ['source', 'track', 'audio', 'video'];
var video = void 0; var video = void 0;
@ -3225,6 +3285,7 @@ _mejs2.default.Features.isStockAndroid = IS_STOCK_ANDROID;
_mejs2.default.Features.hasMSE = HAS_MSE; _mejs2.default.Features.hasMSE = HAS_MSE;
_mejs2.default.Features.supportsNativeHLS = SUPPORTS_NATIVE_HLS; _mejs2.default.Features.supportsNativeHLS = SUPPORTS_NATIVE_HLS;
_mejs2.default.Features.supportsPointerEvents = SUPPORT_POINTER_EVENTS; _mejs2.default.Features.supportsPointerEvents = SUPPORT_POINTER_EVENTS;
_mejs2.default.Features.supportsPassiveEvent = SUPPORT_PASSIVE_EVENT;
_mejs2.default.Features.hasiOSFullScreen = HAS_IOS_FULLSCREEN; _mejs2.default.Features.hasiOSFullScreen = HAS_IOS_FULLSCREEN;
_mejs2.default.Features.hasNativeFullscreen = HAS_NATIVE_FULLSCREEN; _mejs2.default.Features.hasNativeFullscreen = HAS_NATIVE_FULLSCREEN;
_mejs2.default.Features.hasWebkitNativeFullScreen = HAS_WEBKIT_NATIVE_FULLSCREEN; _mejs2.default.Features.hasWebkitNativeFullScreen = HAS_WEBKIT_NATIVE_FULLSCREEN;
@ -3387,7 +3448,10 @@ function siblings(el, filter) {
} }
function visible(elem) { function visible(elem) {
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); if (elem.getClientRects !== undefined && elem.getClientRects === 'function') {
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
}
return !!(elem.offsetWidth || elem.offsetHeight);
} }
function ajax(url, dataType, success, error) { function ajax(url, dataType, success, error) {

File diff suppressed because one or more lines are too long

View File

@ -109,7 +109,8 @@ var DailyMotionIframeRenderer = {
var events = void 0, var events = void 0,
dmPlayer = null, dmPlayer = null,
dmIframe = null; dmIframe = null,
muted = mediaElement.originalNode.muted;
dm.options = options; dm.options = options;
dm.id = mediaElement.id + '_' + options.prefix; dm.id = mediaElement.id + '_' + options.prefix;
@ -136,7 +137,8 @@ var DailyMotionIframeRenderer = {
case 'ended': case 'ended':
return dmPlayer.ended; return dmPlayer.ended;
case 'muted': case 'muted':
return dmPlayer.muted; muted = dmPlayer.muted;
return muted;
case 'buffered': case 'buffered':
var percentLoaded = dmPlayer.bufferedTime, var percentLoaded = dmPlayer.bufferedTime,
duration = dmPlayer.duration; duration = dmPlayer.duration;
@ -172,7 +174,11 @@ var DailyMotionIframeRenderer = {
dmPlayer.seek(value); dmPlayer.seek(value);
break; break;
case 'muted': case 'muted':
if (value === true) {
dmPlayer.setVolume(0);
}
dmPlayer.setMuted(value); dmPlayer.setMuted(value);
muted = value;
setTimeout(function () { setTimeout(function () {
var event = mejs.Utils.createEvent('volumechange', dm); var event = mejs.Utils.createEvent('volumechange', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
@ -180,6 +186,14 @@ var DailyMotionIframeRenderer = {
break; break;
case 'volume': case 'volume':
dmPlayer.setVolume(value); dmPlayer.setVolume(value);
if (value === 0 && !dmPlayer.muted) {
dmPlayer.setMuted(true);
muted = true;
} else if (value > 0 && dmPlayer.muted) {
dmPlayer.setMuted(false);
muted = false;
}
setTimeout(function () { setTimeout(function () {
var event = mejs.Utils.createEvent('volumechange', dm); var event = mejs.Utils.createEvent('volumechange', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
@ -258,8 +272,11 @@ var DailyMotionIframeRenderer = {
} }
if (mediaElement.originalNode.muted) { if (mediaElement.originalNode.muted) {
dmPlayer.setMuted(true);
dmPlayer.setVolume(0); dmPlayer.setVolume(0);
dmPlayer.setMuted(true);
} else {
dmPlayer.setVolume(dmPlayer.volume);
dmPlayer.setMuted(false);
} }
events = mejs.html5media.events; events = mejs.html5media.events;
@ -267,7 +284,7 @@ var DailyMotionIframeRenderer = {
var assignNativeEvents = function assignNativeEvents(eventName) { var assignNativeEvents = function assignNativeEvents(eventName) {
if (eventName !== 'ended') { if (eventName !== 'ended') {
dmPlayer.addEventListener(eventName, function (e) { dmPlayer.addEventListener(eventName, function (e) {
var event = mejs.Utils.createEvent(e.type, dmPlayer); var event = mejs.Utils.createEvent(e.type, dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
} }
@ -278,42 +295,42 @@ var DailyMotionIframeRenderer = {
} }
dmPlayer.addEventListener('ad_start', function () { dmPlayer.addEventListener('ad_start', function () {
var event = mejs.Utils.createEvent('play', dmPlayer); var event = mejs.Utils.createEvent('play', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
event = mejs.Utils.createEvent('progress', dmPlayer); event = mejs.Utils.createEvent('progress', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
event = mejs.Utils.createEvent('timeupdate', dmPlayer); event = mejs.Utils.createEvent('timeupdate', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
dmPlayer.addEventListener('ad_timeupdate', function () { dmPlayer.addEventListener('ad_timeupdate', function () {
var event = mejs.Utils.createEvent('timeupdate', dmPlayer); var event = mejs.Utils.createEvent('timeupdate', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
dmPlayer.addEventListener('ad_pause', function () { dmPlayer.addEventListener('ad_pause', function () {
var event = mejs.Utils.createEvent('pause', dmPlayer); var event = mejs.Utils.createEvent('pause', dm);
mediaElement.dispatchEvent(event);
});
dmPlayer.addEventListener('ad_end', function () {
var event = mejs.Utils.createEvent('ended', dmPlayer);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
dmPlayer.addEventListener('start', function () { dmPlayer.addEventListener('start', function () {
if (mediaElement.originalNode.muted) { if (dmPlayer.muted) {
dmPlayer.setMuted(true); var event = mejs.Utils.createEvent('volumechange', dm);
mediaElement.dispatchEvent(event);
} }
}); });
dmPlayer.addEventListener('video_start', function () { dmPlayer.addEventListener('video_start', function () {
var event = mejs.Utils.createEvent('play', dmPlayer); var event = mejs.Utils.createEvent('play', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
var playingEvent = mejs.Utils.createEvent('playing', dm);
mediaElement.dispatchEvent(playingEvent);
}); });
dmPlayer.addEventListener('ad_timeupdate', function () { dmPlayer.addEventListener('ad_timeupdate', function () {
var event = mejs.Utils.createEvent('timeupdate', dmPlayer); var event = mejs.Utils.createEvent('timeupdate', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}); });
dmPlayer.addEventListener('video_end', function () { dmPlayer.addEventListener('video_end', function () {
var event = mejs.Utils.createEvent('ended', dmPlayer); var event = mejs.Utils.createEvent('ended', dm);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
if (mediaElement.originalNode.getAttribute('loop')) { if (mediaElement.originalNode.getAttribute('loop')) {
@ -339,11 +356,15 @@ var DailyMotionIframeRenderer = {
mediaElement.originalNode.style.display = 'none'; mediaElement.originalNode.style.display = 'none';
var videoId = DailyMotionApi.getDailyMotionId(mediaFiles[0].src), var videoId = DailyMotionApi.getDailyMotionId(mediaFiles[0].src),
dmSettings = Object.assign({ dmSettings = {
id: dm.id, id: dm.id,
container: dmContainer, container: dmContainer,
videoId: videoId videoId: videoId
}, dm.options.dailymotion); };
dmSettings.params = Object.assign({}, dm.options.dailymotion);
dmSettings.params.controls = !!mediaElement.originalNode.controls;
if (mediaElement.originalNode.autoplay) { if (mediaElement.originalNode.autoplay) {
dmSettings.params.autoplay = true; dmSettings.params.autoplay = true;
@ -351,6 +372,7 @@ var DailyMotionIframeRenderer = {
if (mediaElement.originalNode.muted) { if (mediaElement.originalNode.muted) {
dmSettings.params.mute = true; dmSettings.params.mute = true;
} }
dmSettings.params.api = '1';
DailyMotionApi.enqueueIframe(dmSettings); DailyMotionApi.enqueueIframe(dmSettings);

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,30 @@
*/(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict'; 'use strict';
var FacebookApi = {
promise: null,
load: function load(settings) {
if (typeof FB !== 'undefined') {
FacebookApi._createPlayer(settings);
} else {
FacebookApi.promise = FacebookApi.promise || mejs.Utils.loadScript('https://connect.facebook.net/' + settings.options.lang + '/sdk.js');
FacebookApi.promise.then(function () {
FB.init(settings.options);
setTimeout(function () {
FacebookApi._createPlayer(settings);
}, 50);
});
}
},
_createPlayer: function _createPlayer(settings) {
window['__ready__' + settings.id]();
}
};
var FacebookRenderer = { var FacebookRenderer = {
name: 'facebook', name: 'facebook',
options: { options: {
@ -18,7 +42,8 @@ var FacebookRenderer = {
facebook: { facebook: {
appId: '', appId: '',
xfbml: true, xfbml: true,
version: 'v2.10' version: 'v2.10',
lang: 'en_US'
} }
}, },
@ -27,54 +52,50 @@ var FacebookRenderer = {
}, },
create: function create(mediaElement, options, mediaFiles) { create: function create(mediaElement, options, mediaFiles) {
var apiStack = [],
fb = {},
readyState = 4;
var fbWrapper = {}, var hasStartedPlaying = false,
apiStack = [],
eventHandler = {},
readyState = 4,
autoplay = mediaElement.originalNode.autoplay;
var poster = '',
src = '',
paused = true, paused = true,
ended = false, ended = false,
hasStartedPlaying = false, fbPlayer = null,
fbApi = null, src = '',
fbDiv = null; poster = '',
autoplay = mediaElement.originalNode.autoplay;
fb.options = options;
fb.id = mediaElement.id + '_' + options.prefix;
fb.mediaElement = mediaElement;
if (mejs.Features.isiPhone && mediaElement.originalNode.getAttribute('poster')) { if (mejs.Features.isiPhone && mediaElement.originalNode.getAttribute('poster')) {
poster = mediaElement.originalNode.getAttribute('poster'); poster = mediaElement.originalNode.getAttribute('poster');
mediaElement.originalNode.removeAttribute('poster'); mediaElement.originalNode.removeAttribute('poster');
} }
options = Object.assign(options, mediaElement.options);
fbWrapper.options = options;
fbWrapper.id = mediaElement.id + '_' + options.prefix;
fbWrapper.mediaElement = mediaElement;
var props = mejs.html5media.properties, var props = mejs.html5media.properties,
assignGettersSetters = function assignGettersSetters(propName) { assignGettersSetters = function assignGettersSetters(propName) {
var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
fbWrapper['get' + capName] = function () { fb['get' + capName] = function () {
if (fbApi !== null) { if (fbPlayer !== null) {
var value = null; var value = null;
switch (propName) { switch (propName) {
case 'currentTime': case 'currentTime':
return fbApi.getCurrentPosition(); return fbPlayer.getCurrentPosition();
case 'duration': case 'duration':
return fbApi.getDuration(); return fbPlayer.getDuration();
case 'volume': case 'volume':
return fbApi.getVolume(); return fbPlayer.getVolume();
case 'paused': case 'paused':
return paused; return paused;
case 'ended': case 'ended':
return ended; return ended;
case 'muted': case 'muted':
return fbApi.isMuted(); return fbPlayer.isMuted();
case 'buffered': case 'buffered':
return { return {
start: function start() { start: function start() {
@ -97,47 +118,60 @@ var FacebookRenderer = {
} }
}; };
fbWrapper['set' + capName] = function (value) { fb['set' + capName] = function (value) {
if (fbApi !== null) { if (fbPlayer !== null) {
switch (propName) { switch (propName) {
case 'src': case 'src':
var url = typeof value === 'string' ? value : value[0].src; var url = typeof value === 'string' ? value : value[0].src;
src = url;
fbDiv.remove(); fbContainer.remove();
createFacebookEmbed(url, options.facebook); fbContainer = document.createElement('div');
fbContainer.id = fb.id;
fbContainer.className = 'fb-video';
fbContainer.setAttribute('data-href', url);
fbContainer.setAttribute('data-allowfullscreen', 'true');
fbContainer.setAttribute('data-controls', 'false');
mediaElement.originalNode.parentNode.insertBefore(fbContainer, mediaElement.originalNode);
mediaElement.originalNode.style.display = 'none';
FacebookApi.load({
lang: fb.options.lang,
id: fb.id
});
FB.XFBML.parse(); FB.XFBML.parse();
if (autoplay) { if (autoplay) {
fbApi.play(); fbPlayer.play();
} }
break; break;
case 'currentTime': case 'currentTime':
fbApi.seek(value); fbPlayer.seek(value);
break; break;
case 'muted': case 'muted':
if (value) { if (value) {
fbApi.mute(); fbPlayer.mute();
} else { } else {
fbApi.unmute(); fbPlayer.unmute();
} }
setTimeout(function () { setTimeout(function () {
var event = mejs.Utils.createEvent('volumechange', fbWrapper); var event = mejs.Utils.createEvent('volumechange', fb);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}, 50); }, 50);
break; break;
case 'volume': case 'volume':
fbApi.setVolume(value); fbPlayer.setVolume(value);
setTimeout(function () { setTimeout(function () {
var event = mejs.Utils.createEvent('volumechange', fbWrapper); var event = mejs.Utils.createEvent('volumechange', fb);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}, 50); }, 50);
break; break;
case 'readyState': case 'readyState':
var event = mejs.Utils.createEvent('canplay', fbWrapper); var event = mejs.Utils.createEvent('canplay', fb);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
break; break;
default: default:
@ -156,13 +190,13 @@ var FacebookRenderer = {
var methods = mejs.html5media.methods, var methods = mejs.html5media.methods,
assignMethods = function assignMethods(methodName) { assignMethods = function assignMethods(methodName) {
fbWrapper[methodName] = function () { fb[methodName] = function () {
if (fbApi !== null) { if (fbPlayer !== null) {
switch (methodName) { switch (methodName) {
case 'play': case 'play':
return fbApi.play(); return fbPlayer.play();
case 'pause': case 'pause':
return fbApi.pause(); return fbPlayer.pause();
case 'load': case 'load':
return null; return null;
} }
@ -176,165 +210,145 @@ var FacebookRenderer = {
assignMethods(methods[_i]); assignMethods(methods[_i]);
} }
function sendEvents(events) { function assignEvents(events) {
for (var _i2 = 0, _total2 = events.length; _i2 < _total2; _i2++) { for (var _i2 = 0, _total2 = events.length; _i2 < _total2; _i2++) {
var event = mejs.Utils.createEvent(events[_i2], fbWrapper); var event = mejs.Utils.createEvent(events[_i2], fb);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
} }
} }
function createFacebookEmbed(url, config) { window['__ready__' + fb.id] = function () {
src = url; FB.Event.subscribe('xfbml.ready', function (msg) {
if (msg.type === 'video' && fb.id === msg.id) {
mediaElement.fbPlayer = fbPlayer = msg.instance;
fbDiv = document.createElement('div'); var fbIframe = document.getElementById(fb.id),
fbDiv.id = fbWrapper.id; width = fbIframe.offsetWidth,
fbDiv.className = "fb-video"; height = fbIframe.offsetHeight,
fbDiv.setAttribute("data-href", url); events = ['mouseover', 'mouseout'],
fbDiv.setAttribute("data-allowfullscreen", "true"); assignIframeEvents = function assignIframeEvents(e) {
fbDiv.setAttribute("data-controls", "false"); var event = mejs.Utils.createEvent(e.type, fb);
mediaElement.dispatchEvent(event);
};
mediaElement.originalNode.parentNode.insertBefore(fbDiv, mediaElement.originalNode); fb.setSize(width, height);
mediaElement.originalNode.style.display = 'none'; if (!mediaElement.originalNode.muted) {
fbPlayer.unmute();
window.fbAsyncInit = function () {
FB.init(config);
FB.Event.subscribe('xfbml.ready', function (msg) {
if (msg.type === 'video') {
fbApi = msg.instance;
var fbIframe = fbDiv.getElementsByTagName('iframe')[0],
width = fbIframe.offsetWidth,
height = fbIframe.offsetHeight,
events = ['mouseover', 'mouseout'],
assignEvents = function assignEvents(e) {
var event = mejs.Utils.createEvent(e.type, fbWrapper);
mediaElement.dispatchEvent(event);
};
fbWrapper.setSize(width, height);
if (autoplay) {
fbApi.play();
}
for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) {
fbIframe.addEventListener(events[_i3], assignEvents, false);
}
var fbEvents = ['startedPlaying', 'paused', 'finishedPlaying', 'startedBuffering', 'finishedBuffering'];
for (var _i4 = 0, _total4 = fbEvents.length; _i4 < _total4; _i4++) {
var event = fbEvents[_i4],
handler = eventHandler[event];
if (handler !== undefined && handler !== null && !mejs.Utils.isObjectEmpty(handler) && typeof handler.removeListener === 'function') {
handler.removeListener(event);
}
}
if (apiStack.length) {
for (var _i5 = 0, _total5 = apiStack.length; _i5 < _total5; _i5++) {
var stackItem = apiStack[_i5];
if (stackItem.type === 'set') {
var propName = stackItem.propName,
capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
fbWrapper['set' + capName](stackItem.value);
} else if (stackItem.type === 'call') {
fbWrapper[stackItem.methodName]();
}
}
}
sendEvents(['rendererready', 'loadeddata', 'canplay', 'progress', 'loadedmetadata', 'timeupdate']);
var timer = void 0;
eventHandler.startedPlaying = fbApi.subscribe('startedPlaying', function () {
if (!hasStartedPlaying) {
hasStartedPlaying = true;
}
paused = false;
ended = false;
sendEvents(['play', 'playing', 'timeupdate']);
timer = setInterval(function () {
fbApi.getCurrentPosition();
sendEvents(['timeupdate']);
}, 250);
});
eventHandler.paused = fbApi.subscribe('paused', function () {
paused = true;
ended = false;
sendEvents(['pause']);
});
eventHandler.finishedPlaying = fbApi.subscribe('finishedPlaying', function () {
paused = true;
ended = true;
sendEvents(['ended']);
clearInterval(timer);
timer = null;
});
eventHandler.startedBuffering = fbApi.subscribe('startedBuffering', function () {
sendEvents(['progress', 'timeupdate']);
});
eventHandler.finishedBuffering = fbApi.subscribe('finishedBuffering', function () {
sendEvents(['progress', 'timeupdate']);
});
} }
});
};
mejs.Utils.loadScript('https://connect.facebook.net/en_US/sdk.js'); if (autoplay) {
} fbPlayer.play();
}
if (mediaFiles.length > 0) { for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) {
createFacebookEmbed(mediaFiles[0].src, fbWrapper.options.facebook); fbIframe.addEventListener(events[_i3], assignIframeEvents);
} }
fbWrapper.hide = function () { fb.eventHandler = {};
fbWrapper.stopInterval();
fbWrapper.pause(); var fbEvents = ['startedPlaying', 'paused', 'finishedPlaying', 'startedBuffering', 'finishedBuffering'];
if (fbDiv) { for (var _i4 = 0, _total4 = fbEvents.length; _i4 < _total4; _i4++) {
fbDiv.style.display = 'none'; var event = fbEvents[_i4],
handler = fb.eventHandler[event];
if (handler !== undefined && handler !== null && !mejs.Utils.isObjectEmpty(handler) && typeof handler.removeListener === 'function') {
handler.removeListener(event);
}
}
if (apiStack.length) {
for (var _i5 = 0, _total5 = apiStack.length; _i5 < _total5; _i5++) {
var stackItem = apiStack[_i5];
if (stackItem.type === 'set') {
var propName = stackItem.propName,
capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
fb['set' + capName](stackItem.value);
} else if (stackItem.type === 'call') {
fb[stackItem.methodName]();
}
}
}
assignEvents(['rendererready', 'loadeddata', 'canplay', 'progress', 'loadedmetadata', 'timeupdate']);
var timer = void 0;
fb.eventHandler.startedPlaying = fbPlayer.subscribe('startedPlaying', function () {
if (!hasStartedPlaying) {
hasStartedPlaying = true;
}
paused = false;
ended = false;
assignEvents(['play', 'playing', 'timeupdate']);
timer = setInterval(function () {
fbPlayer.getCurrentPosition();
assignEvents(['timeupdate']);
}, 250);
});
fb.eventHandler.paused = fbPlayer.subscribe('paused', function () {
paused = true;
ended = false;
assignEvents(['pause']);
});
fb.eventHandler.finishedPlaying = fbPlayer.subscribe('finishedPlaying', function () {
paused = true;
ended = true;
assignEvents(['ended']);
clearInterval(timer);
timer = null;
});
fb.eventHandler.startedBuffering = fbPlayer.subscribe('startedBuffering', function () {
assignEvents(['progress', 'timeupdate']);
});
fb.eventHandler.finishedBuffering = fbPlayer.subscribe('finishedBuffering', function () {
assignEvents(['progress', 'timeupdate']);
});
}
});
};
src = mediaFiles[0].src;
var fbContainer = document.createElement('div');
fbContainer.id = fb.id;
fbContainer.className = 'fb-video';
fbContainer.setAttribute('data-href', src);
fbContainer.setAttribute('data-allowfullscreen', true);
fbContainer.setAttribute('data-controls', !!mediaElement.originalNode.controls);
mediaElement.originalNode.parentNode.insertBefore(fbContainer, mediaElement.originalNode);
mediaElement.originalNode.style.display = 'none';
FacebookApi.load({
options: fb.options.facebook,
id: fb.id
});
fb.hide = function () {
fb.pause();
if (fbPlayer) {
fbContainer.style.display = 'none';
} }
}; };
fbWrapper.show = function () { fb.setSize = function (width) {
if (fbDiv) { if (fbPlayer !== null && !isNaN(width)) {
fbDiv.style.display = ''; fbContainer.style.width = width;
} }
}; };
fbWrapper.setSize = function (width) { fb.show = function () {
if (fbApi !== null && !isNaN(width)) { if (fbPlayer) {
fbDiv.style.width = width; fbContainer.style.display = '';
} }
}; };
fbWrapper.destroy = function () {
fb.destroy = function () {
if (poster) { if (poster) {
mediaElement.originalNode.setAttribute('poster', poster); mediaElement.originalNode.setAttribute('poster', poster);
} }
}; };
fbWrapper.interval = null; return fb;
fbWrapper.startInterval = function () {
fbWrapper.interval = setInterval(function () {
var event = mejs.Utils.createEvent('timeupdate', fbWrapper);
mediaElement.dispatchEvent(event);
}, 250);
};
fbWrapper.stopInterval = function () {
if (fbWrapper.interval) {
clearInterval(fbWrapper.interval);
}
};
return fbWrapper;
} }
}; };

File diff suppressed because one or more lines are too long

View File

@ -62,10 +62,10 @@ var TwitchApi = {
for (var i = 0, total = parameters.length; i < total; i++) { for (var i = 0, total = parameters.length; i < total; i++) {
var paramParts = parameters[i].split('='); var paramParts = parameters[i].split('=');
if (~paramParts[0].indexOf('channel=')) { if (~paramParts[0].indexOf('channel')) {
twitchId = paramParts[1]; twitchId = paramParts[1];
break; break;
} else if (~paramParts[0].indexOf('video=')) { } else if (~paramParts[0].indexOf('video')) {
twitchId = 'v' + paramParts[1]; twitchId = 'v' + paramParts[1];
break; break;
} }
@ -82,12 +82,12 @@ var TwitchApi = {
var parts = url.split('?'); var parts = url.split('?');
url = parts[0]; url = parts[0];
var id = url.substring(url.lastIndexOf('/') + 1); var id = url.substring(url.lastIndexOf('/') + 1);
return (/^\d+$/i.test(id) !== null ? 'v' + id : id return (/^\d+$/i.test(id) ? 'v' + id : id
); );
}, },
getTwitchType: function getTwitchType(id) { getTwitchType: function getTwitchType(id) {
return (/^v\d+/i.test(id) !== null ? 'video' : 'channel' return (/^v\d+/i.test(id) ? 'video' : 'channel'
); );
} }
}; };
@ -276,7 +276,7 @@ var TwitchIframeRenderer = {
var events = ['mouseover', 'mouseout'], var events = ['mouseover', 'mouseout'],
assignEvents = function assignEvents(e) { assignEvents = function assignEvents(e) {
var event = createEvent(e.type, twitch); var event = mejs.Utils.createEvent(e.type, twitch);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
}; };
@ -286,12 +286,12 @@ var TwitchIframeRenderer = {
var timer = void 0; var timer = void 0;
twitchPlayer.addEventListener('ready', function () { twitchPlayer.addEventListener(Twitch.Player.READY, function () {
paused = false; paused = false;
ended = false; ended = false;
sendEvents(['rendererready', 'loadedmetadata', 'loadeddata', 'canplay']); sendEvents(['rendererready', 'loadedmetadata', 'loadeddata', 'canplay']);
}); });
twitchPlayer.addEventListener('play', function () { twitchPlayer.addEventListener(Twitch.Player.PLAY, function () {
if (!hasStartedPlaying) { if (!hasStartedPlaying) {
hasStartedPlaying = true; hasStartedPlaying = true;
} }
@ -304,14 +304,14 @@ var TwitchIframeRenderer = {
sendEvents(['timeupdate']); sendEvents(['timeupdate']);
}, 250); }, 250);
}); });
twitchPlayer.addEventListener('pause', function () { twitchPlayer.addEventListener(Twitch.Player.PAUSE, function () {
paused = true; paused = true;
ended = false; ended = false;
if (!twitchPlayer.getEnded()) { if (!twitchPlayer.getEnded()) {
sendEvents(['pause']); sendEvents(['pause']);
} }
}); });
twitchPlayer.addEventListener('ended', function () { twitchPlayer.addEventListener(Twitch.Player.ENDED, function () {
paused = true; paused = true;
ended = true; ended = true;
sendEvents(['ended']); sendEvents(['ended']);

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ var VimeoApi = {
var parts = url.split('?'); var parts = url.split('?');
url = parts[0]; url = parts[0];
return parseInt(url.substring(url.lastIndexOf('/') + 1)); return parseInt(url.substring(url.lastIndexOf('/') + 1), 10);
} }
}; };
@ -256,6 +256,11 @@ var vimeoIframeRenderer = {
} }
} }
if (mediaElement.originalNode.muted) {
vimeoPlayer.setVolume(0);
volume = 0;
}
var vimeoIframe = document.getElementById(vimeo.id); var vimeoIframe = document.getElementById(vimeo.id);
var events = void 0; var events = void 0;
@ -295,6 +300,9 @@ var vimeoIframeRenderer = {
if (mediaElement.originalNode.autoplay) { if (mediaElement.originalNode.autoplay) {
var initEvent = mejs.Utils.createEvent('play', vimeo); var initEvent = mejs.Utils.createEvent('play', vimeo);
mediaElement.dispatchEvent(initEvent); mediaElement.dispatchEvent(initEvent);
var playingEvent = mejs.Utils.createEvent('playing', vimeo);
mediaElement.dispatchEvent(playingEvent);
} }
} }
@ -319,6 +327,9 @@ var vimeoIframeRenderer = {
ended = false; ended = false;
var event = mejs.Utils.createEvent('play', vimeo); var event = mejs.Utils.createEvent('play', vimeo);
mediaElement.dispatchEvent(event); mediaElement.dispatchEvent(event);
var playingEvent = mejs.Utils.createEvent('playing', vimeo);
mediaElement.dispatchEvent(playingEvent);
}); });
vimeoPlayer.on('pause', function () { vimeoPlayer.on('pause', function () {
paused = true; paused = true;

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@
settings = $.extend( true, {}, _wpmejsSettings ); settings = $.extend( true, {}, _wpmejsSettings );
} }
settings.classPrefix = 'mejs-'; settings.classPrefix = 'mejs-';
settings.success = settings.success || function (mejs) { settings.success = settings.success || function ( mejs ) {
var autoplay, loop; var autoplay, loop;
if ( mejs.rendererName && -1 !== mejs.rendererName.indexOf( 'flash' ) ) { if ( mejs.rendererName && -1 !== mejs.rendererName.indexOf( 'flash' ) ) {

View File

@ -352,7 +352,9 @@ 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-74e01a40', 1 ); $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.6-78496d1' );
$scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player.min.js", array(), '4.2.6-78496d1', 1 );
$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 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(
@ -444,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-74e01a40', 1 ); $scripts->add( 'mediaelement-vimeo', "/wp-includes/js/mediaelement/renderers/vimeo.min.js", array('mediaelement'), '4.2.6-78496d1', 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' ),
@ -989,7 +991,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-74e01a40' ); $styles->add( 'mediaelement', "/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css", array(), '4.2.6-78496d1' );
$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' ) );
$styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' ); $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-beta2-41876'; $wp_version = '4.9-beta2-41877';
/** /**
* 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.