!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.artplayer={})}(this,function(t){"use strict";var o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function i(t,e){for(var n=0;n\n
\n
\n
\n \n
\n
\n ',t.$video=t.$container.querySelector(".artplayer-video"),t.$subtitle=t.$container.querySelector(".artplayer-subtitle"),t.$bottom=t.$container.querySelector(".artplayer-bottom"),t.$progress=t.$container.querySelector(".artplayer-progress"),t.$controls=t.$container.querySelector(".artplayer-controls"),t.$controlsLeft=t.$container.querySelector(".artplayer-controls-left"),t.$controlsRight=t.$container.querySelector(".artplayer-controls-right"),t.$layers=t.$container.querySelector(".artplayer-layers"),t.$loading=t.$container.querySelector(".artplayer-loading"),t.$notice=t.$container.querySelector(".artplayer-notice"),t.$mask=t.$container.querySelector(".artplayer-mask")}}]),e}(),$={"zh-cn":{"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败","Fast forward 10 seconds":"快进10秒","Rewind 10 seconds":"快退10秒","10% increase in volume":"音量增加10%","10% reduction in volume":"音量减少10%"},"zh-tw":{"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗","Fast forward 10 seconds":"快進10秒","Rewind 10 seconds":"快退10秒","10% increase in volume":"音量增加10%","10% reduction in volume":"音量減少10%"}},T=function(){function n(t){var e=t.option;o(this,n),this.language=$[e.lang.toLowerCase()]||{}}return r(n,[{key:"get",value:function(t){return this.language[t]||t}}]),n}(),S=function(){function e(t){o(this,e),this.art=t,this.init(),this.eventBind()}return r(e,[{key:"init",value:function(){var t=this.art.option,e=this.art.refs.$video;e.controls=!0,e.poster=t.poster,e.volume=y(t.volume,0,1),e.autoplay=t.autoplay,e.preload=t.preload,e.src=t.url}},{key:"eventBind",value:function(){var e=this,t=this.art,n=t.events.proxy,i=t.refs.$video;b.video.events.forEach(function(t){n(i,t,function(t){e.art.emit("video:".concat(t.type),t)})}),this.art.on("video:loadstart",function(){e.art.loading.show()}),this.art.on("video:loadeddata",function(){e.art.loading.hide()}),this.art.on("video:canplay",function(){if(e.art.controls.show(),e.art.mask.show(),e.art.option.autoplay){var t=e.play();void 0!==t&&t.then().catch(function(t){console.warn(t)})}}),this.art.on("video:playing",function(){e.art.playing=!0,e.art.controls.hide(),e.art.mask.hide()}),this.art.on("video:pause",function(){e.art.playing=!1,e.art.controls.show(),e.art.mask.show()}),this.art.on("video:ended",function(){e.art.playing=!1,e.art.controls.show(),e.art.mask.show()})}},{key:"play",value:function(){var t=this.art.refs.$video,e=t.play();return this.art.emit("play",t),e}},{key:"pause",value:function(){var t=this.art.refs.$video;t.pause(),this.art.emit("pause",t)}},{key:"toggle",value:function(){this.art.playing?this.pause():this.play()}},{key:"seek",value:function(t){var e=this.art.refs.$video,n=Math.max(t,0);e.duration&&(n=Math.min(n,e.duration)),e.currentTime=n,this.art.emit("seek",n)}},{key:"currentTime",value:function(){return this.art.refs.$video.currentTime}},{key:"volume",value:function(t){var e=this.art.refs.$video;t&&(e.volume=y(t,0,1)),this.art.emit("volume",e.volume)}},{key:"switchVolumeIcon",value:function(){}},{key:"switchVideo",value:function(){}},{key:"switchQuality",value:function(){}},{key:"resize",value:function(){}},{key:"speed",value:function(t){this.art.refs.$video.playbackRate=t,this.art.emit("speed",t)}}]),e}();var E=function t(e,n){o(this,t),this.art=e,this.option=n},C=function t(e,n){o(this,t),this.art=e,this.option=n},q=function t(e,n){o(this,t),this.art=e,this.option=n},L=function t(e,n){o(this,t),this.art=e,this.option=n},O=function t(e,n){o(this,t),this.art=e,this.option=n},A=function t(e,n){o(this,t),this.art=e,this.option=n},M=function t(e,n){o(this,t),this.art=e,this.option=n},P=function t(e,n){o(this,t),this.art=e,this.option=n},j=function t(e,n){o(this,t),this.art=e,this.option=n},R=function t(e,n){o(this,t),this.art=e,this.option=n},N=function t(e,n){o(this,t),this.art=e,this.option=n},D=0,_=function(){function e(t){o(this,e),this.art=t,this.$map={top:[],left:[],right:[]},this.init(),this.mount()}return r(e,[{key:"init",value:function(){var e=this;this.add({control:A,disable:!1,html:"Progress",position:"top",index:10}),this.add({control:q,disable:!1,html:"Highlight",position:"top",index:20}),this.add({control:M,disable:!1,html:"Screenshot",position:"top",index:30}),this.add({control:O,disable:!1,html:"PlayAndPause",tooltip:"PlayAndPause",position:"left",index:10}),this.add({control:R,disable:!1,html:"Volume",tooltip:"Volume",position:"left",index:20}),this.add({control:j,disable:!1,html:"Time",tooltip:"Volume",position:"left",index:30}),this.add({control:E,disable:!1,html:"Danmu",tooltip:"Danmu",position:"right",index:10}),this.add({control:P,disable:!1,html:"Subtitle",tooltip:"Subtitle",position:"right",index:20}),this.add({control:N,disable:!1,html:"Setting",tooltip:"Setting",position:"right",index:30}),this.add({control:L,disable:!1,html:"Pip",tooltip:"Pip",position:"right",index:40}),this.add({control:C,disable:!1,html:"Fullscreen",tooltip:"Fullscreen",position:"right",index:50}),this.art.option.controls.forEach(function(t){e.add(t)})}},{key:"add",value:function(t){var e;if(d("function"==typeof(e=t).control,"'control' option require 'function' type, but got '".concat(a(e.control),"'.")),d("boolean"==typeof e.disable,"'disable' option require 'boolean' type, but got '".concat(a(e.disable),"'.")),d("string"==typeof e.html||e.html instanceof Element,"'html' option require 'string' or 'Element' type, but got '".concat(a(e.html),"'.")),d(-1<["top","left","right"].indexOf(e.position),"'position' option require one of 'top、left、right', but got '".concat(e.position,"'.")),d("number"==typeof e.index,"'index' option require 'number' type, but got '".concat(a(e.index),"'.")),!t.disable){D++;var n=t.control.name.toLowerCase()||"control".concat(D),i=document.createElement("div");i.setAttribute("class","art-control art-control-".concat(n)),i.setAttribute("data-control-index",String(t.index)||D),g(i,t.style||{}),v(i,t.html),t.ref=i,this.commonMethod(t),this[n]=new t.control(this.art,t),this.$map[t.position].push(i)}}},{key:"mount",value:function(){var t=this,e=this.art.refs,n=e.$progress,i=e.$controlsLeft,o=e.$controlsRight;Object.keys(this.$map).forEach(function(e){t.$map[e].sort(function(t,e){return Number(t.dataset.controlIndex)-Number(e.dataset.controlIndex)}).forEach(function(t){switch(e){case"top":n.appendChild(t);break;case"left":i.appendChild(t);break;case"right":o.appendChild(t)}})})}},{key:"commonMethod",value:function(t){var e=this;Object.defineProperty(t.control.prototype,"hide",{value:function(){t.ref.style.display="none",e.art.emit("control:hide",t.ref)}}),Object.defineProperty(t.control.prototype,"show",{value:function(){t.ref.style.display="top"===t.position?"block":"inline-block",e.art.emit("control:show",t.ref)}}),Object.defineProperty(t.control.prototype,"addMenu",{value:function(t){console.log(t)}})}},{key:"show",value:function(){this.art.refs.$container.classList.add("controls-show")}},{key:"hide",value:function(){this.art.refs.$container.classList.remove("controls-show")}}]),e}(),B=function(){function e(t){o(this,e),this.art=t,this.init()}return r(e,[{key:"init",value:function(){var e=this,t=this.art,n=t.option,i=t.i18n,o=t.refs,r=t.events.proxy;n.contextmenu.push({text:i.get("Video info"),click:function(){e.art.info.show()}},{text:i.get("About author"),link:"https://github.com/zhw2590582"},{text:"ArtPlayer 1.0.0",link:"https://github.com/zhw2590582/artplayer"},{text:i.get("Close"),click:function(){e.hide()}}),r(o.$container,"contextmenu",function(t){t.preventDefault(),e.art.focus=!0,o.$contextmenu||e.creatMenu(),e.show(),e.setPos(t)}),r(o.$container,"click",function(t){o.$contextmenu&&!t.path.includes(o.$contextmenu)&&e.hide()})}},{key:"creatMenu",value:function(){var n=this,t=this.art,e=t.option,i=t.refs,o=t.events.proxy;i.$contextmenu=document.createElement("div"),i.$contextmenu.classList.add("artplayer-contextmenu"),e.contextmenu.forEach(function(e){var t=document.createElement("a");t.innerHTML=e.text,t.classList.add("art-menu"),e.link?(t.target="_blank",t.href=e.link):e.click&&(t.href="#",o(t,"click",function(t){t.preventDefault(),e.click(n.art,t),n.hide()})),v(i.$contextmenu,t)}),v(i.$container,i.$contextmenu)}},{key:"setPos",value:function(t){var e=this.art.refs,n=t.clientX,i=t.clientY,o=e.$container.getBoundingClientRect(),r=o.height,a=o.width,s=o.left,c=o.top,u=e.$contextmenu.getBoundingClientRect(),l=u.height,f=u.width,h=n-s,p=i-c;s+a".concat(t,"
")}).join("")}n.art.emit("subtitle:update",a)})}}},{key:"show",value:function(){var t=this.art.refs.$subtitle;t.style.display="block",this.art.emit("subtitle:show",t)}},{key:"hide",value:function(){var t=this.art.refs.$subtitle;t.style.display="none",this.art.emit("subtitle:hide",t)}},{key:"switch",value:function(t){var e=this.art.refs.$track;d("vtt"===m(t),"'url' option require 'vtt' format, but got '".concat(m(t),"'.")),d(e,"You need to initialize the subtitle option first."),e.src=t,this.art.emit("subtitle:switch",t)}}]),e}(),W=function(){function e(t){o(this,e),this.art=t,this.destroyEvents=[],this.proxy=this.proxy.bind(this)}return r(e,[{key:"proxy",value:function(t,e,n){var i=3\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n',play:'\n \n \n'},K={},Object.keys(J).forEach(function(t){var e=document.createElement("div");e.innerHTML='').concat(J[t]," ");var n=U(e.childNodes,1);K[t]=n[0]}),K),tt=function(){function e(t){o(this,e),this.art=t,this.init()}return r(e,[{key:"init",value:function(){var t=this.art,e=t.option;v(t.refs.$loading,e.loading||Z.loading)}},{key:"hide",value:function(){var t=this.art.refs.$loading;t.style.display="none",this.art.emit("loading:hide",t)}},{key:"show",value:function(){var t=this.art.refs.$loading;t.style.display="flex",this.art.emit("loading:show",t)}}]),e}(),et=function(){function e(t){o(this,e),this.art=t,this.timer=null}return r(e,[{key:"show",value:function(t,e){var n=this,i=this.art.refs.$notice;i.style.display="block",i.innerHTML=t instanceof Error?t.message.trim():t,e&&(clearTimeout(this.timer),this.timer=setTimeout(function(){n.hide()},1e3)),this.art.emit("notice:show",i)}},{key:"hide",value:function(){var t=this.art.refs.$notice;t.style.display="none",this.art.emit("notice:hide",t)}}]),e}(),nt=function(){function e(t){o(this,e),this.art=t,this.init()}return r(e,[{key:"init",value:function(){var t=this,e=this.art,n=e.player,i=e.option,o=e.refs,r=e.events.proxy;Z.play.style.backgroundColor=i.theme,v(o.$mask,Z.play),r(o.$mask,"click",function(){n.play(),t.hide()})}},{key:"show",value:function(){var t=this.art.refs.$mask;t.style.display="flex",this.art.emit("mask:show",t)}},{key:"hide",value:function(){var t=this.art.refs.$mask;t.style.display="none",this.art.emit("mask:show",t)}}]),e}(),it=0,ot=[],rt=function(t){function i(t){var e,n;return o(this,i),(e=c(this,u(i).call(this))).emit("init:start"),e.option=Object.assign({},i.DEFAULTS,t),d((n=e.option).container,"'container' option is required."),d(n.url,"'url' option is required."),d("string"==typeof n.container||n.container instanceof Element,"'container' option require 'string' or 'Element' type, but got '".concat(a(n.container),"'.")),d("string"==typeof n.url,"'url' option require 'string' type, but got '".concat(a(n.url),"'.")),d("string"==typeof n.poster,"'poster' option require 'string' type, but got '".concat(a(n.poster),"'.")),d("number"==typeof n.volume,"'volume' option require 'number' type, but got '".concat(a(n.volume),"'.")),d("boolean"==typeof n.autoplay,"'autoplay' option require 'boolean' type, but got '".concat(a(n.autoplay),"'.")),d(-1<["none","metadata","auto"].indexOf(n.preload),"'preload' option require one of 'none、metadata、auto', but got '".concat(n.preload,".")),d("string"==typeof n.lang,"'lang' option require 'string' type, but got '".concat(a(n.lang),"'.")),d("string"==typeof n.type,"'type' option require 'string' type, but got '".concat(a(n.type),"'.")),d("string"==typeof n.mimeCodec,"'mimeCodec' option require 'string' type, but got '".concat(a(n.mimeCodec),"'.")),d(Array.isArray(n.layers),"'layers' option require 'array' type, but got '".concat(a(n.layers),"'.")),d(Array.isArray(n.contextmenu),"'contextmenu' option require 'array' type, but got '".concat(a(n.contextmenu),"'.")),d("string"==typeof n.loading||n.loading instanceof Element,"'loading' option require 'string' type, but got '".concat(a(n.loading),"'.")),d("string"==typeof n.theme,"'theme' option require 'string' type, but got '".concat(a(n.theme),"'.")),d("boolean"==typeof n.hotkey,"'hotkey' option require 'boolean' type, but got '".concat(a(n.hotkey),"'.")),d("[object Object]"===Object.prototype.toString.call(n.subtitle),"'subtitle' option require 'object' type, but got '".concat(a(n.subtitle),"'.")),d(Array.isArray(n.controls),"'controls' option require 'array' type, but got '".concat(a(n.controls),"'.")),e.init(),e.emit("init:end"),e}return n(i,x),r(i,[{key:"init",value:function(){return this.focus=!1,this.playing=!1,this.refs={},this.option.container instanceof Element?this.refs.$container=this.option.container:this.refs.$container=document.querySelector(this.option.container),this.refs.$container.classList.add("artplayer-container"),this.template=new w(this),this.i18n=new T(this),this.events=new W(this),this.player=new S(this),this.layers=new Q(this),this.controls=new _(this),this.contextmenu=new B(this),this.danmu=new H(this),this.subtitle=new Y(this),this.info=new V(this),this.loading=new tt(this),this.notice=new et(this),this.hotkey=new X(this),this.mask=new nt(this),this.id=it++,ot.push(this),this}},{key:"destroy",value:function(){this.events.destroy(),this.refs.$container.classList.remove("artplayer-container"),this.refs.$container.innerHTML="",ot.splice(ot.indexOf(this),1),this.emit("destroy")}}],[{key:"use",value:function(t){var e=this.plugins||(this.plugins=[]);if(-1