' + e.message + '
'; + } + + if (e.urls) { + for (var i = 0, total = e.urls.length; i < total; i++) { + var url = e.urls[i]; + errorContent += '' + _mejs2.default.i18n.t('mejs.download-file') + ': ' + url.src + ''; + } + } + } + + if (errorContent && t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error')) { + errorContainer.innerHTML = errorContent; + t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').innerHTML = errorContainer.outerHTML; + t.layers.querySelector('.' + t.options.classPrefix + 'overlay-error').parentNode.style.display = 'block'; + } + } + }, { + key: 'setPlayerSize', + value: function setPlayerSize(width, height) { + var t = this; + + if (!t.options.setDimensions) { + return false; + } + + if (typeof width !== 'undefined') { + t.width = width; + } + + if (typeof height !== 'undefined') { + t.height = height; + } + + switch (t.options.stretching) { + case 'fill': + if (t.isVideo) { + t.setFillMode(); + } else { + t.setDimensions(t.width, t.height); + } + break; + case 'responsive': + t.setResponsiveMode(); + break; + case 'none': + t.setDimensions(t.width, t.height); + break; + + default: + if (t.hasFluidMode() === true) { + t.setResponsiveMode(); + } else { + t.setDimensions(t.width, t.height); + } + break; + } + } + }, { + key: 'hasFluidMode', + value: function hasFluidMode() { + var t = this; + + return t.height.toString().indexOf('%') !== -1 || t.node && t.node.style.maxWidth && t.node.style.maxWidth !== 'none' && t.node.style.maxWidth !== t.width || t.node && t.node.currentStyle && t.node.currentStyle.maxWidth === '100%'; + } + }, { + key: 'setResponsiveMode', + value: function setResponsiveMode() { + var t = this, + parent = function () { + + var parentEl = void 0, + el = t.container; + + while (el) { + try { + if (_constants.IS_FIREFOX && el.tagName.toLowerCase() === 'html' && _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null) { + return _window2.default.frameElement; + } else { + parentEl = el.parentElement; + } + } catch (e) { + parentEl = el.parentElement; + } + + if (parentEl && dom.visible(parentEl)) { + return parentEl; + } + el = parentEl; + } + + return null; + }(), + parentStyles = parent ? getComputedStyle(parent, null) : getComputedStyle(_document2.default.body, null), + nativeWidth = function () { + if (t.isVideo) { + if (t.media.videoWidth && t.media.videoWidth > 0) { + return t.media.videoWidth; + } else if (t.node.getAttribute('width')) { + return t.node.getAttribute('width'); + } else { + return t.options.defaultVideoWidth; + } + } else { + return t.options.defaultAudioWidth; + } + }(), + nativeHeight = function () { + if (t.isVideo) { + if (t.media.videoHeight && t.media.videoHeight > 0) { + return t.media.videoHeight; + } else if (t.node.getAttribute('height')) { + return t.node.getAttribute('height'); + } else { + return t.options.defaultVideoHeight; + } + } else { + return t.options.defaultAudioHeight; + } + }(), + aspectRatio = function () { + var ratio = 1; + if (!t.isVideo) { + return ratio; + } + + if (t.media.videoWidth && t.media.videoWidth > 0 && t.media.videoHeight && t.media.videoHeight > 0) { + ratio = t.height >= t.width ? t.media.videoWidth / t.media.videoHeight : t.media.videoHeight / t.media.videoWidth; + } else { + ratio = t.initialAspectRatio; + } + + if (isNaN(ratio) || ratio < 0.01 || ratio > 100) { + ratio = 1; + } + + return ratio; + }(), + parentHeight = parseFloat(parentStyles.height); + + var newHeight = void 0, + parentWidth = parseFloat(parentStyles.width); + + if (t.isVideo) { + if (t.height === '100%') { + newHeight = parseFloat(parentWidth * nativeHeight / nativeWidth, 10); + } else { + newHeight = t.height >= t.width ? parseFloat(parentWidth / aspectRatio, 10) : parseFloat(parentWidth * aspectRatio, 10); + } + } else { + newHeight = nativeHeight; + } + + if (isNaN(newHeight)) { + newHeight = parentHeight; + } + + if (t.container.parentNode.length > 0 && t.container.parentNode.tagName.toLowerCase() === 'body') { + parentWidth = _window2.default.innerWidth || _document2.default.documentElement.clientWidth || _document2.default.body.clientWidth; + newHeight = _window2.default.innerHeight || _document2.default.documentElement.clientHeight || _document2.default.body.clientHeight; + } + + if (newHeight && parentWidth) { + t.container.style.width = parentWidth + 'px'; + t.container.style.height = newHeight + 'px'; + + t.node.style.width = '100%'; + t.node.style.height = '100%'; + + if (t.isVideo && t.media.setSize) { + t.media.setSize(parentWidth, newHeight); + } + + var layerChildren = t.layers.children; + for (var i = 0, total = layerChildren.length; i < total; i++) { + layerChildren[i].style.width = '100%'; + layerChildren[i].style.height = '100%'; + } + } + } + }, { + key: 'setFillMode', + value: function setFillMode() { + var t = this; + + var parent = void 0, + isIframe = false; + + try { + if (_window2.default.self !== _window2.default.top) { + isIframe = true; + parent = _window2.default.frameElement; + } else { + parent = t.outerContainer; + } + } catch (e) { + parent = t.outerContainer; + } + + var parentStyles = getComputedStyle(parent); + + if (t.node.style.height !== 'none' && t.node.style.height !== t.height) { + t.node.style.height = 'auto'; + } + if (t.node.style.maxWidth !== 'none' && t.node.style.maxWidth !== t.width) { + t.node.style.maxWidth = 'none'; + } + + if (t.node.style.maxHeight !== 'none' && t.node.style.maxHeight !== t.height) { + t.node.style.maxHeight = 'none'; + } + + if (t.node.currentStyle) { + if (t.node.currentStyle.height === '100%') { + t.node.currentStyle.height = 'auto'; + } + if (t.node.currentStyle.maxWidth === '100%') { + t.node.currentStyle.maxWidth = 'none'; + } + if (t.node.currentStyle.maxHeight === '100%') { + t.node.currentStyle.maxHeight = 'none'; + } + } + + if (!isIframe && !parseFloat(parentStyles.width)) { + parent.style.width = t.media.offsetWidth + 'px'; + } + + if (!isIframe && !parseFloat(parentStyles.height)) { + parent.style.height = t.media.offsetHeight + 'px'; + } + + parentStyles = getComputedStyle(parent); + + var parentWidth = parseFloat(parentStyles.width), + parentHeight = parseFloat(parentStyles.height); + + t.setDimensions('100%', '100%'); + + var poster = t.container.querySelector('.' + t.options.classPrefix + 'poster>img'); + if (poster) { + poster.style.display = ''; + } + + var targetElement = t.container.querySelectorAll('object, embed, iframe, video'), + initHeight = t.height, + initWidth = t.width, + scaleX1 = parentWidth, + scaleY1 = initHeight * parentWidth / initWidth, + scaleX2 = initWidth * parentHeight / initHeight, + scaleY2 = parentHeight, + bScaleOnWidth = scaleX2 > parentWidth === false, + finalWidth = bScaleOnWidth ? Math.floor(scaleX1) : Math.floor(scaleX2), + finalHeight = bScaleOnWidth ? Math.floor(scaleY1) : Math.floor(scaleY2), + width = bScaleOnWidth ? parentWidth + 'px' : finalWidth + 'px', + height = bScaleOnWidth ? finalHeight + 'px' : parentHeight + 'px'; + + for (var i = 0, total = targetElement.length; i < total; i++) { + targetElement[i].style.height = height; + targetElement[i].style.width = width; + if (t.media.setSize) { + t.media.setSize(width, height); + } + + targetElement[i].style.marginLeft = Math.floor((parentWidth - finalWidth) / 2) + 'px'; + targetElement[i].style.marginTop = 0; + } + } + }, { + key: 'setDimensions', + value: function setDimensions(width, height) { + var t = this; + + width = (0, _general.isString)(width) && width.indexOf('%') > -1 ? width : parseFloat(width) + 'px'; + height = (0, _general.isString)(height) && height.indexOf('%') > -1 ? height : parseFloat(height) + 'px'; + + t.container.style.width = width; + t.container.style.height = height; + + var layers = t.layers.children; + for (var i = 0, total = layers.length; i < total; i++) { + layers[i].style.width = width; + layers[i].style.height = height; + } + } + }, { + key: 'setControlsSize', + value: function setControlsSize() { + var t = this; + + if (!dom.visible(t.container)) { + return; + } + + if (t.rail && dom.visible(t.rail)) { + var totalStyles = t.total ? getComputedStyle(t.total, null) : null, + totalMargin = totalStyles ? parseFloat(totalStyles.marginLeft) + parseFloat(totalStyles.marginRight) : 0, + railStyles = getComputedStyle(t.rail), + railMargin = parseFloat(railStyles.marginLeft) + parseFloat(railStyles.marginRight); + + var siblingsWidth = 0; + + var siblings = dom.siblings(t.rail, function (el) { + return el !== t.rail; + }), + total = siblings.length; + for (var i = 0; i < total; i++) { + siblingsWidth += siblings[i].offsetWidth; + } + + siblingsWidth += totalMargin + (totalMargin === 0 ? railMargin * 2 : railMargin) + 1; + + t.container.style.minWidth = siblingsWidth + 'px'; + + var event = (0, _general.createEvent)('controlsresize', t.container); + t.container.dispatchEvent(event); + } else { + var children = t.controls.children; + var minWidth = 0; + + for (var _i = 0, _total = children.length; _i < _total; _i++) { + minWidth += children[_i].offsetWidth; + } + + t.container.style.minWidth = minWidth + 'px'; + } + } + }, { + key: 'addControlElement', + value: function addControlElement(element, key) { + + var t = this; + + if (t.featurePosition[key] !== undefined) { + var child = t.controls.children[t.featurePosition[key] - 1]; + child.parentNode.insertBefore(element, child.nextSibling); + } else { + t.controls.appendChild(element); + var children = t.controls.children; + for (var i = 0, total = children.length; i < total; i++) { + if (element === children[i]) { + t.featurePosition[key] = i; + break; + } + } + } + } + }, { + key: 'createIframeLayer', + value: function createIframeLayer() { + var t = this; + + if (t.isVideo && t.media.rendererName !== null && t.media.rendererName.indexOf('iframe') > -1 && !_document2.default.getElementById(t.media.id + '-iframe-overlay')) { + + var layer = _document2.default.createElement('div'), + target = _document2.default.getElementById(t.media.id + '_' + t.media.rendererName); + + layer.id = t.media.id + '-iframe-overlay'; + layer.className = t.options.classPrefix + 'iframe-overlay'; + layer.addEventListener('click', function (e) { + if (t.options.clickToPlayPause) { + if (t.paused) { + t.play(); + } else { + t.pause(); + } + + e.preventDefault(); + e.stopPropagation(); + } + }); + + target.parentNode.insertBefore(layer, target); + } + } + }, { + key: 'resetSize', + value: function resetSize() { + var t = this; + + setTimeout(function () { + t.setPlayerSize(t.width, t.height); + t.setControlsSize(); + }, 50); + } + }, { + key: 'setPoster', + value: function setPoster(url) { + var t = this; + + var posterDiv = t.container.querySelector('.' + t.options.classPrefix + 'poster'); + + if (!posterDiv) { + posterDiv = _document2.default.createElement('div'); + posterDiv.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; + t.layers.appendChild(posterDiv); + } + + var posterImg = posterDiv.querySelector('img'); + + if (!posterImg && url) { + posterImg = _document2.default.createElement('img'); + posterImg.className = t.options.classPrefix + 'poster-img'; + posterImg.width = '100%'; + posterImg.height = '100%'; + posterDiv.style.display = ''; + posterDiv.appendChild(posterImg); + } + + if (url) { + posterImg.setAttribute('src', url); + posterDiv.style.backgroundImage = 'url("' + url + '")'; + posterDiv.style.display = ''; + } else if (posterImg) { + posterDiv.style.backgroundImage = 'none'; + posterDiv.style.display = 'none'; + posterImg.remove(); + } else { + posterDiv.style.display = 'none'; + } + } + }, { + key: 'changeSkin', + value: function changeSkin(className) { + var t = this; + + t.container.className = t.options.classPrefix + 'container ' + className; + t.setPlayerSize(t.width, t.height); + t.setControlsSize(); + } + }, { + key: 'globalBind', + value: function globalBind(events, callback) { + var t = this, + doc = t.node ? t.node.ownerDocument : _document2.default; + + events = (0, _general.splitEvents)(events, t.id); + if (events.d) { + var eventList = events.d.split(' '); + for (var i = 0, total = eventList.length; i < total; i++) { + eventList[i].split('.').reduce(function (part, e) { + doc.addEventListener(e, callback, false); + return e; + }, ''); + } + } + if (events.w) { + var _eventList = events.w.split(' '); + for (var _i2 = 0, _total2 = _eventList.length; _i2 < _total2; _i2++) { + _eventList[_i2].split('.').reduce(function (part, e) { + _window2.default.addEventListener(e, callback, false); + return e; + }, ''); + } + } + } + }, { + key: 'globalUnbind', + value: function globalUnbind(events, callback) { + var t = this, + doc = t.node ? t.node.ownerDocument : _document2.default; + + events = (0, _general.splitEvents)(events, t.id); + if (events.d) { + var eventList = events.d.split(' '); + for (var i = 0, total = eventList.length; i < total; i++) { + eventList[i].split('.').reduce(function (part, e) { + doc.removeEventListener(e, callback, false); + return e; + }, ''); + } + } + if (events.w) { + var _eventList2 = events.w.split(' '); + for (var _i3 = 0, _total3 = _eventList2.length; _i3 < _total3; _i3++) { + _eventList2[_i3].split('.').reduce(function (part, e) { + _window2.default.removeEventListener(e, callback, false); + return e; + }, ''); + } + } + } + }, { + key: 'buildposter', + value: function buildposter(player, controls, layers, media) { + var t = this, + poster = _document2.default.createElement('div'); + + poster.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; + layers.appendChild(poster); + + var posterUrl = media.originalNode.getAttribute('poster'); + + if (player.options.poster !== '' && posterUrl && _constants.IS_IOS) { + media.originalNode.removeAttribute('poster'); + posterUrl = player.options.poster; + } + + if (posterUrl) { + t.setPoster(posterUrl); + } else if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { + t.setPoster(t.media.renderer.getPosterUrl()); + } else { + poster.style.display = 'none'; + } + + media.addEventListener('play', function () { + poster.style.display = 'none'; + }); + + media.addEventListener('playing', function () { + poster.style.display = 'none'; + }); + + if (player.options.showPosterWhenEnded && player.options.autoRewind) { + media.addEventListener('ended', function () { + poster.style.display = ''; + }); + } + + media.addEventListener('error', function () { + poster.style.display = 'none'; + }); + + if (player.options.showPosterWhenPaused) { + media.addEventListener('pause', function () { + if (!player.ended) { + poster.style.display = ''; + } + }); + } + } + }, { + key: 'buildoverlays', + value: function buildoverlays(player, controls, layers, media) { + + if (!player.isVideo) { + return; + } + + var t = this, + loading = _document2.default.createElement('div'), + error = _document2.default.createElement('div'), + bigPlay = _document2.default.createElement('div'), + buffer = controls.querySelector('.' + t.options.classPrefix + 'time-buffering'); + + loading.style.display = 'none'; + loading.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; + loading.innerHTML = ' '; + layers.appendChild(loading); + + error.style.display = 'none'; + error.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; + error.innerHTML = ''; + layers.appendChild(error); + + bigPlay.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer ' + t.options.classPrefix + 'overlay-play'; + bigPlay.innerHTML = ''); + bigPlay.addEventListener('click', function () { + if (t.options.clickToPlayPause) { + + var button = t.container.querySelector('.' + t.options.classPrefix + 'overlay-button'), + pressed = button.getAttribute('aria-pressed'); + + if (t.paused) { + t.play(); + } else { + t.pause(); + } + + button.setAttribute('aria-pressed', !!pressed); + t.container.focus(); + } + }); + + bigPlay.addEventListener('keydown', function (e) { + var keyPressed = e.keyCode || e.which || 0; + + if (keyPressed === 13 || _constants.IS_FIREFOX && keyPressed === 32) { + var event = (0, _general.createEvent)('click', bigPlay); + bigPlay.dispatchEvent(event); + return false; + } + }); + + layers.appendChild(bigPlay); + + if (t.media.rendererName !== null && (/(youtube|facebook)/i.test(t.media.rendererName) && !(t.media.originalNode.getAttribute('poster') || player.options.poster || typeof t.media.renderer.getPosterUrl === 'function' && t.media.renderer.getPosterUrl()) || _constants.IS_STOCK_ANDROID)) { + bigPlay.style.display = 'none'; + } + + var hasError = false; + + media.addEventListener('play', function () { + bigPlay.style.display = 'none'; + loading.style.display = 'none'; + if (buffer !== null) { + buffer.style.display = 'none'; + } + error.style.display = 'none'; + hasError = false; + }); + media.addEventListener('playing', function () { + bigPlay.style.display = 'none'; + loading.style.display = 'none'; + if (buffer !== null) { + buffer.style.display = 'none'; + } + error.style.display = 'none'; + hasError = false; + }); + media.addEventListener('seeking', function () { + bigPlay.style.display = 'none'; + loading.style.display = ''; + if (buffer !== null) { + buffer.style.display = ''; + } + hasError = false; + }); + media.addEventListener('seeked', function () { + bigPlay.style.display = t.paused && !_constants.IS_STOCK_ANDROID ? '' : 'none'; + loading.style.display = 'none'; + if (buffer !== null) { + buffer.style.display = 'none'; + } + hasError = false; + }); + media.addEventListener('pause', function () { + loading.style.display = 'none'; + if (!_constants.IS_STOCK_ANDROID && !hasError) { + bigPlay.style.display = ''; + } + if (buffer !== null) { + buffer.style.display = 'none'; + } + hasError = false; + }); + media.addEventListener('waiting', function () { + loading.style.display = ''; + if (buffer !== null) { + buffer.style.display = ''; + } + hasError = false; + }); + + media.addEventListener('loadeddata', function () { + loading.style.display = ''; + if (buffer !== null) { + buffer.style.display = ''; + } + + if (_constants.IS_ANDROID) { + media.canplayTimeout = setTimeout(function () { + if (_document2.default.createEvent) { + var evt = _document2.default.createEvent('HTMLEvents'); + evt.initEvent('canplay', true, true); + return media.dispatchEvent(evt); + } + }, 300); + } + hasError = false; + }); + media.addEventListener('canplay', function () { + loading.style.display = 'none'; + if (buffer !== null) { + buffer.style.display = 'none'; + } + + clearTimeout(media.canplayTimeout); + hasError = false; + }); + + media.addEventListener('error', function (e) { + t._handleError(e, t.media, t.node); + loading.style.display = 'none'; + bigPlay.style.display = 'none'; + if (buffer !== null) { + buffer.style.display = 'none'; + } + hasError = true; + }); + + media.addEventListener('keydown', function (e) { + t.onkeydown(player, media, e); + hasError = false; + }); + } + }, { + key: 'buildkeyboard', + value: function buildkeyboard(player, controls, layers, media) { + + var t = this; + + t.container.addEventListener('keydown', function () { + t.keyboardAction = true; + }); + + t.globalKeydownCallback = function (event) { + var container = _document2.default.activeElement.closest('.' + t.options.classPrefix + 'container'), + target = t.media.closest('.' + t.options.classPrefix + 'container'); + t.hasFocus = !!(container && target && container.id === target.id); + return t.onkeydown(player, media, event); + }; + + t.globalClickCallback = function (event) { + t.hasFocus = !!event.target.closest('.' + t.options.classPrefix + 'container'); + }; + + t.globalBind('keydown', t.globalKeydownCallback); + + t.globalBind('click', t.globalClickCallback); + } + }, { + key: 'onkeydown', + value: function onkeydown(player, media, e) { + + if (player.hasFocus && player.options.enableKeyboard) { + for (var i = 0, total = player.options.keyActions.length; i < total; i++) { + var keyAction = player.options.keyActions[i]; + + for (var j = 0, jl = keyAction.keys.length; j < jl; j++) { + if (e.keyCode === keyAction.keys[j]) { + keyAction.action(player, media, e.keyCode, e); + e.preventDefault(); + e.stopPropagation(); + } + } + } + } + + return true; + } + }, { + key: 'play', + value: function play() { + this.proxy.play(); + } + }, { + key: 'pause', + value: function pause() { + this.proxy.pause(); + } + }, { + key: 'load', + value: function load() { + this.proxy.load(); + } + }, { + key: 'setCurrentTime', + value: function setCurrentTime(time) { + this.proxy.setCurrentTime(time); + } + }, { + key: 'getCurrentTime', + value: function getCurrentTime() { + return this.proxy.currentTime; + } + }, { + key: 'getDuration', + value: function getDuration() { + return this.proxy.duration; + } + }, { + key: 'setVolume', + value: function setVolume(volume) { + this.proxy.volume = volume; + } + }, { + key: 'getVolume', + value: function getVolume() { + return this.proxy.getVolume(); + } + }, { + key: 'setMuted', + value: function setMuted(value) { + this.proxy.setMuted(value); + } + }, { + key: 'setSrc', + value: function setSrc(src) { + if (!this.controlsEnabled) { + this.enableControls(); + } + this.proxy.setSrc(src); + } + }, { + key: 'getSrc', + value: function getSrc() { + return this.proxy.getSrc(); + } + }, { + key: 'canPlayType', + value: function canPlayType(type) { + return this.proxy.canPlayType(type); + } + }, { + key: 'remove', + value: function remove() { + var t = this, + rendererName = t.media.rendererName, + src = t.media.originalNode.src; + + for (var featureIndex in t.options.features) { + var feature = t.options.features[featureIndex]; + if (t['clean' + feature]) { + try { + t['clean' + feature](t, t.layers, t.controls, t.media); + } catch (e) { + console.error('error cleaning ' + feature, e); + } + } + } + + var nativeWidth = t.node.getAttribute('width'), + nativeHeight = t.node.getAttribute('height'); + + if (nativeWidth) { + if (nativeWidth.indexOf('%') === -1) { + nativeWidth = nativeWidth + 'px'; + } + } else { + nativeWidth = 'auto'; + } + + if (nativeHeight) { + if (nativeHeight.indexOf('%') === -1) { + nativeHeight = nativeHeight + 'px'; + } + } else { + nativeHeight = 'auto'; + } + + t.node.style.width = nativeWidth; + t.node.style.height = nativeHeight; + + if (!t.isDynamic) { + (function () { + t.node.setAttribute('controls', true); + t.node.setAttribute('id', t.node.getAttribute('id').replace('_' + rendererName, '').replace('_from_mejs', '')); + var poster = t.container.querySelector('.' + t.options.classPrefix + 'poster>img'); + if (poster) { + t.node.setAttribute('poster', poster.src); + } + + delete t.node.autoplay; + + if (t.media.canPlayType((0, _media.getTypeFromFile)(src)) !== '') { + t.node.setAttribute('src', src); + } + + if (~rendererName.indexOf('iframe')) { + var layer = _document2.default.getElementById(t.media.id + '-iframe-overlay'); + layer.remove(); + } + + var node = t.node.cloneNode(); + node.style.display = ''; + t.container.parentNode.insertBefore(node, t.container); + t.node.remove(); + + if (t.mediaFiles) { + for (var i = 0, total = t.mediaFiles.length; i < total; i++) { + var source = _document2.default.createElement('source'); + source.setAttribute('src', t.mediaFiles[i].src); + source.setAttribute('type', t.mediaFiles[i].type); + node.appendChild(source); + } + } + if (t.trackFiles) { + var _loop3 = function _loop3(_i4, _total4) { + var track = t.trackFiles[_i4]; + var newTrack = _document2.default.createElement('track'); + newTrack.kind = track.kind; + newTrack.label = track.label; + newTrack.srclang = track.srclang; + newTrack.src = track.src; + + node.appendChild(newTrack); + newTrack.addEventListener('load', function () { + this.mode = 'showing'; + node.textTracks[_i4].mode = 'showing'; + }); + }; + + for (var _i4 = 0, _total4 = t.trackFiles.length; _i4 < _total4; _i4++) { + _loop3(_i4, _total4); + } + } + + delete t.node; + delete t.mediaFiles; + delete t.trackFiles; + })(); + } else { + t.container.parentNode.insertBefore(t.node, t.container); + } + + if (typeof t.media.renderer.destroy === 'function') { + t.media.renderer.destroy(); + } + + delete _mejs2.default.players[t.id]; + + if (_typeof(t.container) === 'object') { + var offscreen = t.container.parentNode.querySelector('.' + t.options.classPrefix + 'offscreen'); + offscreen.remove(); + t.container.remove(); + } + t.globalUnbind('resize', t.globalResizeCallback); + t.globalUnbind('keydown', t.globalKeydownCallback); + t.globalUnbind('click', t.globalClickCallback); + + delete t.media.player; + } + }, { + key: 'paused', + get: function get() { + return this.proxy.paused; + } + }, { + key: 'muted', + get: function get() { + return this.proxy.muted; + }, + set: function set(muted) { + this.setMuted(muted); + } + }, { + key: 'ended', + get: function get() { + return this.proxy.ended; + } + }, { + key: 'readyState', + get: function get() { + return this.proxy.readyState; + } + }, { + key: 'currentTime', + set: function set(time) { + this.setCurrentTime(time); + }, + get: function get() { + return this.getCurrentTime(); + } + }, { + key: 'duration', + get: function get() { + return this.getDuration(); + } + }, { + key: 'volume', + set: function set(volume) { + this.setVolume(volume); + }, + get: function get() { + return this.getVolume(); + } + }, { + key: 'src', + set: function set(src) { + this.setSrc(src); + }, + get: function get() { + return this.getSrc(); + } + }]); + + return MediaElementPlayer; +}(); + +_window2.default.MediaElementPlayer = MediaElementPlayer; + +exports.default = MediaElementPlayer; + +},{"17":17,"2":2,"25":25,"26":26,"27":27,"28":28,"3":3,"30":30,"5":5,"6":6,"7":7}],17:[function(_dereq_,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _window = _dereq_(3); + +var _window2 = _interopRequireDefault(_window); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var DefaultPlayer = function () { + function DefaultPlayer(player) { + _classCallCheck(this, DefaultPlayer); + + this.media = player.media; + this.isVideo = player.isVideo; + this.classPrefix = player.options.classPrefix; + this.createIframeLayer = function () { + return player.createIframeLayer(); + }; + this.setPoster = function (url) { + return player.setPoster(url); + }; + return this; + } + + _createClass(DefaultPlayer, [{ + key: 'play', + value: function play() { + this.media.play(); + } + }, { + key: 'pause', + value: function pause() { + this.media.pause(); + } + }, { + key: 'load', + value: function load() { + var t = this; + + if (!t.isLoaded) { + t.media.load(); + } + + t.isLoaded = true; + } + }, { + key: 'setCurrentTime', + value: function setCurrentTime(time) { + this.media.setCurrentTime(time); + } + }, { + key: 'getCurrentTime', + value: function getCurrentTime() { + return this.media.currentTime; + } + }, { + key: 'getDuration', + value: function getDuration() { + return this.media.getDuration(); + } + }, { + key: 'setVolume', + value: function setVolume(volume) { + this.media.setVolume(volume); + } + }, { + key: 'getVolume', + value: function getVolume() { + return this.media.getVolume(); + } + }, { + key: 'setMuted', + value: function setMuted(value) { + this.media.setMuted(value); + } + }, { + key: 'setSrc', + value: function setSrc(src) { + var t = this, + layer = document.getElementById(t.media.id + '-iframe-overlay'); + + if (layer) { + layer.remove(); + } + + t.media.setSrc(src); + t.createIframeLayer(); + if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { + t.setPoster(t.media.renderer.getPosterUrl()); + } + } + }, { + key: 'getSrc', + value: function getSrc() { + return this.media.getSrc(); + } + }, { + key: 'canPlayType', + value: function canPlayType(type) { + return this.media.canPlayType(type); + } + }, { + key: 'paused', + get: function get() { + return this.media.paused; + } + }, { + key: 'muted', + set: function set(muted) { + this.setMuted(muted); + }, + get: function get() { + return this.media.muted; + } + }, { + key: 'ended', + get: function get() { + return this.media.ended; + } + }, { + key: 'readyState', + get: function get() { + return this.media.readyState; + } + }, { + key: 'currentTime', + set: function set(time) { + this.setCurrentTime(time); + }, + get: function get() { + return this.getCurrentTime(); + } + }, { + key: 'duration', + get: function get() { + return this.getDuration(); + } + }, { + key: 'volume', + set: function set(volume) { + this.setVolume(volume); + }, + get: function get() { + return this.getVolume(); + } + }, { + key: 'src', + set: function set(src) { + this.setSrc(src); + }, + get: function get() { + return this.getSrc(); + } + }]); + + return DefaultPlayer; +}(); + +exports.default = DefaultPlayer; + + +_window2.default.DefaultPlayer = DefaultPlayer; + +},{"3":3}],18:[function(_dereq_,module,exports){ +'use strict'; + +var _window = _dereq_(3); + +var _window2 = _interopRequireDefault(_window); + +var _mejs = _dereq_(7); + +var _mejs2 = _interopRequireDefault(_mejs); + +var _player = _dereq_(16); + +var _player2 = _interopRequireDefault(_player); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +if (typeof jQuery !== 'undefined') { + _mejs2.default.$ = _window2.default.jQuery = _window2.default.$ = jQuery; +} else if (typeof Zepto !== 'undefined') { + _mejs2.default.$ = _window2.default.Zepto = _window2.default.$ = Zepto; +} else if (typeof ender !== 'undefined') { + _mejs2.default.$ = _window2.default.ender = _window2.default.$ = ender; +} + +(function ($) { + if (typeof $ !== 'undefined') { + $.fn.mediaelementplayer = function (options) { + if (options === false) { + this.each(function () { + var player = $(this).data('mediaelementplayer'); + if (player) { + player.remove(); + } + $(this).removeData('mediaelementplayer'); + }); + } else { + this.each(function () { + $(this).data('mediaelementplayer', new _player2.default(this, options)); + }); + } + return this; + }; + + $(document).ready(function () { + $('.' + _mejs2.default.MepDefaults.classPrefix + 'player').mediaelementplayer(); + }); + } +})(_mejs2.default.$); + +},{"16":16,"3":3,"7":7}],19:[function(_dereq_,module,exports){ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _window = _dereq_(3); + +var _window2 = _interopRequireDefault(_window); + +var _mejs = _dereq_(7); + +var _mejs2 = _interopRequireDefault(_mejs); + +var _renderer = _dereq_(8); + +var _general = _dereq_(27); + +var _media = _dereq_(28); + +var _constants = _dereq_(25); + +var _dom = _dereq_(26); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var NativeDash = { + + promise: null, + + load: function load(settings) { + if (typeof dashjs !== 'undefined') { + NativeDash.promise = new Promise(function (resolve) { + resolve(); + }).then(function () { + NativeDash._createPlayer(settings); + }); + } else { + settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.dashjs.org/latest/dash.all.min.js'; + + NativeDash.promise = NativeDash.promise || (0, _dom.loadScript)(settings.options.path); + NativeDash.promise.then(function () { + NativeDash._createPlayer(settings); + }); + } + + return NativeDash.promise; + }, + + _createPlayer: function _createPlayer(settings) { + var player = dashjs.MediaPlayer().create(); + _window2.default['__ready__' + settings.id](player); + return player; + } +}; + +var DashNativeRenderer = { + name: 'native_dash', + options: { + prefix: 'native_dash', + dash: { + path: 'https://cdn.dashjs.org/latest/dash.all.min.js', + debug: false, + drm: {}, + + robustnessLevel: '' + } + }, + + canPlayType: function canPlayType(type) { + return _constants.HAS_MSE && ['application/dash+xml'].indexOf(type.toLowerCase()) > -1; + }, + + create: function create(mediaElement, options, mediaFiles) { + + var originalNode = mediaElement.originalNode, + id = mediaElement.id + '_' + options.prefix, + autoplay = originalNode.autoplay, + children = originalNode.children; + + var node = null, + dashPlayer = null; + + originalNode.removeAttribute('type'); + for (var i = 0, total = children.length; i < total; i++) { + children[i].removeAttribute('type'); + } + + node = originalNode.cloneNode(true); + options = Object.assign(options, mediaElement.options); + + var props = _mejs2.default.html5media.properties, + events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']), + attachNativeEvents = function attachNativeEvents(e) { + var event = (0, _general.createEvent)(e.type, mediaElement); + mediaElement.dispatchEvent(event); + }, + assignGettersSetters = function assignGettersSetters(propName) { + var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); + + node['get' + capName] = function () { + return dashPlayer !== null ? node[propName] : null; + }; + + node['set' + capName] = function (value) { + if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { + if (propName === 'src') { + var source = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; + node[propName] = source; + if (dashPlayer !== null) { + dashPlayer.reset(); + for (var _i = 0, _total = events.length; _i < _total; _i++) { + node.removeEventListener(events[_i], attachNativeEvents); + } + dashPlayer = NativeDash._createPlayer({ + options: options.dash, + id: id + }); + + if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(value.drm) === 'object') { + dashPlayer.setProtectionData(value.drm); + if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { + dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); + } + } + dashPlayer.attachSource(source); + if (autoplay) { + dashPlayer.play(); + } + } + } else { + node[propName] = value; + } + } + }; + }; + + for (var _i2 = 0, _total2 = props.length; _i2 < _total2; _i2++) { + assignGettersSetters(props[_i2]); + } + + _window2.default['__ready__' + id] = function (_dashPlayer) { + mediaElement.dashPlayer = dashPlayer = _dashPlayer; + + var dashEvents = dashjs.MediaPlayer.events, + assignEvents = function assignEvents(eventName) { + if (eventName === 'loadedmetadata') { + dashPlayer.getDebug().setLogToBrowserConsole(options.dash.debug); + dashPlayer.initialize(); + dashPlayer.setScheduleWhilePaused(false); + dashPlayer.setFastSwitchEnabled(true); + dashPlayer.attachView(node); + dashPlayer.setAutoPlay(false); + + if (_typeof(options.dash.drm) === 'object' && !_mejs2.default.Utils.isObjectEmpty(options.dash.drm)) { + dashPlayer.setProtectionData(options.dash.drm); + if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { + dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); + } + } + dashPlayer.attachSource(node.getSrc()); + } + + node.addEventListener(eventName, attachNativeEvents); + }; + + for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) { + assignEvents(events[_i3]); + } + + var assignMdashEvents = function assignMdashEvents(e) { + var event = (0, _general.createEvent)(e.type, node); + event.data = e; + mediaElement.dispatchEvent(event); + + if (e.type.toLowerCase() === 'error') { + console.error(e); + } + }; + + for (var eventType in dashEvents) { + if (dashEvents.hasOwnProperty(eventType)) { + dashPlayer.on(dashEvents[eventType], assignMdashEvents); + } + } + }; + + if (mediaFiles && mediaFiles.length > 0) { + for (var _i4 = 0, _total4 = mediaFiles.length; _i4 < _total4; _i4++) { + if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i4].type)) { + node.setAttribute('src', mediaFiles[_i4].src); + if (typeof mediaFiles[_i4].drm !== 'undefined') { + options.dash.drm = mediaFiles[_i4].drm; + } + break; + } + } + } + + node.setAttribute('id', id); + + originalNode.parentNode.insertBefore(node, originalNode); + originalNode.autoplay = false; + originalNode.style.display = 'none'; + + node.setSize = function (width, height) { + node.style.width = width + 'px'; + node.style.height = height + 'px'; + return node; + }; + + node.hide = function () { + node.pause(); + node.style.display = 'none'; + return node; + }; + + node.show = function () { + node.style.display = ''; + return node; + }; + + node.destroy = function () { + if (dashPlayer !== null) { + dashPlayer.reset(); + } + }; + + var event = (0, _general.createEvent)('rendererready', node); + mediaElement.dispatchEvent(event); + + mediaElement.promises.push(NativeDash.load({ + options: options.dash, + id: id + })); + + return node; + } +}; + +_media.typeChecks.push(function (url) { + return ~url.toLowerCase().indexOf('.mpd') ? 'application/dash+xml' : null; +}); + +_renderer.renderer.add(DashNativeRenderer); + +},{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],20:[function(_dereq_,module,exports){ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PluginDetector = undefined; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _window = _dereq_(3); + +var _window2 = _interopRequireDefault(_window); + +var _document = _dereq_(2); + +var _document2 = _interopRequireDefault(_document); + +var _mejs = _dereq_(7); + +var _mejs2 = _interopRequireDefault(_mejs); + +var _i18n = _dereq_(5); + +var _i18n2 = _interopRequireDefault(_i18n); + +var _renderer = _dereq_(8); + +var _general = _dereq_(27); + +var _constants = _dereq_(25); + +var _media = _dereq_(28); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var PluginDetector = exports.PluginDetector = { + plugins: [], + + hasPluginVersion: function hasPluginVersion(plugin, v) { + var pv = PluginDetector.plugins[plugin]; + v[1] = v[1] || 0; + v[2] = v[2] || 0; + return pv[0] > v[0] || pv[0] === v[0] && pv[1] > v[1] || pv[0] === v[0] && pv[1] === v[1] && pv[2] >= v[2]; + }, + + addPlugin: function addPlugin(p, pluginName, mimeType, activeX, axDetect) { + PluginDetector.plugins[p] = PluginDetector.detectPlugin(pluginName, mimeType, activeX, axDetect); + }, + + detectPlugin: function detectPlugin(pluginName, mimeType, activeX, axDetect) { + + var version = [0, 0, 0], + description = void 0, + ax = void 0; + + if (_constants.NAV.plugins !== null && _constants.NAV.plugins !== undefined && _typeof(_constants.NAV.plugins[pluginName]) === 'object') { + description = _constants.NAV.plugins[pluginName].description; + if (description && !(typeof _constants.NAV.mimeTypes !== 'undefined' && _constants.NAV.mimeTypes[mimeType] && !_constants.NAV.mimeTypes[mimeType].enabledPlugin)) { + version = description.replace(pluginName, '').replace(/^\s+/, '').replace(/\sr/gi, '.').split('.'); + for (var i = 0, total = version.length; i < total; i++) { + version[i] = parseInt(version[i].match(/\d+/), 10); + } + } + } else if (_window2.default.ActiveXObject !== undefined) { + try { + ax = new ActiveXObject(activeX); + if (ax) { + version = axDetect(ax); + } + } catch (e) { + + } + } + return version; + } +}; + +PluginDetector.addPlugin('flash', 'Shockwave Flash', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash', function (ax) { + var version = [], + d = ax.GetVariable("$version"); + + if (d) { + d = d.split(" ")[1].split(","); + version = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; + } + return version; +}); + +var FlashMediaElementRenderer = { + create: function create(mediaElement, options, mediaFiles) { + + var flash = {}; + + flash.options = options; + flash.id = mediaElement.id + '_' + flash.options.prefix; + flash.mediaElement = mediaElement; + flash.flashState = {}; + flash.flashApi = null; + flash.flashApiStack = []; + + var props = _mejs2.default.html5media.properties, + assignGettersSetters = function assignGettersSetters(propName) { + flash.flashState[propName] = null; + + var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); + + flash['get' + capName] = function () { + if (flash.flashApi !== null) { + if (typeof flash.flashApi['get_' + propName] === 'function') { + var value = flash.flashApi['get_' + propName](); + + if (propName === 'buffered') { + return { + start: function start() { + return 0; + }, + end: function end() { + return value; + }, + length: 1 + }; + } + return value; + } else { + return null; + } + } else { + return null; + } + }; + + flash['set' + capName] = function (value) { + if (propName === 'src') { + value = (0, _media.absolutizeUrl)(value); + } + + if (flash.flashApi !== null && flash.flashApi['set_' + propName] !== undefined) { + try { + flash.flashApi['set_' + propName](value); + } catch (e) { + + } + } else { + flash.flashApiStack.push({ + type: 'set', + propName: propName, + value: value + }); + } + }; + }; + + for (var i = 0, total = props.length; i < total; i++) { + assignGettersSetters(props[i]); + } + + var methods = _mejs2.default.html5media.methods, + assignMethods = function assignMethods(methodName) { + flash[methodName] = function () { + if (flash.flashApi !== null) { + if (flash.flashApi['fire_' + methodName]) { + try { + flash.flashApi['fire_' + methodName](); + } catch (e) { + + } + } else { + + } + } else { + flash.flashApiStack.push({ + type: 'call', + methodName: methodName + }); + } + }; + }; + methods.push('stop'); + for (var _i = 0, _total = methods.length; _i < _total; _i++) { + assignMethods(methods[_i]); + } + + var initEvents = ['rendererready']; + + for (var _i2 = 0, _total2 = initEvents.length; _i2 < _total2; _i2++) { + var event = (0, _general.createEvent)(initEvents[_i2], flash); + mediaElement.dispatchEvent(event); + } + + _window2.default['__ready__' + flash.id] = function () { + + flash.flashReady = true; + flash.flashApi = _document2.default.getElementById('__' + flash.id); + + if (flash.flashApiStack.length) { + for (var _i3 = 0, _total3 = flash.flashApiStack.length; _i3 < _total3; _i3++) { + var stackItem = flash.flashApiStack[_i3]; + + if (stackItem.type === 'set') { + var propName = stackItem.propName, + capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); + + flash['set' + capName](stackItem.value); + } else if (stackItem.type === 'call') { + flash[stackItem.methodName](); + } + } + } + }; + + _window2.default['__event__' + flash.id] = function (eventName, message) { + var event = (0, _general.createEvent)(eventName, flash); + if (message) { + try { + event.data = JSON.parse(message); + event.details.data = JSON.parse(message); + } catch (e) { + event.message = message; + } + } + + flash.mediaElement.dispatchEvent(event); + }; + + flash.flashWrapper = _document2.default.createElement('div'); + + if (['always', 'sameDomain'].indexOf(flash.options.shimScriptAccess) === -1) { + flash.options.shimScriptAccess = 'sameDomain'; + } + + var autoplay = mediaElement.originalNode.autoplay, + flashVars = ['uid=' + flash.id, 'autoplay=' + autoplay, 'allowScriptAccess=' + flash.options.shimScriptAccess, 'preload=' + (mediaElement.originalNode.getAttribute('preload') || '')], + isVideo = mediaElement.originalNode !== null && mediaElement.originalNode.tagName.toLowerCase() === 'video', + flashHeight = isVideo ? mediaElement.originalNode.height : 1, + flashWidth = isVideo ? mediaElement.originalNode.width : 1; + + if (mediaElement.originalNode.getAttribute('src')) { + flashVars.push('src=' + mediaElement.originalNode.getAttribute('src')); + } + + if (flash.options.enablePseudoStreaming === true) { + flashVars.push('pseudostreamstart=' + flash.options.pseudoStreamingStartQueryParam); + flashVars.push('pseudostreamtype=' + flash.options.pseudoStreamingType); + } + + mediaElement.appendChild(flash.flashWrapper); + mediaElement.originalNode.style.display = 'none'; + + var settings = []; + + if (_constants.IS_IE) { + var specialIEContainer = _document2.default.createElement('div'); + 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 (!isVideo) { + settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); + } + + specialIEContainer.outerHTML = ''; + } 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 + '"']; + + if (!isVideo) { + settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); + } + + flash.flashWrapper.innerHTML = '