(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.artplayer = {}))); }(this, (function (exports) { 'use strict'; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var setPrototypeOf = createCommonjsModule(function (module) { function _setPrototypeOf(o, p) { module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } module.exports = _setPrototypeOf; }); var construct = createCommonjsModule(function (module) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { module.exports = _construct = Reflect.construct; } else { module.exports = _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } module.exports = _construct; }); function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } var arrayWithoutHoles = _arrayWithoutHoles; function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } var iterableToArray = _iterableToArray; function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } var nonIterableSpread = _nonIterableSpread; function _toConsumableArray(arr) { return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread(); } var toConsumableArray = _toConsumableArray; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var classCallCheck = _classCallCheck; 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var createClass = _createClass; var _typeof_1 = createCommonjsModule(function (module) { function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } function _typeof(obj) { if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { module.exports = _typeof = function _typeof(obj) { return _typeof2(obj); }; } else { module.exports = _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); }; } return _typeof(obj); } module.exports = _typeof; }); function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } var assertThisInitialized = _assertThisInitialized; function _possibleConstructorReturn(self, call) { if (call && (_typeof_1(call) === "object" || typeof call === "function")) { return call; } return assertThisInitialized(self); } var possibleConstructorReturn = _possibleConstructorReturn; var getPrototypeOf = createCommonjsModule(function (module) { function _getPrototypeOf(o) { module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } module.exports = _getPrototypeOf; }); function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) setPrototypeOf(subClass, superClass); } var inherits = _inherits; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var defineProperty = _defineProperty; function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { defineProperty(target, key, source[key]); }); } return target; } var objectSpread = _objectSpread; function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var arrayWithHoles = _arrayWithHoles; function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } var iterableToArrayLimit = _iterableToArrayLimit; function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } var nonIterableRest = _nonIterableRest; function _slicedToArray(arr, i) { return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest(); } var slicedToArray = _slicedToArray; function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } var isNativeFunction = _isNativeFunction; var wrapNativeSuper = createCommonjsModule(function (module) { function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return construct(Class, arguments, getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } module.exports = _wrapNativeSuper; }); var ArtPlayerError = /*#__PURE__*/ function (_Error) { inherits(ArtPlayerError, _Error); function ArtPlayerError(message, context) { var _this; classCallCheck(this, ArtPlayerError); _this = possibleConstructorReturn(this, getPrototypeOf(ArtPlayerError).call(this, message)); if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(assertThisInitialized(assertThisInitialized(_this)), context || _this.constructor); } _this.name = 'ArtPlayerError'; return _this; } return ArtPlayerError; }(wrapNativeSuper(Error)); function errorHandle(condition, msg) { var isFun = typeof condition === 'function'; if (isFun ? !isFun() : !condition) { throw new ArtPlayerError(msg); } } function clamp(num, a, b) { return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); } function getExt(url) { if (url.includes('?')) { return getExt(url.split('?')[0]); } if (url.includes('#')) { return getExt(url.split('#')[0]); } return url.trim().toLowerCase().split('.').pop(); } function append(parent, child) { if (child instanceof Element) { parent.appendChild(child); } else { parent.insertAdjacentHTML('beforeend', child); } return child; } function setStyle(element, styles) { Object.keys(styles).forEach(function (key) { element.style[key] = styles[key]; }); return element; } function secondToTime(second) { var add0 = function add0(num) { return num < 10 ? "0".concat(num) : String(num); }; var hour = Math.floor(second / 3600); var min = Math.floor((second - hour * 3600) / 60); var sec = Math.floor(second - hour * 3600 - min * 60); return (hour > 0 ? [hour, min, sec] : [min, sec]).map(add0).join(':'); } function deepMerge() { var isObject = function isObject(value) { return value !== null && _typeof_1(value) === 'object'; }; var returnValue = {}; for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) { sources[_key] = arguments[_key]; } for (var _i = 0; _i < sources.length; _i++) { var source = sources[_i]; if (Array.isArray(source)) { if (!Array.isArray(returnValue)) { returnValue = []; } returnValue = toConsumableArray(returnValue).concat(toConsumableArray(source)); } else if (isObject(source)) { var _arr = Object.entries(source); for (var _i2 = 0; _i2 < _arr.length; _i2++) { var _arr$_i = slicedToArray(_arr[_i2], 2), key = _arr$_i[0], value = _arr$_i[1]; if (isObject(value) && Reflect.has(returnValue, key)) { value = deepMerge(returnValue[key], value); } returnValue = objectSpread({}, returnValue, defineProperty({}, key, value)); } } } return returnValue; } function validOption(option) { errorHandle(option.container, '\'container\' option is required.'); errorHandle(option.url, '\'url\' option is required.'); errorHandle(typeof option.container === 'string' || option.container instanceof Element, "'container' option require 'string' or 'Element' type, but got '".concat(_typeof_1(option.container), "'.")); errorHandle(typeof option.url === 'string', "'url' option require 'string' type, but got '".concat(_typeof_1(option.url), "'.")); errorHandle(typeof option.poster === 'string', "'poster' option require 'string' type, but got '".concat(_typeof_1(option.poster), "'.")); errorHandle(Object.prototype.toString.call(option.thumbnails) === '[object Object]', "'thumbnails' option require 'object' type, but got '".concat(_typeof_1(option.thumbnails), "'.")); errorHandle(typeof option.volume === 'number', "'volume' option require 'number' type, but got '".concat(_typeof_1(option.volume), "'.")); errorHandle(typeof option.autoplay === 'boolean', "'autoplay' option require 'boolean' type, but got '".concat(_typeof_1(option.autoplay), "'.")); errorHandle(typeof option.loop === 'boolean', "'loop' option require 'boolean' type, but got '".concat(_typeof_1(option.loop), "'.")); errorHandle(['none', 'metadata', 'auto'].indexOf(option.preload) > -1, "'preload' option require one of 'none\u3001metadata\u3001auto', but got '".concat(option.preload, ".")); errorHandle(typeof option.lang === 'string', "'lang' option require 'string' type, but got '".concat(_typeof_1(option.lang), "'.")); errorHandle(typeof option.type === 'string', "'type' option require 'string' type, but got '".concat(_typeof_1(option.type), "'.")); errorHandle(typeof option.mimeCodec === 'string', "'mimeCodec' option require 'string' type, but got '".concat(_typeof_1(option.mimeCodec), "'.")); errorHandle(Array.isArray(option.layers), "'layers' option require 'array' type, but got '".concat(_typeof_1(option.layers), "'.")); errorHandle(Array.isArray(option.contextmenu), "'contextmenu' option require 'array' type, but got '".concat(_typeof_1(option.contextmenu), "'.")); errorHandle(typeof option.loading === 'string' || option.loading instanceof Element, "'loading' option require 'string' type, but got '".concat(_typeof_1(option.loading), "'.")); errorHandle(typeof option.theme === 'string', "'theme' option require 'string' type, but got '".concat(_typeof_1(option.theme), "'.")); errorHandle(typeof option.hotkey === 'boolean', "'hotkey' option require 'boolean' type, but got '".concat(_typeof_1(option.hotkey), "'.")); errorHandle(Object.prototype.toString.call(option.subtitle) === '[object Object]', "'subtitle' option require 'object' type, but got '".concat(_typeof_1(option.subtitle), "'.")); errorHandle(Array.isArray(option.controls), "'controls' option require 'array' type, but got '".concat(_typeof_1(option.controls), "'.")); errorHandle(Array.isArray(option.highlight), "'highlight' option require 'array' type, but got '".concat(_typeof_1(option.highlight), "'.")); } var mimeCodec = { mp4: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', webm: 'video/webm; codecs="vorbis, vp8"', ts: 'video/mp2t; codecs="avc1.42E01E, mp4a.40.2"' }; var mse = { mediaSource: { propertys: ['activeSourceBuffers', 'duration', 'readyState', 'sourceBuffers'], methods: ['addSourceBuffer', 'endOfStream', 'removeSourceBuffer', 'clearLiveSeekableRange', 'setLiveSeekableRange'], events: ['sourceclose', 'sourceended', 'sourceopen'] }, sourceBuffer: { propertys: ['mode', 'updating', 'buffered', 'timestampOffset', 'audioTracks', 'videoTracks', 'textTracks', 'appendWindowStart', 'appendWindowEnd', 'trackDefaults'], methods: ['appendBuffer', 'appendStream', 'abort', 'remove'], events: ['abort', 'error', 'update', 'updateend', 'updatestart'] }, sourceBufferList: { propertys: ['length'], events: ['addsourcebuffer', 'removesourcebuffer'] } }; var video = { propertys: ['audioTracks', 'autoplay', 'buffered', 'controller', 'controls', 'crossOrigin', 'currentSrc', 'currentTime', 'defaultMuted', 'defaultPlaybackRate', 'duration', 'ended', 'error', 'loop', 'mediaGroup', 'muted', 'networkState', 'paused', 'playbackRate', 'played', 'preload', 'readyState', 'seekable', 'seeking', 'src', 'startDate', 'textTracks', 'videoTracks', 'volume'], methods: ['addTextTrack', 'canPlayType', 'load', 'play', 'pause'], events: ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting'] }; var config = { mimeCodec: mimeCodec, mse: mse, video: video }; function E () { // Keep this empty so it's easier to inherit from // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) } E.prototype = { on: function (name, callback, ctx) { var e = this.e || (this.e = {}); (e[name] || (e[name] = [])).push({ fn: callback, ctx: ctx }); return this; }, once: function (name, callback, ctx) { var self = this; function listener () { self.off(name, listener); callback.apply(ctx, arguments); } listener._ = callback; return this.on(name, listener, ctx); }, emit: function (name) { var data = [].slice.call(arguments, 1); var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); var i = 0; var len = evtArr.length; for (i; i < len; i++) { evtArr[i].fn.apply(evtArr[i].ctx, data); } return this; }, off: function (name, callback) { var e = this.e || (this.e = {}); var evts = e[name]; var liveEvents = []; if (evts && callback) { for (var i = 0, len = evts.length; i < len; i++) { if (evts[i].fn !== callback && evts[i].fn._ !== callback) liveEvents.push(evts[i]); } } // Remove event from queue to prevent memory leak // Suggested by https://github.com/lazd // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 (liveEvents.length) ? e[name] = liveEvents : delete e[name]; return this; } }; var tinyEmitter = E; var Template = /*#__PURE__*/ function () { function Template(art) { classCallCheck(this, Template); this.art = art; this.init(); } createClass(Template, [{ key: "init", value: function init() { var refs = this.art.refs; refs.$container.innerHTML = "\n
".concat(item, "
"); }).join(''); } _this.art.emit('subtitle:update', $subtitle); }); } }); } }, { key: "load", value: function load(url) { var _this2 = this; var type; return fetch(url).then(function (response) { type = response.headers.get('Content-Type'); return response.text(); }).then(function (text) { if (/x-subrip/gi.test(type)) { return _this2.srtToVtt(text); } return url; }).catch(function (err) { throw err; }); } }, { key: "srtToVtt", value: function srtToVtt(text) { var vttText = 'WEBVTT \r\n\r\n'.concat(text.replace(/\{\\([ibu])\}/g, '$1>').replace(/\{\\([ibu])1\}/g, '<$1>').replace(/\{([ibu])\}/g, '<$1>').replace(/\{\/([ibu])\}/g, '$1>').replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g, '$1.$2').concat('\r\n\r\n')); return URL.createObjectURL(new Blob([vttText], { type: 'text/vtt' })); } }, { key: "checkExt", value: function checkExt(url) { var ext = getExt(url); errorHandle(ext === 'vtt' || ext === 'srt', "'subtitle.url' option require 'vtt' or 'srt' format, but got '".concat(ext, "'.")); } }, { key: "show", value: function show() { var $subtitle = this.art.refs.$subtitle; $subtitle.style.display = 'block'; this.art.emit('subtitle:show', $subtitle); } }, { key: "hide", value: function hide() { var $subtitle = this.art.refs.$subtitle; $subtitle.style.display = 'none'; this.art.emit('subtitle:hide', $subtitle); } }, { key: "switch", value: function _switch(url) { var _this3 = this; var $track = this.art.refs.$track; this.checkExt(url); errorHandle($track, 'You need to initialize the subtitle option first.'); this.load(url).then(function (data) { if (url !== data) { $track.src = data; _this3.art.emit('subtitle:switch', url); } }); } }]); return Subtitle; }(); var Events = /*#__PURE__*/ function () { function Events(art) { classCallCheck(this, Events); this.art = art; this.destroyEvents = []; this.proxy = this.proxy.bind(this); } createClass(Events, [{ key: "proxy", value: function proxy(target, name, callback) { var _this = this; var option = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; if (Array.isArray(name)) { name.forEach(function (item) { return _this.proxy(target, item, callback, option); }); } target.addEventListener(name, callback, option); this.destroyEvents.push(function () { target.removeEventListener(name, callback, option); }); } }, { key: "destroy", value: function destroy() { this.destroyEvents.forEach(function (event) { return event(); }); } }]); return Events; }(); var Hotkey = /*#__PURE__*/ function () { function Hotkey(art) { classCallCheck(this, Hotkey); this.art = art; if (this.art.option.hotkey) { this.init(); } } createClass(Hotkey, [{ key: "init", value: function init() { var _this = this; var _this$art = this.art, player = _this$art.player, $player = _this$art.refs.$player, proxy = _this$art.events.proxy; proxy(document, 'click', function (event) { _this.art.isFocus = event.path.indexOf($player) > -1; }); proxy(window, 'keydown', function (event) { if (_this.art.isFocus) { var tag = document.activeElement.tagName.toUpperCase(); var editable = document.activeElement.getAttribute('contenteditable'); if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') { switch (event.keyCode) { case 39: event.preventDefault(); player.seek(player.currentTime() + 10); break; case 37: event.preventDefault(); player.seek(player.currentTime() - 10); break; case 38: event.preventDefault(); player.volume(player.volume() + 0.05); break; case 40: event.preventDefault(); player.volume(player.volume() - 0.05); break; case 32: event.preventDefault(); player.toggle(); break; default: break; } } } }); } }]); return Hotkey; }(); var id$1 = 0; var Layers = /*#__PURE__*/ function () { function Layers(art) { classCallCheck(this, Layers); this.art = art; this.add = this.add.bind(this); this.art.option.layers.forEach(this.add); this.init(); } createClass(Layers, [{ key: "init", value: function init() { var _this$art = this.art, refs = _this$art.refs, player = _this$art.player, proxy = _this$art.events.proxy; proxy(refs.$layers, 'click', function (event) { if (event.path[0] === refs.$layers) { player.pause(); } }); } }, { key: "add", value: function add(option, callback) { var refs = this.art.refs; id$1++; var $layer = document.createElement('div'); $layer.setAttribute('data-art-layer-id', id$1); $layer.setAttribute('class', "art-layer art-layer-".concat(option.name || id$1)); $layer.style.zIndex = option.index || id$1; append($layer, option.html); setStyle($layer, option.style || {}); refs.$layers.appendChild($layer); this.art.emit('layers:add', $layer); callback && callback($layer); } }, { key: "show", value: function show() { var $layers = this.art.refs.$layers; $layers.style.display = 'block'; this.art.emit('layers:show', $layers); } }, { key: "hide", value: function hide() { var $layers = this.art.refs.$layers; $layers.style.display = 'none'; this.art.emit('layers:hide', $layers); } }]); return Layers; }(); var Loading = /*#__PURE__*/ function () { function Loading(art) { classCallCheck(this, Loading); this.art = art; this.init(); } createClass(Loading, [{ key: "init", value: function init() { var _this$art = this.art, option = _this$art.option, $loading = _this$art.refs.$loading; append($loading, option.loading || icons$1.loading); } }, { key: "hide", value: function hide() { var $loading = this.art.refs.$loading; $loading.style.display = 'none'; this.art.emit('loading:hide', $loading); } }, { key: "show", value: function show() { var $loading = this.art.refs.$loading; $loading.style.display = 'flex'; this.art.emit('loading:show', $loading); } }]); return Loading; }(); var Notice = /*#__PURE__*/ function () { function Notice(art) { classCallCheck(this, Notice); this.art = art; this.timer = null; } createClass(Notice, [{ key: "show", value: function show(msg) { var _this = this; var autoHide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000; var $notice = this.art.refs.$notice; $notice.style.display = 'block'; $notice.innerHTML = msg instanceof Error ? msg.message.trim() : msg; if (autoHide) { clearTimeout(this.timer); this.timer = setTimeout(function () { _this.hide(); }, time); } this.art.emit('notice:show', $notice); } }, { key: "hide", value: function hide() { var $notice = this.art.refs.$notice; $notice.style.display = 'none'; this.art.emit('notice:hide', $notice); } }]); return Notice; }(); var Mask = /*#__PURE__*/ function () { function Mask(art) { classCallCheck(this, Mask); this.art = art; this.init(); } createClass(Mask, [{ key: "init", value: function init() { var _this = this; var _this$art = this.art, player = _this$art.player, refs = _this$art.refs, proxy = _this$art.events.proxy; append(refs.$mask, icons$1.playBig); proxy(refs.$mask, 'click', function () { player.play(); _this.hide(); }); } }, { key: "show", value: function show() { var $mask = this.art.refs.$mask; $mask.style.display = 'block'; this.art.emit('mask:show', $mask); } }, { key: "hide", value: function hide() { var $mask = this.art.refs.$mask; $mask.style.display = 'none'; this.art.emit('mask:show', $mask); } }]); return Mask; }(); var id$2 = 0; var instances = []; var Artplayer = /*#__PURE__*/ function (_Emitter) { inherits(Artplayer, _Emitter); function Artplayer(option) { var _this; classCallCheck(this, Artplayer); _this = possibleConstructorReturn(this, getPrototypeOf(Artplayer).call(this)); _this.emit('init:start'); _this.option = deepMerge({}, Artplayer.DEFAULTS, option); validOption(_this.option); _this.init(); _this.emit('init:end'); return _this; } createClass(Artplayer, [{ key: "init", value: function init() { this.isError = false; this.isFocus = false; this.isPlaying = false; this.refs = {}; if (this.option.container instanceof Element) { this.refs.$container = this.option.container; } else { this.refs.$container = document.querySelector(this.option.container); } this.template = new Template(this); this.i18n = new I18n(this); this.notice = new Notice(this); this.events = new Events(this); this.player = new Player(this); this.layers = new Layers(this); this.controls = new Controls(this); this.contextmenu = new Contextmenu(this); this.danmu = new Danmu$1(this); this.subtitle = new Subtitle$1(this); this.info = new Info(this); this.loading = new Loading(this); this.hotkey = new Hotkey(this); this.mask = new Mask(this); this.id = id$2++; instances.push(this); return this; } }, { key: "destroy", value: function destroy() { var removeHtml = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; this.events.destroy(); instances.splice(instances.indexOf(this), 1); if (removeHtml) { this.refs.$container.innerHTML = ''; } this.emit('destroy'); } }], [{ key: "use", value: function use(Plugin) { var name = Plugin.name.toLowerCase(); var installedPlugins = this.plugins || (this.plugins = {}); if (!installedPlugins[name]) { var args = Array.from(arguments).slice(1); args.unshift(this); installedPlugins[name] = construct(Plugin, toConsumableArray(args)); this.prototype.emit('use', Plugin); } return this; } }, { key: "version", get: function get() { return '1.0.0'; } }, { key: "config", get: function get() { return config; } }, { key: "DEFAULTS", get: function get() { return { container: '.artplayer', url: '', poster: '', thumbnails: { url: '', number: 60, width: 160, height: 90, column: 10 }, volume: 0.7, autoplay: false, loop: false, preload: 'auto', type: '', mimeCodec: '', layers: [], contextmenu: [], loading: '', theme: '#f00', hotkey: true, subtitle: { url: '', style: {} }, controls: [], highlight: [], lang: navigator.language.toLowerCase() }; } }]); return Artplayer; }(tinyEmitter); window.Artplayer = Artplayer; exports.instances = instances; exports.default = Artplayer; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=artplayer.js.map