Files
ArtPlayer/dist/artplayer.js
T
2018-11-02 16:56:52 +08:00

2 lines
59 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!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";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(t,e){return t(e={exports:{}},e.exports),e.exports}var o=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}),r=e(function(i){function r(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=r=function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&o(r,n.prototype),r}:i.exports=r=Reflect.construct,r.apply(null,arguments)}i.exports=r});var n=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}};var i=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)};var a=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var u=function(t){return n(t)||i(t)||a()};var s=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function c(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 l=function(t,e,n){return e&&c(t.prototype,e),n&&c(t,n),t},h=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 d=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var f=function(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?d(t):e},p=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});var v=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&&o(t,e)};var y=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var m=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(t){y(e,t,n[t])})}return e};var g=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},b=function(t){function i(t,e){var n;return s(this,i),n=f(this,p(i).call(this,t)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(d(d(n)),e||n.constructor),n.name="ArtPlayerError",n}return v(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||!g(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 r(t,arguments,p(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},i(t)}e.exports=i})(Error));function w(t,e){var n="function"==typeof t;if(n?!n():!t)throw new b(e)}function $(t,e,n){return Math.max(Math.min(t,Math.max(e,n)),Math.min(e,n))}function k(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",e),t.lastElementChild}function x(t,e,n){return t.style[e]=n,t}function S(e,n){return Object.keys(n).forEach(function(t){x(e,t,n[t])}),e}function C(t){var e=Math.floor(t/3600),n=Math.floor((t-3600*e)/60),i=Math.floor(t-3600*e-60*n);return(0<e?[e,n,i]:[n,i]).map(function(t){return t<10?"0".concat(t):String(t)}).join(":")}function T(t){var e=JSON.parse(localStorage.getItem("artplayer_settings"))||{};return t?e[t]:e}function L(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"up";t.setAttribute("data-balloon",e),t.setAttribute("data-balloon-pos",n)}function E(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;return new Promise(function(t){return setTimeout(t,e)})}function M(e){return Array.from(e.parentElement.children).filter(function(t){return t!==e})}var A=e(function(t,e){t.exports=function(){function c(t){return(c="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)}var l=Object.prototype.toString,a=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e,n,i,r,o,a,s=c(t);if("boolean"===s)return"boolean";if("string"===s)return"string";if("number"===s)return"number";if("symbol"===s)return"symbol";if("function"===s)return"GeneratorFunction"===u(t)?"generatorfunction":"function";if(e=t,Array.isArray?Array.isArray(e):e instanceof Array)return"array";if((a=t).constructor&&"function"==typeof a.constructor.isBuffer&&a.constructor.isBuffer(a))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if((n=t)instanceof Date||"function"==typeof n.toDateString&&"function"==typeof n.getDate&&"function"==typeof n.setDate)return"date";if((i=t)instanceof Error||"string"==typeof i.message&&i.constructor&&"number"==typeof i.constructor.stackTraceLimit)return"error";if((r=t)instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global)return"regexp";switch(u(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if("function"==typeof(o=t).throw&&"function"==typeof o.return&&"function"==typeof o.next)return"generator";switch(s=l.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return s.slice(8,-1).toLowerCase().replace(/\s/g,"")};function u(t){return t.constructor?t.constructor.name:null}function o(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:["option"];for(var i in h(t,e,n),d(t,e,n),f(t,e,n),e)if(e.hasOwnProperty(i)){var r=t[i],o=e[i],a=n.concat(i);if(s(t,i,o,a))continue;h(r,o,a),d(r,o,a),f(r,o,a)}}function s(t,e,n,i){if(!Object.prototype.hasOwnProperty.call(t,e)){if(!0===n.__required__||!0===n.required)throw new TypeError("'".concat(i.join("."),"' is required"));return!0}}function h(t,e,n){var i;if("string"===a(e)?i=e:e.__type__?i=e.__type__:e.type&&(i=e.type),i&&"string"===a(i)){i=i.trim().toLowerCase();var r=a(t),o=r===i;if(-1<i.indexOf("|")&&(o=i.split("|").filter(Boolean).some(function(t){return r===t.trim()})),!o)throw new TypeError("'".concat(n.join("."),"' require '").concat(i,"' type, but got '").concat(r,"'"))}}function d(t,e,n){var i;if(e.___validator__?i=e.___validator__:e.validator&&(i=e.validator),"function"===a(i)){var r=i(n,t,a(t));if(!0!==r)throw new TypeError("The scheme for '".concat(n.join("."),"' validator function require return true, but got '").concat(r,"'"))}}function f(t,e,n){var i;if(e.___child__?i=e.___child__:e.child&&(i=e.child),"object"===a(i)){var r=a(t);"object"===r?o(t,i,n):"array"===r&&t.forEach(function(t,e){o(t,i,n.concat(e))})}}return o.kindOf=a,window.optionValidator=o}()});function P(t,e,n){if("string"===n){if(""===e.trim())throw new b("".concat(t.join(".")," can not be empty'"));return!0}if(e instanceof Element)return!0;throw new b("".concat(t.join(".")," require 'string' or 'Element' type, but got '").concat(n,"'"))}var H={container:{validator:P,required:!0},url:{type:"string",required:!0},volume:"number",thumbnails:{type:"object",child:{url:"string",number:"number",width:"number",height:"number",column:"number"}},screenshot:"boolean",autoplay:"boolean",playbackRate:"boolean",aspectRatio:"boolean",loop:"boolean",type:{type:"string"},mimeCodec:"string",layers:{type:"array",child:{name:"string",index:"number",html:{validator:P},style:"object"}},contextmenu:{type:"array",child:{type:"object|function",name:"string",html:{validator:P},click:"function"}},quality:{type:"array",child:{default:"boolean",name:"string",url:"string"}},loading:"string",theme:"string",hotkey:"boolean",pip:"boolean",fullscreen:"boolean",fullscreenWeb:"boolean",subtitle:{type:"object",child:{url:"string",style:"object"}},controls:{type:"array",child:{option:{type:"object",child:{disable:"boolean",position:"boolean",index:"number"}}}},highlight:{type:"array",child:{time:"number",text:"string"}},moreVideoAttr:"object",lang:"string"},O={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 j(){}j.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 r(){i.off(t,r),e.apply(n,arguments)}return r._=e,this.on(t,r,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,r=n.length;i<r;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],r=[];if(i&&e)for(var o=0,a=i.length;o<a;o++)i[o].fn!==e&&i[o].fn._!==e&&r.push(i[o]);return r.length?n[t]=r:delete n[t],this}};var R=j,q=function(){function e(t){s(this,e),this.art=t,this.init()}return l(e,[{key:"init",value:function(){var t=this.art.refs;t.$container.innerHTML='\n <div class="artplayer-video-player">\n <video class="artplayer-video"></video>\n <div class="artplayer-subtitle"></div>\n <div class="artplayer-danmu"></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">\n <div class="artplayer-notice-inner"></div>\n </div>\n <div class="artplayer-setting">\n <div class="artplayer-setting-inner">\n <div class="artplayer-setting-body"></div>\n <div class="artplayer-setting-close">×</div>\n </div>\n </div>\n <div class="artplayer-info">\n <div class="artplayer-info-panel"></div>\n <div class="artplayer-info-close">[x]</div>\n </div>\n </div>\n ',t.$player=t.$container.querySelector(".artplayer-video-player"),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.$danmu=t.$container.querySelector(".artplayer-danmu"),t.$loading=t.$container.querySelector(".artplayer-loading"),t.$notice=t.$container.querySelector(".artplayer-notice"),t.$noticeInner=t.$container.querySelector(".artplayer-notice-inner"),t.$mask=t.$container.querySelector(".artplayer-mask"),t.$setting=t.$container.querySelector(".artplayer-setting"),t.$settingInner=t.$container.querySelector(".artplayer-setting-inner"),t.$settingBody=t.$container.querySelector(".artplayer-setting-body"),t.$settingClose=t.$container.querySelector(".artplayer-setting-close"),t.$info=t.$container.querySelector(".artplayer-info"),t.$infoPanel=t.$container.querySelector(".artplayer-info-panel"),t.$infoClose=t.$container.querySelector(".artplayer-info-close")}}]),e}(),_={"zh-cn":{"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常",Switch:"切换",Common:"常规","Hide setting":"隐藏设置","Show setting":"显示设置"},"zh-tw":{"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常",Switch:"切換",Common:"常規","Hide setting":"隱藏設置","Show setting":"顯示設置"}},I=function(){function n(t){var e=t.option;s(this,n),this.option=e,this.init()}return l(n,[{key:"init",value:function(){this.language=_[this.option.lang.toLowerCase()]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){_=t(_),this.init()}}]),n}(),V=function(){function e(t){s(this,e),this.art=t,this.init(),this.eventBind(),this.firstCanplay=!1,this.reconnectTime=0,this.maxReconnectTime=5}return l(e,[{key:"init",value:function(){var t=this.art,n=t.option,i=t.refs.$video;Object.keys(n.moreVideoAttr).forEach(function(t){var e=n.moreVideoAttr[t];i[t]=e}),i.volume=$(n.volume,0,1),i.poster=n.poster,i.autoplay=n.autoplay,i.src=n.url}},{key:"eventBind",value:function(){var e=this,t=this.art,n=t.option,i=t.events,r=i.proxy,o=i.hover,a=t.refs,s=a.$player,c=a.$video,l=t.i18n,u=t.notice;O.video.events.forEach(function(t){r(c,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:waiting",function(){e.art.loading.show()}),this.art.on("video:seeking",function(){e.art.loading.show()}),this.art.on("video:canplay",function(){e.firstCanplay||(e.firstCanplay=!0,e.art.emit("firstCanplay")),e.art.controls.show(),e.art.mask.show(),e.art.loading.hide(),n.autoplay&&e.play()}),this.art.on("video:playing",function(){e.art.isPlaying=!0,e.art.controls.hide(),e.art.mask.hide()}),this.art.on("video:pause",function(){e.art.isPlaying=!1,e.art.controls.show(),e.art.mask.show()}),this.art.on("video:ended",function(){e.art.isPlaying=!1,e.art.controls.show(),e.art.mask.show(),n.loop&&(e.seek(0),e.play())}),this.art.on("video:error",function(){e.reconnectTime<e.maxReconnectTime?E(1e3).then(function(){e.reconnectTime++,c.src=n.url,u.show("".concat(l.get("Reconnect"),": ").concat(e.reconnectTime))}):(e.art.isError=!0,e.art.isPlaying=!1,e.art.loading.hide(),e.art.controls.hide(),s.classList.add("artplayer-error"),E(1e3).then(function(){u.show(l.get("Video load failed"),!1),e.art.destroy()}))}),o(s,function(){s.classList.add("artplayer-hover"),e.art.emit("hoverenter")},function(){s.classList.remove("artplayer-hover"),e.art.emit("hoverleave")})}},{key:"play",value:function(){var t=this.art,e=t.refs.$video,n=t.i18n,i=t.notice,r=e.play();void 0!==r&&r.then().catch(function(t){i.show(t,!0,3e3),console.warn(t)}),i.show(n.get("Play")),this.art.emit("play",e)}},{key:"pause",value:function(){var t=this.art,e=t.refs.$video,n=t.i18n,i=t.notice;e.pause(),i.show(n.get("Pause")),this.art.emit("pause",e)}},{key:"toggle",value:function(){this.art.isPlaying?this.pause():this.play()}},{key:"seek",value:function(t){var e=this.art,n=e.refs.$video,i=e.notice,r=Math.max(t,0);n.duration&&(r=Math.min(r,n.duration)),n.currentTime=r,i.show("".concat(C(r)," / ").concat(C(n.duration))),this.art.emit("seek",r)}},{key:"volume",value:function(t){var e,n,i,r=this.art,o=r.refs.$video,a=r.i18n,s=r.notice;return void 0!==t&&(o.volume=$(t,0,1),s.show("".concat(a.get("Volume"),": ").concat(parseInt(100*o.volume))),0!==o.volume&&(e="volume",n=o.volume,i=Object.assign({},T(),y({},e,n)),localStorage.setItem("artplayer_settings",JSON.stringify(i))),this.art.emit("volume",o.volume)),o.volume||0}},{key:"currentTime",value:function(){return this.art.refs.$video.currentTime||0}},{key:"duration",value:function(){return this.art.refs.$video.duration||0}},{key:"switch",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"Unknown",n=this.art,i=n.refs.$video,r=n.i18n,o=n.notice,a=n.isPlaying,s=n.option,c=this.currentTime();i.src=t,s.url=t,this.reconnectTime=0,this.seek(c),a&&this.play(),this.resetStyle(),o.show("".concat(r.get("Switch"),": ").concat(e)),this.art.emit("switch",t)}},{key:"playbackRate",value:function(t){var e=this.art,n=e.refs,i=n.$video,r=n.$player,o=e.i18n,a=e.notice,s=$(t,.1,10);i.playbackRate=s,r.dataset.playbackRate=s,a.show("".concat(o.get("Rate"),": ").concat(1===s?o.get("Normal"):"".concat(s,"x"))),this.art.emit("playbackRate",s)}},{key:"aspectRatio",value:function(t){var e=this.art,n=e.refs,i=n.$video,r=n.$player,o=e.i18n,a=e.notice,s=2===t.length?"".concat(t[0],":").concat(t[1]):o.get("Default");if(2===t.length){var c=i.videoWidth,l=i.videoHeight,u=r.clientWidth,h=r.clientHeight,d=c/l,f=Number(t[0])/Number(t[1]);if(f<d){var p=f*l/c;x(i,"width","".concat(100*p,"%")),x(i,"height","100%"),x(i,"padding","0 ".concat((u-u*p)/2,"px"))}else{var v=c/f/l;x(i,"width","100%"),x(i,"height","".concat(100*v,"%")),x(i,"padding","".concat((h-h*v)/2,"px 0"))}r.dataset.aspectRatio=s}else x(i,"width",null),x(i,"height",null),x(i,"padding",null),delete r.dataset.aspectRatio;a.show("".concat(o.get("Aspect ratio"),": ").concat(s)),this.art.emit("aspectRatio",t)}},{key:"resetStyle",value:function(){var t=this.art,e=t.refs.$video,n=t.contextmenu;if(n.$playbackRate){var i=n.$playbackRate.querySelector(".normal");M(i).forEach(function(t){return t.classList.remove("current")}),i.classList.add("current")}if(x(e,"width",null),x(e,"height",null),x(e,"padding",null),n.$aspectRatio){var r=n.$aspectRatio.querySelector(".default");M(r).forEach(function(t){return t.classList.remove("current")}),r.classList.add("current")}}}]),e}();var B=function(t){if(Array.isArray(t))return t};var D=function(t,e){var n=[],i=!0,r=!1,o=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){r=!0,o=t}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n};var N=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var z=function(t,e){return B(t)||D(t,e)||N()};var W,F,U=(W={loading:'<svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-default">\n <rect x="0" y="0" width="100" height="100" fill="none" class="bk"/>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(0 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-1s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(30 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(60 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(90 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.75s" repeatCount="indefinite"/></rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(120 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(150 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(180 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.5s" repeatCount="indefinite"/></rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(210 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(240 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(270 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.25s" repeatCount="indefinite"/></rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(300 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"/>\n </rect>\n <rect x="47" y="40" width="6" height="20" rx="5" ry="5" fill="#ffffff" transform="rotate(330 50 50) translate(0 -30)">\n <animate attributeName="opacity" from="1" to="0" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"/>\n </rect>\n</svg>',playBig:'<svg style="width: 60px; height: 60px; filter: drop-shadow(0px 1px 1px black);" version="1.1" viewBox="0 0 24 24" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="info"/>\n <g id="icons">\n <path d="M20,2H4C1.8,2,0,3.8,0,6v12c0,2.2,1.8,4,4,4h16c2.2,0,4-1.8,4-4V6C24,3.8,22.2,2,20,2z M15.6,12.8L10.5,16 C9.9,16.5,9,16,9,15.2V8.8C9,8,9.9,7.5,10.5,8l5.1,3.2C16.3,11.5,16.3,12.5,15.6,12.8z" id="video"/>\n </g>\n</svg>',play:'<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%" viewBox="0 0 22 22">\n <path d="M17.982 9.275L8.06 3.27A2.013 2.013 0 0 0 5 4.994v12.011a2.017 2.017 0 0 0 3.06 1.725l9.922-6.005a2.017 2.017 0 0 0 0-3.45z"></path>\n</svg>',pause:'<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%" viewBox="0 0 22 22">\n <path d="M7 3a2 2 0 0 0-2 2v12a2 2 0 1 0 4 0V5a2 2 0 0 0-2-2zM15 3a2 2 0 0 0-2 2v12a2 2 0 1 0 4 0V5a2 2 0 0 0-2-2z"></path>\n</svg>',volume:'<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%" viewBox="0 0 22 22">\n <path d="M10.188 4.65L6 8H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h1l4.188 3.35a.5.5 0 0 0 .812-.39V5.04a.498.498 0 0 0-.812-.39zM14.446 3.778a1 1 0 0 0-.862 1.804 6.002 6.002 0 0 1-.007 10.838 1 1 0 0 0 .86 1.806A8.001 8.001 0 0 0 19 11a8.001 8.001 0 0 0-4.554-7.222z"></path><path d="M15 11a3.998 3.998 0 0 0-2-3.465v6.93A3.998 3.998 0 0 0 15 11z"></path>\n</svg>',volumeClose:'<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%" viewBox="0 0 22 22">\n <path d="M15 11a3.998 3.998 0 0 0-2-3.465v2.636l1.865 1.865A4.02 4.02 0 0 0 15 11z"></path>\n <path d="M13.583 5.583A5.998 5.998 0 0 1 17 11a6 6 0 0 1-.585 2.587l1.477 1.477a8.001 8.001 0 0 0-3.446-11.286 1 1 0 0 0-.863 1.805zM18.778 18.778l-2.121-2.121-1.414-1.414-1.415-1.415L13 13l-2-2-3.889-3.889-3.889-3.889a.999.999 0 1 0-1.414 1.414L5.172 8H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h1l4.188 3.35a.5.5 0 0 0 .812-.39v-3.131l2.587 2.587-.01.005a1 1 0 0 0 .86 1.806c.215-.102.424-.214.627-.333l2.3 2.3a1.001 1.001 0 0 0 1.414-1.416zM11 5.04a.5.5 0 0 0-.813-.39L8.682 5.854 11 8.172V5.04z"></path>\n</svg>',subtitle:'<svg style="width: 100%; height: 100%" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">\n <path d="M0 0h48v48H0z" fill="none"/>\n <path d="M40 8H8c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM8 24h8v4H8v-4zm20 12H8v-4h20v4zm12 0h-8v-4h8v4zm0-8H20v-4h20v4z"/>\n</svg>',screenshot:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" style="width: 100%; height: 100%">\n\t<g id="surface1">\n\t\t<path d="M 19.402344 6 C 17.019531 6 14.96875 7.679688 14.5 10.011719 L 14.097656 12 L 9 12 C 6.238281 12 4 14.238281 4 17 L 4 38 C 4 40.761719 6.238281 43 9 43 L 41 43 C 43.761719 43 46 40.761719 46 38 L 46 17 C 46 14.238281 43.761719 12 41 12 L 35.902344 12 L 35.5 10.011719 C 35.03125 7.679688 32.980469 6 30.597656 6 Z M 25 17 C 30.519531 17 35 21.480469 35 27 C 35 32.519531 30.519531 37 25 37 C 19.480469 37 15 32.519531 15 27 C 15 21.480469 19.480469 17 25 17 Z M 25 19 C 20.589844 19 17 22.589844 17 27 C 17 31.410156 20.589844 35 25 35 C 29.410156 35 33 31.410156 33 27 C 33 22.589844 29.410156 19 25 19 Z "/>\n\t</g>\n</svg>\n',danmu:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" style="width: 85%; height: 85%">\r\n\t<path d="M54,2.5H6c-3.252,0-6,2.748-6,6v33c0,3.252,2.748,6,6,6h14.555l8.702,9.669C29.446,57.38,29.717,57.5,30,57.5 s0.554-0.12,0.743-0.331l8.702-9.669H54c3.252,0,6-2.748,6-6v-33C60,5.248,57.252,2.5,54,2.5z M16,28.5c-2.206,0-4-1.794-4-4 s1.794-4,4-4s4,1.794,4,4S18.206,28.5,16,28.5z M30,28.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S32.206,28.5,30,28.5z M44,28.5c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S46.206,28.5,44,28.5z"/>\r\n</svg>\r\n',setting:'<svg xmlns="http://www.w3.org/2000/svg" style="width: 100%; height: 100%" viewBox="0 0 22 22">\n <circle cx="11" cy="11" r="2"></circle>\n <path d="M19.164 8.861L17.6 8.6a6.978 6.978 0 0 0-1.186-2.099l.574-1.533a1 1 0 0 0-.436-1.217l-1.997-1.153a1.001 1.001 0 0 0-1.272.23l-1.008 1.225a7.04 7.04 0 0 0-2.55.001L8.716 2.829a1 1 0 0 0-1.272-.23L5.447 3.751a1 1 0 0 0-.436 1.217l.574 1.533A6.997 6.997 0 0 0 4.4 8.6l-1.564.261A.999.999 0 0 0 2 9.847v2.306c0 .489.353.906.836.986l1.613.269a7 7 0 0 0 1.228 2.075l-.558 1.487a1 1 0 0 0 .436 1.217l1.997 1.153c.423.244.961.147 1.272-.23l1.04-1.263a7.089 7.089 0 0 0 2.272 0l1.04 1.263a1 1 0 0 0 1.272.23l1.997-1.153a1 1 0 0 0 .436-1.217l-.557-1.487c.521-.61.94-1.31 1.228-2.075l1.613-.269a.999.999 0 0 0 .835-.986V9.847a.999.999 0 0 0-.836-.986zM11 15a4 4 0 1 1 0-8 4 4 0 0 1 0 8z"></path>\n</svg>'},F={},Object.keys(W).forEach(function(t){var e=document.createElement("div");e.innerHTML='<i class="art-icon art-icon-'.concat(t,'">').concat(W[t],"</i>");var n=z(e.childNodes,1);F[t]=n[0]}),F),Y=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){var e=this,n=this.option.$control,i=t.events.proxy,r=t.i18n,o=t.danmu;this.$danmu=k(n,U.danmu),L(this.$danmu,r.get("Hide danmu")),i(n,"click",function(){o.isOpen?(o.hide(),x(e.$danmu,"opacity","1"),L(e.$danmu,r.get("Show danmu"))):(o.show(),x(e.$danmu,"opacity","0.8"),L(e.$danmu,r.get("Hide danmu")))})}}]),e}(),Z=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){this.art=t}}]),e}(),G=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){this.art=t}}]),e}(),J=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){this.art=t}}]),e}(),X=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){var e=this,n=t.events.proxy,i=t.player,r=t.i18n;this.$play=k(this.option.$control,U.play),this.$pause=k(this.option.$control,U.pause),L(this.$play,r.get("Play")),L(this.$pause,r.get("Pause")),x(this.$pause,"display","none"),n(this.$play,"click",function(){i.play()}),n(this.$pause,"click",function(){i.pause()}),t.on("video:playing",function(){x(e.$play,"display","none"),x(e.$pause,"display","block")}),t.on("video:pause",function(){x(e.$play,"display","block"),x(e.$pause,"display","none")})}}]),e}(),K=function(){function e(t){s(this,e),this.option=t,this.isDroging=!1,this.getLoaded=this.getLoaded.bind(this),this.getPlayed=this.getPlayed.bind(this),this.set=this.set.bind(this)}return l(e,[{key:"apply",value:function(t){this.art=t,this.init()}},{key:"init",value:function(){var r=this,t=this.art,e=t.option,n=e.highlight,i=e.theme,o=t.events.proxy,a=t.refs.$video,s=t.player;k(this.option.$control,'\n <div class="art-control-progress-inner">\n <div class="art-progress-loaded"></div>\n <div class="art-progress-played" style="background: '.concat(i,'"></div>\n <div class="art-progress-highlight"></div>\n <div class="art-progress-indicator" style="background: ').concat(i,'"></div>\n <div class="art-progress-tip art-tip"></div>\n </div>\n ')),this.$loaded=this.option.$control.querySelector(".art-progress-loaded"),this.$played=this.option.$control.querySelector(".art-progress-played"),this.$highlight=this.option.$control.querySelector(".art-progress-highlight"),this.$indicator=this.option.$control.querySelector(".art-progress-indicator"),this.$tip=this.option.$control.querySelector(".art-progress-tip"),this.set("loaded",this.getLoaded()),n.forEach(function(t){var e=Number(t.time)/a.duration;k(r.$highlight,'\n <span data-text="'.concat(t.text,'" data-time="').concat(t.time,'" style="left: ').concat(100*e,'%"></span>\n '))}),this.art.on("video:progress",function(){r.set("loaded",r.getLoaded())}),this.art.on("video:timeupdate",function(){r.set("played",r.getPlayed())}),this.art.on("video:ended",function(){r.set("played",1)}),o(this.option.$control,"mousemove",function(t){x(r.$tip,"display","block"),-1<t.path.indexOf(r.$highlight)?r.showHighlight(t):r.showTime(t)}),o(this.option.$control,"mouseout",function(){x(r.$tip,"display","none")}),o(this.option.$control,"click",function(t){if(t.target!==r.$indicator){var e=r.getPosFromEvent(t),n=e.second,i=e.percentage;r.set("played",i),s.seek(n)}}),o(this.$indicator,"mousedown",function(){r.isDroging=!0}),o(document,"mousemove",function(t){if(r.isDroging){var e=r.getPosFromEvent(t),n=e.second,i=e.percentage;r.$indicator.classList.add("show-indicator"),r.set("played",i),s.seek(n)}}),o(document,"mouseup",function(){r.isDroging&&(r.isDroging=!1,r.$indicator.classList.remove("show-indicator"))})}},{key:"showHighlight",value:function(t){var e=this.art.refs.$video,n=t.target.dataset,i=n.text,r=n.time;this.$tip.innerHTML=i;var o=Number(r)/e.duration*this.option.$control.clientWidth+t.target.clientWidth/2-this.$tip.clientWidth/2;x(this.$tip,"left","".concat(o,"px"))}},{key:"showTime",value:function(t){var e=this.getPosFromEvent(t),n=e.width,i=e.time,r=this.$tip.clientWidth;this.$tip.innerHTML=i,n<=r/2?x(this.$tip,"left",0):n>this.option.$control.clientWidth-r/2?x(this.$tip,"left","".concat(this.option.$control.clientWidth-r,"px")):x(this.$tip,"left","".concat(n-r/2,"px"))}},{key:"getPlayed",value:function(){var t=this.art.refs.$video;return t.currentTime/t.duration}},{key:"getLoaded",value:function(){var t=this.art.refs.$video;return t.buffered.length?t.buffered.end(t.buffered.length-1)/t.duration:0}},{key:"getPosFromEvent",value:function(t){var e=this.art.refs,n=e.$video,i=e.$progress,r=i.getBoundingClientRect().left,o=$(t.x-r,0,i.clientWidth),a=o/i.clientWidth*n.duration;return{second:a,time:C(a),width:o,percentage:$(o/i.clientWidth,0,1)}}},{key:"set",value:function(t,e){x(this["$".concat(t)],"width","".concat(100*e,"%")),"played"===t&&x(this.$indicator,"left","calc(".concat(100*e,"% - 6.5px)"))}}]),e}(),Q=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){var e=this,n=this.option.$control,i=t.events.proxy,r=t.i18n,o=t.subtitle;this.$subtitle=k(n,U.subtitle),L(this.$subtitle,r.get("Hide subtitle")),i(n,"click",function(){o.isOpen?(o.hide(),x(e.$subtitle,"opacity","1"),L(e.$subtitle,r.get("Show subtitle"))):(o.show(),x(e.$subtitle,"opacity","0.8"),L(e.$subtitle,r.get("Hide subtitle")))})}}]),e}(),tt=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){this.art=t,this.init()}},{key:"init",value:function(){var t=this;this.option.$control.innerHTML="00:00 / 00:00",this.art.on("video:canplay",function(){t.option.$control.innerHTML=t.getTime()}),this.art.on("video:timeupdate",function(){t.option.$control.innerHTML=t.getTime()}),this.art.on("video:seeking",function(){t.option.$control.innerHTML=t.getTime()})}},{key:"getTime",value:function(){var t=this.art.player;return"".concat(C(t.currentTime())," / ").concat(C(t.duration()))}}]),e}(),et=function(){function e(t){s(this,e),this.option=t,this.isDroging=!1}return l(e,[{key:"apply",value:function(t){this.art=t,this.init()}},{key:"init",value:function(){var e=this,t=this.art,n=t.events.proxy,i=t.player,r=t.i18n;this.$volume=k(this.option.$control,U.volume),this.$volumeClose=k(this.option.$control,U.volumeClose),this.$volumePanel=k(this.option.$control,'<div class="art-volume-panel"></div>'),this.$volumeHandle=k(this.$volumePanel,'<div class="art-volume-slider-handle"></div>'),L(this.$volume,r.get("Mute")),x(this.$volumeClose,"display","none");var o=T("volume");this.setVolumeHandle(o),i.volume(o),n(this.$volume,"click",function(){x(e.$volume,"display","none"),x(e.$volumeClose,"display","block"),i.volume(0)}),n(this.$volumeClose,"click",function(){x(e.$volume,"display","block"),x(e.$volumeClose,"display","none"),i.volume(T("volume"))}),n(this.option.$control,"mouseenter",function(){e.$volumePanel.classList.add("art-volume-panel-hover"),setTimeout(function(){e.setVolumeHandle(i.volume())},200)}),n(this.option.$control,"mouseleave",function(){e.$volumePanel.classList.remove("art-volume-panel-hover")}),n(this.$volumePanel,"click",function(t){e.volumeChangeFromEvent(t)}),n(this.$volumeHandle,"mousedown",function(){e.isDroging=!0}),n(this.$volumeHandle,"mousemove",function(t){e.isDroging&&e.volumeChangeFromEvent(t)}),n(document,"mouseup",function(){e.isDroging&&(e.isDroging=!1)}),this.art.on("video:volumechange",function(){var t=i.volume();e.setVolumeHandle(t),0===t?(x(e.$volume,"display","none"),x(e.$volumeClose,"display","block")):(x(e.$volume,"display","block"),x(e.$volumeClose,"display","none"))})}},{key:"volumeChangeFromEvent",value:function(t){var e=this.art.player,n=this.$volumePanel.getBoundingClientRect(),i=n.left,r=n.width,o=this.$volumeHandle.getBoundingClientRect().width,a=$(t.x-i-o/2,0,r-o/2)/(r-o);e.volume(a)}},{key:"setVolumeHandle",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.7,e=this.$volumePanel.getBoundingClientRect().width,n=this.$volumeHandle.getBoundingClientRect().width,i=n/2+(e-n)*t-n/2;x(this.$volumeHandle,"left","".concat(i,"px"))}}]),e}(),nt=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){var e=this,n=this.option.$control,i=t.events.proxy,r=t.i18n,o=t.setting;this.$setting=k(n,U.setting),L(this.$setting,r.get("Show setting")),i(n,"click",function(){o.isOpen?(o.hide(),x(e.$setting,"opacity","1"),L(e.$setting,r.get("Show setting"))):(o.show(),x(e.$setting,"opacity","0.8"),L(e.$setting,r.get("Hide setting")))})}}]),e}(),it=function(){function e(t){s(this,e),this.option=t,this.loading=!1,this.isLoad=!1}return l(e,[{key:"apply",value:function(t){this.art=t,w(this.art.controls.progress,"'thumbnails' control dependent on 'progress' control"),this.init()}},{key:"init",value:function(){var e=this,t=this.art,n=t.refs.$progress,i=t.events.proxy;i(n,"mousemove",function(t){e.loading||(e.loading=!0,e.load(e.art.option.thumbnails.url).then(function(){e.isLoad=!0})),e.isLoad&&(x(e.option.$control,"display","block"),e.showThumbnails(t))}),i(n,"mouseout",function(){x(e.option.$control,"display","none")})}},{key:"load",value:function(i){var r=this.art.events.proxy;return new Promise(function(t,e){var n=new Image;if(n.src=i,n.complete)return t(n);r(n,"load",function(){return t(n)}),r(n,"error",function(){return e(n)})})}},{key:"showThumbnails",value:function(t){var e=this.art,n=e.refs.$progress,i=e.controls.progress.getPosFromEvent(t).width,r=this.art.option.thumbnails,o=r.url,a=r.height,s=r.width,c=r.number,l=r.column,u=n.clientWidth/c,h=Math.ceil(i/u),d=Math.ceil(h/l),f=h%l||l;x(this.option.$control,"backgroundImage","url(".concat(o,")")),x(this.option.$control,"height","".concat(a,"px")),x(this.option.$control,"width","".concat(s,"px")),x(this.option.$control,"backgroundPosition","-".concat(--f*s,"px -").concat(--d*a,"px")),i<=s/2?x(this.option.$control,"left",0):i>n.clientWidth-s/2?x(this.option.$control,"left","".concat(n.clientWidth-s,"px")):x(this.option.$control,"left","".concat(i-s/2,"px"))}}]),e}(),rt=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){var e=this;this.art=t;var n=this.art,i=n.events.proxy,r=n.i18n,o=n.notice;this.$screenshot=k(this.option.$control,U.screenshot),L(this.$screenshot,r.get("Screenshot")),i(this.$screenshot,"click",function(){try{e.captureFrame()}catch(t){o.show(t)}})}},{key:"captureFrame",value:function(){var t=this.art.refs.$video,e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0);var n=e.toDataURL("image/png"),i=document.createElement("a");x(i,"display","none"),i.href=n,i.download="ArtPlayer_".concat(C(t.currentTime),".png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}}]),e}(),ot=function(){function e(t){s(this,e),this.option=t,this.playIndex=-1}return l(e,[{key:"apply",value:function(t){var o=this,e=this.option.$control,a=t.option,n=t.events,i=n.proxy,r=n.hover,s=t.player,c=a.quality.find(function(t){return t.default})||a.quality[0];this.playIndex=a.quality.indexOf(c);var l=k(e,'<div class="art-quality-name">'.concat(c.name,"</div>")),u=a.quality.map(function(t,e){return'<div class="art-quality-item" data-index="'.concat(e,'">').concat(t.name,"</div>")}).join(""),h=k(e,'<div class="art-qualitys">'.concat(u,"</div>"));r(e,function(){e.classList.add("hover")},function(){e.classList.remove("hover")}),i(h,"click",function(t){var e=Number(t.target.dataset.index),n=a.quality[e],i=n.url,r=n.name;i&&r&&o.playIndex!==e&&(s.switch(i,r),l.innerHTML=r,o.playIndex=e)})}}]),e}(),at=0,st=function(){function n(t){var e=this;s(this,n),this.art=t,this.$map={},this.art.on("firstCanplay",function(){e.init(),e.mount()})}return l(n,[{key:"init",value:function(){var e=this;this.add(new K({name:"progress",disable:!1,position:"top",index:10})),this.add(new it({name:"thumbnails",disable:!this.art.option.thumbnails.url,position:"top",index:20})),this.add(new X({name:"playAndPause",disable:!1,position:"left",index:10})),this.add(new et({name:"volume",disable:!1,position:"left",index:20})),this.add(new tt({name:"time",disable:!1,position:"left",index:30})),this.add(new ot({name:"quality",disable:0===this.art.option.quality.length,position:"right",index:10})),this.add(new Y({name:"danmu",disable:!1,position:"right",index:20})),this.add(new rt({name:"screenshot",disable:!this.art.option.screenshot,position:"right",index:30})),this.add(new Q({name:"subtitle",disable:!this.art.option.subtitle.url,position:"right",index:40})),this.add(new nt({name:"setting",disable:!this.art.option.setting,position:"right",index:50})),this.add(new J({name:"pip",disable:!this.art.option.pip,position:"right",index:60})),this.add(new G({name:"fullscreenWeb",disable:!this.art.option.fullscreenWeb,position:"right",index:70})),this.add(new Z({name:"fullscreen",disable:!this.art.option.fullscreen,position:"right",index:80})),this.art.option.controls.forEach(function(t){e.add(t)})}},{key:"add",value:function(t){var e=t.option;if(e&&!e.disable){at++;var n=e.name||t.constructor.name.toLowerCase()||"control".concat(at),i=document.createElement("div");i.setAttribute("class","art-control art-control-".concat(n)),i.dataset.controlIndex=e.index||at,e.$control=i,this.commonMethod(t),(this.$map[e.position]||(this.$map[e.position]=[])).push(i),t.apply&&t.apply(this.art),this[n]=t}}},{key:"mount",value:function(){var t=this,e=this.art.refs,n=e.$progress,i=e.$controlsLeft,r=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":k(n,t);break;case"left":k(i,t);break;case"right":k(r,t)}})})}},{key:"commonMethod",value:function(t){var e=this;Object.defineProperty(t,"hide",{value:function(){x(t.option.$control,"display","none"),e.art.emit("control:hide",t.option.$control)}}),Object.defineProperty(t,"show",{value:function(){x(t.option.$control,"display","block"),e.art.emit("control:show",t.option.$control)}})}},{key:"show",value:function(){this.art.refs.$player.classList.add("artplayer-controls-show")}},{key:"hide",value:function(){this.art.refs.$player.classList.remove("artplayer-controls-show")}}]),n}();function ct(t){var e=t.option,n=t.i18n,i=t.player,r=t.contextmenu;return{disable:!e.playbackRate,name:"playbackRate",index:10,html:"\n ".concat(n.get("Play speed"),':\n <span data-rate="0.5">0.5</span>\n <span data-rate="0.75">0.75</span>\n <span data-rate="1" class="normal current">').concat(n.get("Normal"),'</span>\n <span data-rate="1.25">1.25</span>\n <span data-rate="1.5">1.5</span>\n <span data-rate="2.0">2.0</span>\n '),click:function(t){var e=t.target,n=e.dataset.rate;n&&(i.playbackRate(Number(n)),M(e).forEach(function(t){return t.classList.remove("current")}),e.classList.add("current"),r.hide())}}}function lt(t){var e=t.option,n=t.i18n,i=t.player,r=t.contextmenu;return{disable:!e.aspectRatio,name:"aspectRatio",index:20,html:"\n ".concat(n.get("Aspect ratio"),':\n <span data-ratio="default" class="default current">').concat(n.get("Default"),'</span>\n <span data-ratio="4:3">4:3</span>\n <span data-ratio="16:9">16:9</span>\n '),click:function(t){var e=t.target,n=e.dataset.ratio;n&&(i.aspectRatio(n.split(":")),M(e).forEach(function(t){return t.classList.remove("current")}),e.classList.add("current"),r.hide())}}}function ut(t){return{disable:!1,name:"info",index:30,html:t.i18n.get("Video info"),click:function(){t.info.show(),t.contextmenu.hide()}}}var ht={disable:!1,name:"version",index:40,html:'<a href="https://github.com/zhw2590582/artplayer" target="_blank">ArtPlayer 1.0.0</a>'};function dt(t){return{disable:!1,name:"close",index:50,html:t.i18n.get("Close"),click:function(){t.contextmenu.hide()}}}var ft=0,pt=function(){function e(t){s(this,e),this.art=t,this.init()}return l(e,[{key:"init",value:function(){var e=this,t=this.art,n=t.option,i=t.refs,r=t.events.proxy;n.contextmenu.push(ct,lt,ut,ht,dt),r(i.$player,"contextmenu",function(t){t.preventDefault(),e.art.isFocus=!0,i.$contextmenu||e.creatMenu(),e.show(),e.setPos(t)}),r(i.$player,"click",function(t){i.$contextmenu&&!t.path.includes(i.$contextmenu)&&e.hide()})}},{key:"creatMenu",value:function(){var i=this,t=this.art,e=t.option,n=t.refs,r=t.events.proxy;n.$contextmenu=document.createElement("div"),n.$contextmenu.classList.add("artplayer-contextmenu"),e.contextmenu.filter(function(t){return!t.disable}).map(function(t){ft++;var e="function"==typeof t?t(i.art):t,n=document.createElement("div");return n.dataset.artMenuId=e.index||ft,n.setAttribute("class","art-menu art-menu-".concat(e.name||ft)),k(n,e.html),S(n,e.style||{}),e.click&&r(n,"click",function(t){t.preventDefault(),e.click.call(i,t),i.art.emit("contextmenu:click",n)}),i["$".concat(e.name||ft)]=n}).sort(function(t,e){return Number(t.dataset.artMenuId)-Number(e.dataset.artMenuId)}).forEach(function(t){k(n.$contextmenu,t)}),k(n.$player,n.$contextmenu)}},{key:"setPos",value:function(t){var e=this.art.refs,n=t.clientX,i=t.clientY,r=e.$player.getBoundingClientRect(),o=r.height,a=r.width,s=r.left,c=r.top,l=e.$contextmenu.getBoundingClientRect(),u=l.height,h=l.width,d=n-s,f=i-c;s+a<n+h&&(d=a-h),c+o<i+u&&(f=o-u),x(e.$contextmenu,"left","".concat(d,"px")),x(e.$contextmenu,"top","".concat(f,"px"))}},{key:"hide",value:function(){var t=this.art.refs.$contextmenu;t&&(x(t,"display","none"),this.art.emit("contextmenu:hide",t))}},{key:"show",value:function(){var t=this.art.refs.$contextmenu;t&&(x(t,"display","block"),this.art.emit("contextmenu:show",t))}}]),e}(),vt=function(){function e(t){s(this,e),this.art=t,this.isOpen=!0,this.init()}return l(e,[{key:"init",value:function(){}},{key:"show",value:function(){var t=this.art,e=t.refs.$danmu,n=t.i18n,i=t.notice;x(e,"display","block"),this.isOpen=!0,i.show(n.get("Show danmu")),this.art.emit("danmu:show",e)}},{key:"hide",value:function(){var t=this.art,e=t.refs.$danmu,n=t.i18n,i=t.notice;x(e,"display","none"),this.isOpen=!1,i.show(n.get("Hide danmu")),this.art.emit("danmu:hide",e)}}]),e}(),yt=function(){function e(t){s(this,e),this.art=t,this.init()}return l(e,[{key:"init",value:function(){var t=this,e=this.art,n=e.refs,i=n.$infoClose,r=n.$infoPanel;(0,e.events.proxy)(i,"click",function(){t.hide()}),this.art.on("switch",function(){r.innerHTML&&t.getHeader()})}},{key:"show",value:function(){var t=this.art.refs,e=t.$info,n=t.$infoPanel;x(e,"display","block"),n.innerHTML||(k(n,this.creatInfo()),this.getHeader()),clearTimeout(this.timer),this.loop(),this.art.emit("info:show",e)}},{key:"creatInfo",value:function(){var t=[];return t.push('\n <div class="art-info-item ">\n <div class="art-info-title">Player version:</div>\n <div class="art-info-content">1.0.0</div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video url:</div>\n <div class="art-info-content" data-video="currentSrc"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video type:</div>\n <div class="art-info-content" data-head="Content-Type"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video size:</div>\n <div class="art-info-content" data-head="Content-length"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video volume:</div>\n <div class="art-info-content" data-video="volume"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video time:</div>\n <div class="art-info-content" data-video="currentTime"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video duration:</div>\n <div class="art-info-content" data-video="duration"></div>\n </div>\n '),t.push('\n <div class="art-info-item">\n <div class="art-info-title">Video resolution:</div>\n <div class="art-info-content">\n <span data-video="videoWidth"></span> x <span data-video="videoHeight"></span>\n </div>\n </div>\n '),t.join("")}},{key:"getHeader",value:function(){var t=this.art.refs,e=t.$infoPanel,n=t.$video.src,i=Array.from(e.querySelectorAll("[data-head]"));i.forEach(function(t){t.innerHTML="loading..."}),fetch(n,{method:"HEAD"}).then(function(n){i.forEach(function(t){var e=n.headers.get(t.dataset.head);t.innerHTML=void 0!==e?e:"unknown"})}).catch(function(){i.forEach(function(t){t.innerHTML="unknown"})})}},{key:"readInfo",value:function(){var t=this.art.refs,e=t.$infoPanel,n=t.$video;Array.from(e.querySelectorAll("[data-video]")).forEach(function(t){var e=n[t.dataset.video];t.innerHTML=void 0!==e?e:"unknown"})}},{key:"loop",value:function(){var t=this;this.readInfo(),this.timer=setTimeout(function(){t.readInfo(),t.loop()},1e3)}},{key:"hide",value:function(){var t=this.art.refs.$info;x(t,"display","none"),clearTimeout(this.timer),this.art.emit("info:hide",t)}}]),e}(),mt=function(){function n(t){s(this,n),this.art=t,this.isOpen=!0;var e=this.art.option.subtitle.url;e&&(this.checkExt(e),this.init())}return l(n,[{key:"init",value:function(){var i=this,t=this.art,e=t.events.proxy,n=t.option.subtitle,r=t.refs,o=r.$video,a=r.$subtitle;S(a,n.style||{});var s=document.createElement("track");s.default=!0,s.kind="metadata",this.load(n.url).then(function(t){if(s.src=t,o.appendChild(s),i.art.refs.$track=s,o.textTracks&&o.textTracks[0]){var n=z(o.textTracks,1)[0];e(n,"cuechange",function(){var t=z(n.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("")}i.art.emit("subtitle:update",a)})}})}},{key:"load",value:function(e){var n,i=this;return fetch(e).then(function(t){return n=t.headers.get("Content-Type"),t.text()}).then(function(t){return/x-subrip/gi.test(n)?i.srtToVtt(t):e}).catch(function(t){throw t})}},{key:"srtToVtt",value:function(t){var e="WEBVTT \r\n\r\n".concat(t.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([e],{type:"text/vtt"}))}},{key:"checkExt",value:function(t){var e=function t(e){return e.includes("?")?t(e.split("?")[0]):e.includes("#")?t(e.split("#")[0]):e.trim().toLowerCase().split(".").pop()}(t);w("vtt"===e||"srt"===e,"'subtitle.url' option require 'vtt' or 'srt' format, but got '".concat(e,"'."))}},{key:"show",value:function(){var t=this.art,e=t.refs.$subtitle,n=t.i18n,i=t.notice;x(e,"display","block"),this.isOpen=!0,i.show(n.get("Show subtitle")),this.art.emit("subtitle:show",e)}},{key:"hide",value:function(){var t=this.art,e=t.refs.$subtitle,n=t.i18n,i=t.notice;x(e,"display","none"),this.isOpen=!1,i.show(n.get("Hide subtitle")),this.art.emit("subtitle:hide",e)}},{key:"switch",value:function(e){var n=this,i=this.art.refs.$track;this.checkExt(e),w(i,"You need to initialize the subtitle option first."),this.load(e).then(function(t){e!==t&&(i.src=t,n.art.emit("subtitle:switch",e))})}}]),n}(),gt=function(){function e(t){s(this,e),this.art=t,this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this)}return l(e,[{key:"proxy",value:function(e,t,n){var i=this,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};Array.isArray(t)&&t.forEach(function(t){return i.proxy(e,t,n,r)}),e.addEventListener(t,n,r),this.destroyEvents.push(function(){e.removeEventListener(t,n,r)})}},{key:"hover",value:function(t,e,n){this.proxy(t,"mouseenter",e),this.proxy(t,"mouseleave",n)}},{key:"destroy",value:function(){this.destroyEvents.forEach(function(t){return t()})}}]),e}(),bt=function(){function e(t){s(this,e),this.art=t,this.art.option.hotkey&&this.init()}return l(e,[{key:"init",value:function(){var i=this,t=this.art,r=t.player,e=t.refs.$player,n=t.events.proxy;n(document,"click",function(t){i.art.isFocus=-1<t.path.indexOf(e)}),n(window,"keydown",function(t){if(i.art.isFocus){var e=document.activeElement.tagName.toUpperCase(),n=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==n&&"true"!==n)switch(t.keyCode){case 39:t.preventDefault(),r.seek(r.currentTime()+10);break;case 37:t.preventDefault(),r.seek(r.currentTime()-10);break;case 38:t.preventDefault(),r.volume(r.volume()+.05);break;case 40:t.preventDefault(),r.volume(r.volume()-.05);break;case 32:t.preventDefault(),r.toggle()}}})}}]),e}(),wt=0,$t=function(){function e(t){s(this,e),this.art=t,this.add=this.add.bind(this),this.art.option.layers.filter(function(t){return!1===t.disable}).forEach(this.add),this.init()}return l(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;wt++;var i=document.createElement("div");i.setAttribute("data-art-layer-id",wt),i.setAttribute("class","art-layer art-layer-".concat(t.name||wt)),x(i,"z-index",t.index||wt),k(i,t.html),S(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;x(t,"display","block"),this.art.emit("layers:show",t)}},{key:"hide",value:function(){var t=this.art.refs.$layers;x(t,"display","none"),this.art.emit("layers:hide",t)}}]),e}(),kt=function(){function e(t){s(this,e),this.art=t,this.init()}return l(e,[{key:"init",value:function(){var t=this.art,e=t.option;k(t.refs.$loading,e.loading||U.loading)}},{key:"hide",value:function(){var t=this.art.refs.$loading;x(t,"display","none"),this.art.emit("loading:hide",t)}},{key:"show",value:function(){var t=this.art.refs.$loading;x(t,"display","flex"),this.art.emit("loading:show",t)}}]),e}(),xt=function(){function e(t){s(this,e),this.art=t,this.timer=null}return l(e,[{key:"show",value:function(t){var e=this,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1e3,r=this.art.refs,o=r.$notice,a=r.$noticeInner;x(o,"display","block"),a.innerHTML=t instanceof Error?t.message.trim():t,n&&(clearTimeout(this.timer),this.timer=setTimeout(function(){e.hide()},i)),this.art.emit("notice:show",o)}},{key:"hide",value:function(){var t=this.art.refs.$notice;x(t,"display","none"),this.art.emit("notice:hide",t)}}]),e}(),St=function(){function e(t){s(this,e),this.art=t,this.init()}return l(e,[{key:"init",value:function(){var t=this,e=this.art,n=e.player,i=e.refs,r=e.events.proxy;k(i.$mask,U.playBig),r(i.$mask,"click",function(){n.play(),t.hide()})}},{key:"show",value:function(){var t=this.art.refs.$mask;x(t,"display","block"),this.art.emit("mask:show",t)}},{key:"hide",value:function(){var t=this.art.refs.$mask;x(t,"display","none"),this.art.emit("mask:show",t)}}]),e}(),Ct=function(){function e(t){s(this,e),this.option=t}return l(e,[{key:"apply",value:function(t){this.art=t;var e=this.option.$setting;this.$header=e.querySelector(".art-setting-header"),this.$body=e.querySelector(".art-setting-body"),k(this.$body,"———— 先占坑,暂无设置 ————")}}]),e}(),Tt=0,Lt=function(){function e(t){s(this,e),this.art=t,this.isOpen=!1,this.$settings=[],t.option.setting&&(this.init(),this.mount())}return l(e,[{key:"init",value:function(){var t=this,e=this.art,n=e.refs.$settingClose;(0,e.events.proxy)(n,"click",function(){t.hide()}),this.add(new Ct({name:"common",title:"Common",disable:!1,index:10}))}},{key:"add",value:function(t){var e=t.option;if(e&&!e.disable){Tt++;var n=e.name||t.constructor.name.toLowerCase()||"setting".concat(Tt),i=e.title||n,r=document.createElement("div");r.setAttribute("class","art-setting art-setting-".concat(n)),r.dataset.settingIndex=e.index||Tt,k(r,'<div class="art-setting-header">'.concat(this.art.i18n.get(i),"</div>")),k(r,'<div class="art-setting-body"></div>'),e.$setting=r,this.$settings.push(r),t.apply&&t.apply(this.art),this[n]=t}}},{key:"mount",value:function(){var e=this;this.$settings.sort(function(t,e){return Number(t.dataset.settingIndex)-Number(e.dataset.settingIndex)}).forEach(function(t){k(e.art.refs.$settingBody,t)})}},{key:"show",value:function(){var t=this.art,e=t.refs.$setting,n=t.i18n,i=t.notice;x(e,"display","flex"),this.isOpen=!0,i.show(n.get("Show setting")),this.art.emit("setting:show",e)}},{key:"hide",value:function(){var t=this.art,e=t.refs.$setting,n=t.i18n,i=t.notice;x(e,"display","none"),this.isOpen=!1,i.show(n.get("Hide setting")),this.art.emit("setting:hide",e)}}]),e}(),Et=0,Mt=[],At=function(t){function n(t){var e;return s(this,n),(e=f(this,p(n).call(this))).emit("init:start"),e.option=function t(){for(var e=function(t){return null!==t&&"object"===h(t)},n={},i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];for(var a=0;a<r.length;a++){var s=r[a];if(Array.isArray(s))Array.isArray(n)||(n=[]),n=u(n).concat(u(s));else if(e(s)){if(s instanceof Element)return s;for(var c in s)if(s.hasOwnProperty(c)){var l=s[c];e(l)&&c in n&&(l=t(n[c],l)),n=m({},n,y({},c,l))}}}return n}({},n.DEFAULTS,t),A(e.option,H),e.init(),e.emit("init:end"),e}return v(n,R),l(n,[{key:"init",value:function(){return this.isError=!1,this.isFocus=!1,this.isPlaying=!1,this.refs={},this.option.container instanceof Element?this.refs.$container=this.option.container:this.refs.$container=document.querySelector(this.option.container),this.template=new q(this),this.i18n=new I(this),this.notice=new xt(this),this.events=new gt(this),this.player=new V(this),this.layers=new $t(this),this.controls=new st(this),this.contextmenu=new pt(this),this.danmu=new vt(this),this.subtitle=new mt(this),this.info=new yt(this),this.loading=new kt(this),this.hotkey=new bt(this),this.mask=new St(this),this.setting=new Lt(this),this.id=Et++,Mt.push(this),this}},{key:"destroy",value:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this.events.destroy(),Mt.splice(Mt.indexOf(this),1),t?this.refs.$container.innerHTML="":this.refs.$player.classList.add("artplayer-destroy"),this.emit("destroy")}}],[{key:"use",value:function(t){var e=t.name.toLowerCase(),n=this.plugins||(this.plugins={});if(!n[e]){var i=Array.from(arguments).slice(1);i.unshift(this),n[e]=r(t,u(i)),this.prototype.emit("use",t)}return this}},{key:"version",get:function(){return"1.0.0"}},{key:"config",get:function(){return O}},{key:"DEFAULTS",get:function(){return{container:".artplayer",url:"",poster:"",volume:.7,thumbnails:{url:"",number:60,width:160,height:90,column:10},screenshot:!0,autoplay:!1,playbackRate:!0,aspectRatio:!0,loop:!1,type:"",mimeCodec:"",layers:[],contextmenu:[],quality:[],loading:"",theme:"#f00",setting:!1,hotkey:!0,pip:!0,fullscreen:!0,fullscreenWeb:!0,subtitle:{url:"",style:{}},controls:[],highlight:[],moreVideoAttr:{crossOrigin:"anonymous",controls:!1,preload:"auto","webkit-playsinline":!0,playsinline:!0},lang:navigator.language.toLowerCase()}}}]),n}();window.Artplayer=At,t.instances=Mt,t.default=At,Object.defineProperty(t,"__esModule",{value:!0})});