Files
ArtPlayer/dist/artplayer.js
T
2018-10-19 09:30:37 +08:00

2 lines
28 KiB
JavaScript

!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<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var r=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var a=e(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=i=function(t){return n(t)}:e.exports=i=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},i(t)}e.exports=i});var s=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var c=function(t,e){return!e||"object"!==a(e)&&"function"!=typeof e?s(t):e},u=e(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),l=e(function(n){function i(t,e){return n.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}n.exports=i});var n=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)};var f=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},h=e(function(i){function o(t,e,n){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?i.exports=o=function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&l(o,n.prototype),o}:i.exports=o=Reflect.construct,o.apply(null,arguments)}i.exports=o}),p=function(t){function i(t,e){var n;return o(this,i),n=c(this,u(i).call(this,t)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(s(s(n)),e||n.constructor),n.name="ArtPlayerError",n}return n(i,t),i}(e(function(e){function i(t){var n="function"==typeof Map?new Map:void 0;return e.exports=i=function(t){if(null===t||!f(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return h(t,arguments,u(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),l(e,t)},i(t)}e.exports=i})(Error));function d(t,e){if(!t)throw new p(e)}function y(t,e,n){return Math.max(Math.min(t,Math.max(e,n)),Math.min(e,n))}function m(t){return t.includes("?")?m(t.split("?")[0]):t.trim().toLowerCase().split(".").pop()}function v(t,e){return e instanceof Element?t.appendChild(e):t.innerHTML=e,t}function g(e,n){return Object.keys(n).forEach(function(t){e.style[t]=n[t]}),e}var b={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"'},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"]}},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"]}};function k(){}k.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,a=i.length;r<a;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}};var x=k,w=function(){function e(t){o(this,e),this.art=t,this.init()}return r(e,[{key:"init",value:function(){var t=this.art.refs;t.$container.innerHTML='\n <video class="artplayer-video" webkit-playsinline playsinline></video>\n <div class="artplayer-subtitle"></div>\n <div class="artplayer-layers"></div>\n <div class="artplayer-mask"></div>\n <div class="artplayer-bottom">\n <div class="artplayer-progress"></div>\n <div class="artplayer-controls">\n <div class="artplayer-controls-left"></div>\n <div class="artplayer-controls-right"></div>\n </div>\n </div>\n <div class="artplayer-loading"></div>\n <div class="artplayer-notice"></div>\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<n+f&&(h=a-f),c+r<i+l&&(p=r-l),e.$contextmenu.style.left="".concat(h,"px"),e.$contextmenu.style.top="".concat(p,"px")}},{key:"hide",value:function(){var t=this.art.refs.$contextmenu;t&&(t.style.display="none",this.art.emit("contextmenu:hide",t))}},{key:"show",value:function(){var t=this.art.refs.$contextmenu;t&&(t.style.display="block",this.art.emit("contextmenu:show",t))}}]),e}(),H=function t(e){o(this,t),this.art=e},V=function(){function e(t){o(this,e),this.art=t}return r(e,[{key:"show",value:function(){console.log("info show")}},{key:"hide",value:function(){console.log("info hide")}}]),e}();var F=function(t){if(Array.isArray(t))return t};var z=function(t,e){var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){o=!0,r=t}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}return n};var I=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var U=function(t,e){return F(t)||z(t,e)||I()},Y=function(){function e(t){o(this,e),this.art=t,this.art.option.subtitle&&(d("vtt"===m(this.art.option.subtitle.url),"'url' option require 'vtt' format, but got '".concat(m(this.art.option.subtitle.url),"'.")),this.init())}return r(e,[{key:"init",value:function(){var n=this,t=this.art,e=t.events.proxy,i=t.option.subtitle,o=t.refs,r=o.$video,a=o.$subtitle;g(a,i.style||{});var s=document.createElement("track");if(s.default=!0,s.kind="metadata",s.src=i.url,r.appendChild(s),this.art.refs.$track=s,r.textTracks&&r.textTracks[0]){var c=U(r.textTracks,1)[0];e(c,"cuechange",function(){var t=U(c.activeCues,1)[0];if(a.innerHTML="",t){var e=document.createElement("div");e.appendChild(t.getCueAsHTML()),a.innerHTML=e.innerHTML.split(/\r?\n/).map(function(t){return"<p>".concat(t,"</p>")}).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<arguments.length&&void 0!==arguments[3]?arguments[3]:{};t.addEventListener(e,n,i),this.destroyEvents.push(function(){t.removeEventListener(e,n,i)})}},{key:"destroy",value:function(){this.destroyEvents.forEach(function(t){return t()})}}]),e}(),X=function(){function e(t){o(this,e),this.art=t,this.art.option.hotkey&&this.init()}return r(e,[{key:"init",value:function(){var o=this,t=this.art,r=t.player,a=t.notice,s=t.i18n,e=t.refs.$container,n=t.events.proxy;n(document,"click",function(t){o.art.focus=-1<t.path.indexOf(e)}),n(window,"keydown",function(t){if(o.art.focus){var e,n=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==n&&"TEXTAREA"!==n&&""!==i&&"true"!==i)switch(t.keyCode){case 39:t.preventDefault(),r.seek(r.currentTime()+10),a.show(s.get("Fast forward 10 seconds"),!0);break;case 37:t.preventDefault(),r.seek(r.currentTime()-10),a.show(s.get("Rewind 10 seconds"),!0);break;case 38:t.preventDefault(),e=r.volume()+.1,r.volume(e),a.show(s.get("10% increase in volume"),!0);break;case 40:t.preventDefault(),e=r.volume()-.1,r.volume(e),a.show(s.get("10% reduction in volume"),!0);break;case 32:t.preventDefault(),r.toggle()}}})}}]),e}(),G=0,Q=function(){function e(t){o(this,e),this.art=t,this.add=this.add.bind(this),this.art.option.layers.forEach(this.add),this.init()}return r(e,[{key:"init",value:function(){var t=this.art,e=t.refs,n=t.player;(0,t.events.proxy)(e.$layers,"click",function(t){t.path[0]===e.$layers&&n.pause()})}},{key:"add",value:function(t,e){var n=this.art.refs;G++;var i=document.createElement("div");i.setAttribute("data-art-layer-id",G),i.setAttribute("class","art-layer art-layer-".concat(t.name||G)),i.style.zIndex=t.index||G,v(i,t.html),g(i,t.style||{}),n.$layers.appendChild(i),this.art.emit("layers:add",i),e&&e(i)}},{key:"show",value:function(){var t=this.art.refs.$layers;t.style.display="block",this.art.emit("layers:show",t)}},{key:"hide",value:function(){var t=this.art.refs.$layers;t.style.display="none",this.art.emit("layers:hide",t)}}]),e}();var J,K,Z=(J={loading:'<svg class="lds-spinner" width="80px" height="80px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" style="background: none;"><g transform="rotate(0 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(30 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(60 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(90 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(120 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(150 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(180 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(210 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(240 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(270 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(300 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>\n </rect>\n</g><g transform="rotate(330 50 50)">\n <rect x="47" y="24" rx="9.4" ry="4.8" width="6" height="12" fill="#ffffff">\n <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>\n </rect>\n</g></svg>\n',play:'<svg id="plyr-play" width="16px" height="18px">\n <path d="M15.562 8.1L3.87.225C3.052-.337 2 .225 2 1.125v15.75c0 .9 1.052 1.462 1.87.9L15.563 9.9c.584-.45.584-1.35 0-1.8z"></path>\n</svg>\n'},K={},Object.keys(J).forEach(function(t){var e=document.createElement("div");e.innerHTML='<i class="art-icon art-icon-'.concat(t,'">').concat(J[t],"</i>");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<e.indexOf(t))return this;var n=Array.from(arguments).slice(1);return n.unshift(this),"function"==typeof t.install?t.install.apply(t,n):"function"==typeof t&&t.apply(null,n),e.push(t),this}},{key:"version",get:function(){return"1.0.0"}},{key:"config",get:function(){return b}},{key:"DEFAULTS",get:function(){return{container:".artplayer",url:"",poster:"",volume:.7,autoplay:!1,preload:"auto",type:"",mimeCodec:"",layers:[],contextmenu:[],loading:"",theme:"#1aafff",hotkey:!0,subtitle:{url:"",style:{}},controls:[],lang:navigator.language.toLowerCase()}}}]),i}();window.Artplayer=rt,t.instances=ot,t.default=rt,Object.defineProperty(t,"__esModule",{value:!0})});