From be4d1d04374b7d30fbefc18fe144979c55b1c08c Mon Sep 17 00:00:00 2001 From: zhw2590582 Date: Fri, 22 Nov 2019 20:27:10 +0800 Subject: [PATCH] add removeHtmlSpace --- .size-snapshot.json | 6 +++--- dist/artplayer.js | 2 +- packages/artplayer/dist/artplayer.js | 2 +- packages/artplayer/src/utils/property.js | 8 +++++--- scripts/creatRollupConfig.js | 2 ++ scripts/removeHtmlSpace.js | 8 ++++++++ test/document.test.js | 20 ++++++++++---------- 7 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 scripts/removeHtmlSpace.js diff --git a/.size-snapshot.json b/.size-snapshot.json index acfdb13e7..144184f95 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,8 +1,8 @@ { "packages/artplayer/dist/artplayer.js": { - "bundled": 164584, - "minified": 88339, - "gzipped": 21861 + "bundled": 163884, + "minified": 87218, + "gzipped": 21867 }, "packages/artplayer-plugin-backlight/dist/artplayer-plugin-backlight.js": { "bundled": 4642, diff --git a/dist/artplayer.js b/dist/artplayer.js index 714c4d3da..cc4b5a243 100644 --- a/dist/artplayer.js +++ b/dist/artplayer.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,(function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function e(t,e){for(var n=0;n1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:document).querySelector(t)}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(e.querySelectorAll(t))}function h(t,e){return t.classList.add(e)}function y(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function m(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function g(t,e,n){return t.style[e]=n,t}function b(t,e){return Object.keys(e).forEach((function(n){g(t,n,e[n])})),t}function w(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=window.getComputedStyle(t,null).getPropertyValue(e);return n?parseFloat(r):r}function O(t){return Array.from(t.parentElement.children).filter((function(e){return e!==t}))}function j(t,e){O(t).forEach((function(t){return y(t,e)})),h(t,e)}function P(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"up";t.setAttribute("aria-label",e),t.setAttribute("data-balloon-pos",n)}var x=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},k=r((function(t){function e(n,r,i){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}}()?t.exports=e=function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&s(i,n.prototype),i}:t.exports=e=Reflect.construct,e.apply(null,arguments)}t.exports=e})),E=function(e){function n(e,r){var i;return t(this,n),i=a(this,c(n).call(this,e)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),r||i.constructor),i.name="ArtPlayerError",i}return u(n,e),n}(r((function(t){function e(n){var r="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!x(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return k(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},e(n)}t.exports=e}))(Error));function S(t,e){if(!t)throw new E(e);return t}function $(t){return"WEBVTT \r\n\r\n".concat(t.replace(/{[\s\S]*?}/g,"").replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"))}function R(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function T(t){var e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(/[:.]/).map((function(t,e,n){if(e===n.length-1){if(1===t.length)return".".concat(t,"00");if(2===t.length)return".".concat(t,"0")}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===n.length-1?".".concat(t):":".concat(t)})).join("")}return"WEBVTT\n\n".concat(t.split(/\r?\n/).map((function(t){var r=t.match(e);return r?{start:n(r[1].trim()),end:n(r[2].trim()),text:r[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map((function(t){return t.trim()})).join("\n")}:null})).filter((function(t){return t})).map((function(t,e){return t?"".concat(e+1,"\n").concat(t.start," --\x3e ").concat(t.end,"\n").concat(t.text):""})).filter((function(t){return t.trim()})).join("\n\n"))}function D(t){return t.includes("?")?D(t.split("?")[0]):t.includes("#")?D(t.split("#")[0]):t.trim().toLowerCase().split(".").pop()}function C(t,e){var n=document.createElement("a");n.style.display="none",n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}var L=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e){return setTimeout(e,t)}))}function B(t,e,n){var r;function i(){for(var i=arguments.length,o=new Array(i),a=0;a0?[e,n,r]:[n,r]).map((function(t){return t<10?"0".concat(t):String(t)})).join(":")}var _=Object.freeze({__proto__:null,query:p,queryAll:d,addClass:h,removeClass:y,hasClass:v,append:m,remove:function(t){return t.parentNode.removeChild(t)},setStyle:g,setStyles:b,getStyle:w,sublings:O,inverseClass:j,tooltip:P,ArtPlayerError:E,errorHandle:S,srtToVtt:$,vttToBlob:R,assToVtt:T,getExt:D,downloadFile:C,hasOwnProperty:q,defineProperty:W,proxyPropertys:V,mergeDeep:F,sleep:H,debounce:B,throttle:I,clamp:N,secondToTime:U});function X(t,e,n){return S("string"===e||t instanceof Element,"".concat(n.join(".")," require 'string' or 'Element' type"))}var Y={container:X,url:"string|function",poster:"string",title:"string",theme:"string",lang:"string",volume:"number",isLive:"boolean",muted:"boolean",autoplay:"boolean",autoSize:"boolean",loop:"boolean",flip:"boolean",playbackRate:"boolean",aspectRatio:"boolean",screenshot:"boolean",setting:"boolean",hotkey:"boolean",pip:"boolean",mutex:"boolean",fullscreen:"boolean",fullscreenWeb:"boolean",subtitleOffset:"boolean",miniProgressBar:"boolean",localVideo:"boolean",localSubtitle:"boolean",autoPip:"boolean",networkMonitor:"boolean",plugins:["function"],whitelist:["string|function|regexp"],layers:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],contextmenu:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],quality:[{default:"boolean|undefined",name:"string",url:"string"}],controls:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined",position:function(t,e,n){var r=["top","left","right"];return S(r.includes(t),"".concat(n.join(".")," only accept ").concat(r.toString()," as parameters"))}}],highlight:[{time:"number",text:"string"}],thumbnails:{url:"string",number:"number",width:"number",height:"number",column:"number"},subtitle:{url:"string",style:"object"},moreVideoAttr:"object",icons:"object",customType:"object"},Z={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"]}},J=function e(n){var r=this;t(this,e);var i=n.constructor.kindOf,o=n.option.whitelist;this.userAgent=window.navigator.userAgent,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.userAgent),this.state=!this.isMobile||o.some((function(t){switch(i(t)){case"string":return r.userAgent.indexOf(t)>-1;case"function":return t(r.userAgent);case"regexp":return t.test(r.userAgent);default:return!1}}))},G=function(){function e(n){var r=this;t(this,e),this.art=n,n.option.container instanceof Element?this.$container=n.option.container:(this.$container=p(n.option.container),S(this.$container,"No container element found by ".concat(n.option.container))),S(n.constructor.instances.every((function(t){return t.template.$container!==r.$container})),"Cannot mount multiple instances on the same dom element"),S(this.$container.clientWidth&&this.$container.clientHeight,"The width and height of the container cannot be 0"),n.whitelist.state?this.initDesktop():this.initMobile()}return n(e,[{key:"query",value:function(t){return p(t,this.$container)}},{key:"initDesktop",value:function(){this.$container.innerHTML='\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
Player version:
\n
3.1.19
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n
×
\n
\n
\n
\n '),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query(".art-video track"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$settingInner=this.query(".art-setting-inner"),this.$settingBody=this.query(".art-setting-body"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$pipHeader=this.query(".art-pip-header"),this.$pipTitle=this.query(".art-pip-title"),this.$pipClose=this.query(".art-pip-close"),this.$contextmenu=this.query(".art-contextmenus")}},{key:"initMobile",value:function(){this.$container.innerHTML='\n
\n \n
\n ',this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video")}},{key:"destroy",value:function(t){t?this.$container.innerHTML="":h(this.$player,"art-destroy")}}]),e}(),Q={"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Flip:"视频翻转",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕","Show setting":"显示设置","Hide setting":"隐藏设置",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常",Open:"打开","Switch video":"切换","Switch subtitle":"切换字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"网页全屏","Exit web fullscreen":"退出网页全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地视频","Subtitle offset time":"字幕偏移时间","No subtitles found":"未发现字幕"},K={"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Flip:"影片翻轉",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕","Show setting":"顯示设置","Hide setting":"隱藏设置",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常",Open:"打開","Switch video":"切換","Switch subtitle":"切換字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"網頁全屏","Exit web fullscreen":"退出網頁全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地視頻","Subtitle offset time":"字幕偏移時間","No subtitles found":"未發現字幕"},tt=function(){function e(n){t(this,e),this.art=n,this.languages={"zh-cn":Q,"zh-tw":K},this.init()}return n(e,[{key:"init",value:function(){var t=this.art.option.lang.toLowerCase();this.language=this.languages[t]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){this.languages=F(this.languages,t),this.init()}}]),e}();var et=r((function(t){!function(){var e="undefined"!=typeof window&&void 0!==window.document?window.document:{},n=t.exports,r=function(){for(var t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,o={};rh){var y=h*l/u;g(r,"width","".concat(100*y,"%")),g(r,"height","100%"),g(r,"padding","0 ".concat((f-f*y)/2,"px"))}else{var v=u/h/l;g(r,"width","100%"),g(r,"height","".concat(100*v,"%")),g(r,"padding","".concat((p-p*v)/2,"px 0"))}}i.dataset.aspectRatio=n,a.show("".concat(o.get("Aspect ratio"),": ").concat("default"===n?o.get("Default"):n)),t.emit("aspectRatioChange",n)}else e.aspectRatio&&(g(r,"width",null),g(r,"height",null),g(r,"padding",null),delete i.dataset.aspectRatio,t.emit("aspectRatioRemove"))}}),Object.defineProperty(e,"aspectRatioReset",{set:function(n){if(n&&e.aspectRatio){var r=e.aspectRatio;e.aspectRatio=r,t.emit("aspectRatioReset")}}})}(n,this),function(t,e){var n=t.option,r=t.notice,i=t.template.$video;Object.defineProperty(e,"getScreenshotDataURL",{value:function(){try{var t=document.createElement("canvas");return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),t.toDataURL("image/png")}catch(t){throw r.show(t),t}}}),Object.defineProperty(e,"getScreenshotBlobUrl",{value:function(){return new Promise((function(t,e){try{var n=document.createElement("canvas");n.width=i.videoWidth,n.height=i.videoHeight,n.getContext("2d").drawImage(i,0,0),n.toBlob((function(e){t(URL.createObjectURL(e))}))}catch(t){r.show(t),e(t)}}))}}),Object.defineProperty(e,"screenshot",{value:function(){var r=e.getScreenshotDataURL();r&&(C(r,"".concat(n.title||"artplayer","_").concat(U(i.currentTime),".png")),t.emit("screenshot",r))}})}(n,this),function(t,e){var n=t.i18n,r=t.notice,i=t.events.destroyEvents,o=t.template.$player,a=function(){t.emit("fullscreenChange",et.isFullscreen)},c=function(){r.show(n.get("Does not support fullscreen"))};e.fullscreenIsEnabled&&(et.on("change",a),et.on("error",c),i.push((function(){et.off("change",a),et.off("error",c)}))),Object.defineProperty(e,"fullscreen",{get:function(){return et.isFullscreen},set:function(n){e.fullscreenIsEnabled?n?(e.fullscreenWeb&&(e.fullscreenWeb=!1),et.request(o).then((function(){h(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenEnabled")}))):(e.fullscreenWeb&&(e.fullscreenWeb=!1),et.exit().then((function(){y(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenExit")}))):c()}}),Object.defineProperty(e,"fullscreenToggle",{set:function(t){t&&(e.fullscreen=!e.fullscreen)}}),Object.defineProperty(e,"fullscreenIsEnabled",{get:function(){return et.isEnabled}})}(n,this),function(t,e){var n=t.template.$player;Object.defineProperty(e,"fullscreenWeb",{get:function(){return v(n,"art-web-fullscreen")},set:function(r){r?(e.fullscreen&&(e.fullscreen=!1),h(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebEnabled")):(e.fullscreen&&(e.fullscreen=!1),y(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebExit"))}}),Object.defineProperty(e,"fullscreenWebToggle",{set:function(t){t&&(e.fullscreenWeb=!e.fullscreenWeb)}})}(n,this),nt(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"loaded",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1)/n.duration:0}}),Object.defineProperty(e,"loadedTime",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1):0}})}(n,this),function(t,e){Object.defineProperty(e,"played",{get:function(){return t.template.$video.currentTime/t.template.$video.duration}})}(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"playing",{get:function(){return!!(n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2)}})}(n,this),function(t,e){var n=t.template,r=n.$container,i=n.$player,o=n.$video;Object.defineProperty(e,"autoSize",{get:function(){return v(r,"art-auto-size")},set:function(n){if(n){var a=o.videoWidth,c=o.videoHeight,s=r.getBoundingClientRect(),u=s.width,l=s.height,f=a/c,p=u/l;if(h(r,"art-auto-size"),p>f){g(i,"width","".concat(l*f/u*100,"%")),g(i,"height","100%")}else{var d=u/f/l*100;g(i,"width","100%"),g(i,"height","".concat(d,"%"))}t.emit("autoSizeChange",{width:e.width,height:e.height})}else y(r,"art-auto-size"),g(i,"width",null),g(i,"height",null),t.emit("autoSizeRemove")}})}(n,this),function(t,e){Object.defineProperty(e,"rect",{get:function(){return t.template.$player.getBoundingClientRect()}}),["bottom","height","left","right","top","width"].forEach((function(t){Object.defineProperty(e,t,{get:function(){return e.rect[t]}})})),Object.defineProperty(e,"x",{get:function(){return e.left+window.pageXOffset}}),Object.defineProperty(e,"y",{get:function(){return e.top+window.pageYOffset}})}(n,this),function(t,e){Object.defineProperty(e,"flip",{get:function(){return t.template.$player.dataset.flip},set:function(e){if(e){var n=["normal","horizontal","vertical"];S(n.includes(e),"'flip' only accept ".concat(n.toString()," as parameters")),t.template.$player.dataset.flip=e,t.emit("flipChange",e)}else delete t.template.$player.dataset.flip,t.emit("flipRemove")}})}(n,this),V(n,this)};var it=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t},ot=r((function(t){function e(n,r,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,n){var r=it(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}},e(n,r,i||n)}t.exports=e})),at=function(){function e(n){t(this,e),this.id=0,this.art=n,this.add=this.add.bind(this),this.name=this.constructor.name.toLowerCase()}return n(e,[{key:"toggle",value:function(){this.show=!this.show}},{key:"add",value:function(t,e){var n=this,r="function"==typeof t?t(this.art):t;if(!this.$parent||r.disable)return{};this.id+=1;var i=r.name||"".concat(this.name).concat(this.id);S(!q(this,i),"Cannot add a component that already has the same name: ".concat(i));var o=document.createElement("div");o.classList.value="art-".concat(this.name," art-").concat(this.name,"-").concat(i),r.html&&m(o,r.html),r.style&&b(o,r.style),r.tooltip&&P(o,r.tooltip);var a=Array.from(this.$parent.children);o.dataset.index=r.index||this.id;var c=a.find((function(t){return Number(t.dataset.index)>=Number(o.dataset.index)}));return c?c.insertAdjacentElement("beforebegin",o):m(this.$parent,o),r.click&&this.art.events.proxy(o,"click",(function(t){t.preventDefault(),r.click.call(n.art,n,t)})),r.mounted&&r.mounted(o,this,this.art),e&&e(o,this,this.art),W(this,i,{value:{get $ref(){return o},set show(t){g(o,"display",t?"block":"none")}}}),this.art.emit("".concat(this.name,":add"),r),this[i]}},{key:"show",get:function(){return v(this.art.template.$player,"art-".concat(this.name,"-show"))},set:function(t){S(!1===t||!0===t,"The show attribute expects a boolean value");var e=this.art.template.$player,n="art-".concat(this.name,"-show");t?h(e,n):y(e,n),this.art.emit("".concat(this.name,":toggle"),t)}}]),e}();var ct=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};function st(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ut(t){return function(e){return function(t){for(var e=1;e\n
\n
\n
\n
\n
\n\n '),mounted:function(t){var n=!1,i=p(".art-progress-loaded",t),c=p(".art-progress-played",t),s=p(".art-progress-highlight",t),u=p(".art-progress-indicator",t),l=p(".art-progress-tip",t);function f(t,e){"loaded"===t&&g(i,"width","".concat(100*e,"%")),"played"===t&&(g(c,"width","".concat(100*e,"%")),g(u,"left","calc(".concat(100*e,"% - ").concat(w(u,"width")/2,"px)")))}r.forEach((function(t){var e=N(t.time,0,a.duration)/a.duration*100;m(s,''))})),f("loaded",a.loaded),e.on("video:progress",(function(){f("loaded",a.loaded)})),e.on("video:timeupdate",(function(){f("played",a.played)})),e.on("video:ended",(function(){f("played",1)})),o(t,"mousemove",(function(n){g(l,"display","block"),n.composedPath().indexOf(s)>-1?function(n){var r=mt(e,n).width,i=n.target.dataset.text;l.innerHTML=i;var o=l.clientWidth;r<=o/2?g(l,"left",0):r>t.clientWidth-o/2?g(l,"left","".concat(t.clientWidth-o,"px")):g(l,"left","".concat(r-o/2,"px"))}(n):function(n){var r=mt(e,n),i=r.width,o=r.time;l.innerHTML=o;var a=l.clientWidth;i<=a/2?g(l,"left",0):i>t.clientWidth-a/2?g(l,"left","".concat(t.clientWidth-a,"px")):g(l,"left","".concat(i-a/2,"px"))}(n)})),o(t,"mouseout",(function(){g(l,"display","none")})),o(t,"click",(function(t){if(t.target!==u){var n=mt(e,t),r=n.second;f("played",n.percentage),a.seek=r}})),o(u,"mousedown",(function(){n=!0})),o(document,"mousemove",(function(t){if(n){var r=mt(e,t),i=r.second,o=r.percentage;h(u,"art-show-indicator"),f("played",o),a.seek=i}})),o(document,"mouseup",(function(){n&&(n=!1,y(u,"art-show-indicator"))}))}})}}function bt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function wt(t){return function(e){return function(t){for(var e=1;e'),l=m(u,'
');function f(t){var e=u.getBoundingClientRect(),n=e.left,r=e.width,i=l.getBoundingClientRect().width;return N(t.pageX-n-i/2,0,r-i/2)/(r-i)}function p(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.7;if(i.muted||0===t)g(c,"display","none"),g(s,"display","flex"),g(l,"left","0");else{var e=((w(u,"width")||60)-w(l,"width"))*t;g(c,"display","flex"),g(s,"display","none"),g(l,"left","".concat(e,"px"))}}P(c,o.get("Mute")),g(s,"display","none"),p(i.volume),e.on("video:volumechange",(function(){p(i.volume)})),n(c,"click",(function(){i.muted=!0})),n(s,"click",(function(){i.muted=!1})),n(u,"click",(function(t){i.muted=!1,i.volume=f(t)})),n(l,"mousedown",(function(){a=!0})),n(document,"mousemove",(function(t){a&&(i.muted=!1,i.volume=f(t))})),n(document,"mouseup",(function(){a&&(a=!1)}))}})}}function kt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Et(t){return function(e){return function(t){for(var e=1;er.clientWidth-s/2?g(t,"left","".concat(r.clientWidth-s,"px")):g(t,"left","".concat(o-s/2,"px"))}(i))})),o(r,"mouseout",(function(){g(t,"display","none")}))}})}}function Rt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Tt(t){return function(e){return function(t){for(var e=1;e'.concat(s.name,"")),l=n.map((function(t,e){return'
').concat(t.name,"
")})).join(""),f=m(t,'
'.concat(l,"
"));o(t,(function(){f.style.left="-".concat(w(f,"width")/2-t.clientWidth/2,"px")})),i(f,"click",(function(t){var e=Number(t.target.dataset.index),r=n[e],i=r.url,o=r.name;i&&o&&c!==e&&(a.switchQuality(i,o),u.innerHTML=o,c=e)}))}})}}var Lt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.option;return e.on("ready",(function(){n.add(gt({name:"progress",disable:i.isLive,position:"top",index:10})),n.add($t({name:"thumbnails",disable:!i.thumbnails.url||i.isLive,position:"top",index:20})),n.add(yt({name:"playAndPause",disable:!1,position:"left",index:10})),n.add(xt({name:"volume",disable:!1,position:"left",index:20})),n.add(jt({name:"time",disable:i.isLive,position:"left",index:30})),n.add(Ct({name:"quality",disable:0===i.quality.length,position:"right",index:10})),n.add(Tt({name:"screenshot",disable:!i.screenshot,position:"right",index:20})),n.add(wt({name:"subtitle",disable:!i.subtitle.url,position:"right",index:30})),n.add(Et({name:"setting",disable:!i.setting,position:"right",index:40})),n.add(dt({name:"pip",disable:!i.pip,position:"right",index:50})),n.add(ft({name:"fullscreenWeb",disable:!i.fullscreenWeb,position:"right",index:60})),n.add(ut({name:"fullscreen",disable:!i.fullscreen,position:"right",index:70})),i.controls.forEach((function(t){n.add(t)}))})),n}return u(r,e),n(r,[{key:"add",value:function(t,e){var n="function"==typeof t?t(this.art):t;S(n.position,"Controls option.position can not be empty");var i=this.art.template,o=i.$progress,a=i.$controlsLeft,s=i.$controlsRight;switch(n.position){case"top":this.$parent=o;break;case"left":this.$parent=a;break;case"right":this.$parent=s}var u=ot(c(r.prototype),"add",this).call(this,n,e);return n.disable||"top"===n.position||u.$ref.firstElementChild&&"I"===u.$ref.firstElementChild.tagName||h(u.$ref,"art-control-onlyText"),u}}]),r}(at);function At(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Mt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e0.5\n0.75\n').concat(n.get("Normal"),'\n1.25\n1.5\n2.0\n '),click:function(t,e){var n=e.target.dataset.rate;n&&(r.playbackRate=Number(n),t.show=!1)},mounted:function(t){e.on("playbackRateChange",(function(e){var n=d("span",t).find((function(t){return Number(t.dataset.rate)===e}));n&&j(n,"art-current")}))}})}}function zt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function qt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e').concat(n.get("Default"),'\n4:3\n16:9\n '),click:function(t,e){var n=e.target.dataset.ratio;n&&(r.aspectRatio=n,t.show=!1)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("span",t).find((function(t){return t.dataset.ratio===e}));n&&j(n,"art-current")}))}})}}function Wt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Vt(t){return function(e){return function(t){for(var e=1;eArtPlayer 3.1.19'})}function Bt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function It(t){return function(e){return function(t){for(var e=1;ec+a&&(h=a-d),n+p>l+o&&(y=o-p),g(u,"left","".concat(h,"px")),g(u,"top","".concat(y,"px"))})),l(s,"click",(function(t){t.composedPath().includes(u)||(r.show=!1)})),e.on("blur",(function(){r.show=!1}))})),r}return u(n,e),n}(at),Ut=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.template,o=i.$infoPanel,s=i.$infoClose,u=i.$video;(0,e.events.proxy)(s,"click",(function(){r.show=!1}));var l=null,f=d("[data-video]",o);return e.on("destroy",(function(){clearTimeout(l)})),e.on("info:toggle",(function(t){clearTimeout(l),t&&function t(){f.forEach((function(t){var e=u[t.dataset.video];t.innerHTML="number"==typeof e?e.toFixed(2):e})),l=setTimeout((function(){t()}),1e3)}()})),r}return u(n,e),n}(at),_t=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.events.proxy,s=e.option.subtitle;return b(e.template.$subtitle,s.style),i(n.textTrack,"cuechange",n.update.bind(o(n))),s.url&&n.init(s.url),n}return u(r,e),n(r,[{key:"update",value:function(){var t=this.art.template.$subtitle;t.innerHTML="",this.activeCue&&(t.innerHTML=this.activeCue.text.split(/\r?\n/).map((function(t){return"

".concat(t,"

")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&o.show("".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),D(t)){case"srt":return R($(n));case"ass":return R(T(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show(t),e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(at);var Xt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.once("video:canplay",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=B((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Array.isArray(e)?e.forEach((function(e){return r.proxy(t,e,n,i)})):(t.addEventListener(e,n,i),this.destroyEvents.push((function(){t.removeEventListener(e,n,i)})))}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Zt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(at),Jt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(at),Gt=function(){function e(n){t(this,e),this.art=n,this.timer=null}return n(e,[{key:"show",value:function(t){var e=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=this.art.template,o=i.$player,a=i.$noticeInner;a.innerHTML=t instanceof Error?t.message.trim():t,clearTimeout(this.timer),n&&(this.timer=setTimeout((function(){e.hide()}),r)),h(o,"art-notice-show"),this.art.emit("notice:toggle",!0)}},{key:"hide",value:function(){var t=this.art.template,e=t.$player;t.$noticeInner.innerHTML="",y(e,"art-notice-show"),this.art.emit("notice:toggle",!0)}}]),e}(),Qt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(at),Kt=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'\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',state:'\n \n',play:'\n \n',pause:'\n \n',volume:'\n \n \n',volumeClose:'\n \n \n',subtitle:'\n \n \n',screenshot:'\n\t\n\n',setting:'\n \n \n',fullscreen:'\n\t\n\t\n\t\n\t\n',fullscreenWeb:'\n\t\n',pip:'\n \n',prev:'\n \n',next:'\n \n'},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function te(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ee(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Flip"),'\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n "),click:function(t,e){var n=e.target.dataset.value;n&&(r.flip=n)},mounted:function(t){e.on("flipChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ne(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function re(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Aspect ratio"),'\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n '),click:function(t,e){var n=e.target.dataset.value;n&&(r.aspectRatio=n)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ie(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function oe(t){return function(e){var n=e.i18n,r=e.player,i=e.events.proxy;return function(t){for(var e=1;e\n '.concat(n.get("Play speed"),': 1.0x\n\n
\n \n
\n '),mounted:function(t){var n=p(".art-setting-range input",t),o=p(".art-subtitle-value",t);i(n,"change",(function(){var t=n.value;o.innerText=t,r.playbackRate=Number(t)})),e.on("playbackRateChange",(function(t){n.value!==t&&(n.value=t,o.innerText=t)}))}})}}var ae=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.option,o=e.template,s=o.$setting,u=o.$settingBody,l=e.events.proxy;return r.$parent=u,i.setting&&(e.on("ready",(function(){l(s,"click",(function(t){t.target===s&&(r.show=!1)})),r.add(ee({disable:!i.flip,name:"flip"})),r.add(re({disable:!i.aspectRatio,name:"aspectRatio"})),r.add(oe({disable:!i.playbackRate,name:"playbackRate"}))})),e.on("blur",(function(){r.show=!1}))),r}return u(n,e),n}(at),ce=function(){function e(n){t(this,e),this.art=n,this.name="artplayer_settings";var r=n.option,i=this.get("volume");i&&(r.volume=i)}return n(e,[{key:"get",value:function(t){var e=JSON.parse(window.localStorage.getItem(this.name))||{};return t?e[t]:{}}},{key:"set",value:function(t,e){var n=Object.assign({},this.get(),ct({},t,e));window.localStorage.setItem(this.name,JSON.stringify(n))}},{key:"del",value:function(t){var e=this.get();delete e[t],window.localStorage.setItem(this.name,JSON.stringify(e))}},{key:"clean",value:function(){window.localStorage.removeItem(this.name)}}]),e}();function se(t){var e=t.i18n,n=t.subtitle,r=t.events.proxy;return{title:"Subtitle",name:"subtitleOffset",index:20,html:'\n
\n '.concat(e.get("Subtitle offset time"),': 0s\n
\n
\n \n
\n '),mounted:function(e){var i=p(".art-setting-range input",e),o=p(".art-subtitle-value",e);r(i,"change",(function(){var e=i.value;o.innerText=e,t.plugins.subtitleOffset.offset(Number(e))})),t.on("subtitle:switch",(function(){i.value=0,o.innerText=0})),t.on("subtitleOffset",(function(t){n.update(),i.value!==t&&(i.value=t,o.innerText=t)}))}}}function ue(t){var e=t.constructor.utils.clamp,n=t.setting,r=t.notice,i=t.template,o=t.i18n,a=t.player;n.add(se);var c=[];return t.on("subtitle:switch",(function(){c=[]})),{name:"subtitleOffset",offset:function(n){if(i.$track&&i.$track.track){var s=Array.from(i.$track.track.cues),u=e(n,-5,5);s.forEach((function(t,n){c[n]||(c[n]={startTime:t.startTime,endTime:t.endTime}),t.startTime=e(c[n].startTime+u,0,a.duration),t.endTime=e(c[n].endTime+u,0,a.duration)})),r.show("".concat(o.get("Subtitle offset time"),": ").concat(n,"s")),t.emit("subtitleOffset",n)}else r.show("".concat(o.get("No subtitles found"))),t.emit("subtitleOffset",0)}}}function le(t){var e=t.events.proxy,n=t.template,r=t.player,i=t.option,o=t.setting,a=t.i18n;function c(e){if(e){var o=n.$video.canPlayType(e.type);if("maybe"===o||"probably"===o){var a=URL.createObjectURL(e);i.title=e.name,r.switchUrl(a,e.name),t.emit("localVideo",e)}else S(!1,"Playback of this file format is not supported")}}function s(t){var n=m(t,'');g(t,"position","relative"),b(n,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(n,"change",(function(){c(n.files[0])}))}return e(n.$player,"dragover",(function(t){t.preventDefault()})),e(n.$player,"drop",(function(t){t.preventDefault(),c(t.dataTransfer.files[0])})),t.on("ready",(function(){o.add({title:"Local Video",name:"localVideo",index:30,html:'\n
\n '.concat(a.get("Local Video"),'\n
\n
\n
').concat(a.get("Open"),'
\n
\n
\n '),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localVideo",(function(t){r.textContent=t.name,r.title=t.name})),s(n)}})})),{name:"localVideo",attach:s}}function fe(t){var e=t.events.proxy,n=t.subtitle,r=t.setting,i=t.i18n;function o(r){var i=m(r,'');g(r,"position","relative"),b(i,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(i,"change",(function(){!function(r){if(r){var i=D(r.name);if(["ass","vtt","srt"].includes(i)){var o=new FileReader;e(o,"load",(function(e){var o=e.target.result;switch(i){case"srt":var a=R($(o));n.switch(a,r.name);break;case"ass":var c=R(T(o));n.switch(c,r.name);break;case"vtt":var s=R(o);n.switch(s,r.name)}t.emit("localSubtitle",r)})),o.readAsText(r)}else S(!1,"Only supports subtitle files in .ass, .vtt and .srt format")}}(i.files[0])}))}return t.on("ready",(function(){r.add({title:"Local Subtitle",name:"localSubtitle",index:40,html:'\n
\n '.concat(i.get("Local Subtitle"),'\n
\n
\n
').concat(i.get("Open"),'
\n
\n
\n '),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localSubtitle",(function(t){r.textContent=t.name,r.title=t.name})),o(n)}})})),{name:"localSubtitle",attach:o}}function pe(t){var e=t.layers,n=t.player,r=t.option.theme;return e.add({name:"miniProgressBar",style:{display:"none",position:"absolute",left:0,right:0,bottom:0,height:"2px",background:r},mounted:function(e){t.on("control:toggle",(function(t){e.style.display=t?"none":"block"})),t.on("destroy",(function(){e.style.display="none"})),t.on("video:timeupdate",(function(){e.style.width="".concat(100*n.played,"%")}))}}),{name:"miniProgressBar"}}function de(t){var e=1e4,n=0,r=0,i=0,o=null;function a(){n=0,r=0,i=0,cancelAnimationFrame(o),o=null}function c(){o||function a(){t.isDestroy||(o=requestAnimationFrame((function(){var o=Date.now();if(i){var c=o-i;r+=c,t.player.playing||(n+=c)}i=o,t.emit("networkMonitor",n/r),r>=e&&(n=0,r=0),a()})))}()}return t.on("play",c),t.on("pause",a),{name:"networkMonitor",reset:a,start:c,sample:function(t){e=t}}}function he(t){var e=t.events,n=t.player,r=t.template,i=B((function(){var e=r.$player.getBoundingClientRect();e.top+e.height<=0&&!n.pip?(n.pip=!0,t.emit("autoPip",!0)):n.pip&&(n.pip=!1,t.emit("autoPip",!1))}),300);return e.proxy(window,"scroll",i),{name:"autoPip"}}var ye=function(){function e(n){var r=this;t(this,e),this.art=n,this.id=0;var i=n.option;i.subtitle.url&&i.subtitleOffset&&this.add(ue),!i.isLive&&i.miniProgressBar&&this.add(pe),i.localVideo&&this.add(le),i.localSubtitle&&this.add(fe),i.networkMonitor&&this.add(de),i.autoPip&&this.add(he),n.option.plugins.forEach((function(t){r.add(t)}))}return n(e,[{key:"add",value:function(t){this.id+=1;var e=t.call(this,this.art),n="";return S(!q(this,n=e&&e.name?e.name:t.name?t.name:"plugin".concat(this.id)),"Cannot add a plugin that already has the same name: ".concat(n)),Object.defineProperty(this,n,{value:e}),this.art.emit("plugin:add",t),this}}]),e}(),ve=function e(n){t(this,e);var r=n.option,i=n.events.proxy,o=n.template.$video;Z.video.events.forEach((function(t){i(o,t,(function(t){n.emit("video:".concat(t.type),t)}))})),Object.keys(r.moreVideoAttr).forEach((function(t){o[t]=r.moreVideoAttr[t]})),r.muted&&(o.muted=r.muted),r.volume&&(o.volume=N(r.volume,0,1)),r.poster&&(o.poster=r.poster),r.autoplay&&(o.autoplay=r.autoplay),o.controls=!0;var a=r.type||D(r.url),c=r.customType[a];a&&c?(n.emit("beforeCustomType",a),c(o,r.url,n),n.emit("afterCustomType",a)):(n.emit("beforeAttachUrl",r.url),o.src=r.url,n.emit("afterAttachUrl",o.src))},me=0,ge=function(e){function r(e){var n;return t(this,r),(n=a(this,c(r).call(this))).option=l(F(r.option,e),Y),n.isFocus=!1,n.isDestroy=!1,n.whitelist=new J(o(n)),n.template=new G(o(n)),n.events=new Xt(o(n)),n.whitelist.state?(n.storage=new ce(o(n)),n.icons=new Kt(o(n)),n.i18n=new tt(o(n)),n.notice=new Gt(o(n)),n.player=new rt(o(n)),n.layers=new Zt(o(n)),n.controls=new Lt(o(n)),n.contextmenu=new Nt(o(n)),n.subtitle=new _t(o(n)),n.info=new Ut(o(n)),n.loading=new Jt(o(n)),n.hotkey=new Yt(o(n)),n.mask=new Qt(o(n)),n.setting=new ae(o(n)),n.plugins=new ye(o(n))):n.mobile=new ve(o(n)),me+=1,n.id=me,r.instances.push(o(n)),n}return u(r,e),n(r,[{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.events.destroy(),this.template.destroy(t),r.instances.splice(r.instances.indexOf(this),1),this.isDestroy=!0,this.emit("destroy")}}],[{key:"version",get:function(){return"3.1.19"}},{key:"env",get:function(){return'"production"'}},{key:"config",get:function(){return Z}},{key:"utils",get:function(){return _}},{key:"scheme",get:function(){return Y}},{key:"Emitter",get:function(){return f}},{key:"validator",get:function(){return l}},{key:"kindOf",get:function(){return l.kindOf}},{key:"option",get:function(){return{container:"#artplayer",url:"",poster:"",title:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,localVideo:!1,localSubtitle:!1,autoPip:!1,networkMonitor:!1,layers:[],contextmenu:[],quality:[],controls:[],highlight:[],plugins:[],whitelist:[],thumbnails:{url:"",number:60,width:160,height:90,column:10},subtitle:{url:"",style:{}},moreVideoAttr:{controls:!1,preload:"metadata"},icons:{},customType:{},lang:navigator.language.toLowerCase()}}}]),r}(f);return Object.defineProperty(ge,"instances",{value:[]}),console.log("%c ArtPlayer %c 3.1.19 %c https://artplayer.org","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),ge})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,(function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function e(t,e){for(var n=0;n1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:document).querySelector(t)}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(e.querySelectorAll(t))}function h(t,e){return t.classList.add(e)}function y(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function m(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function g(t,e,n){return t.style[e]=n,t}function b(t,e){return Object.keys(e).forEach((function(n){g(t,n,e[n])})),t}function w(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=window.getComputedStyle(t,null).getPropertyValue(e);return n?parseFloat(r):r}function O(t){return Array.from(t.parentElement.children).filter((function(e){return e!==t}))}function j(t,e){O(t).forEach((function(t){return y(t,e)})),h(t,e)}function P(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"up";t.setAttribute("aria-label",e),t.setAttribute("data-balloon-pos",n)}var x=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},k=r((function(t){function e(n,r,i){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}}()?t.exports=e=function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&s(i,n.prototype),i}:t.exports=e=Reflect.construct,e.apply(null,arguments)}t.exports=e})),E=function(e){function n(e,r){var i;return t(this,n),i=a(this,c(n).call(this,e)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),r||i.constructor),i.name="ArtPlayerError",i}return u(n,e),n}(r((function(t){function e(n){var r="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!x(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return k(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},e(n)}t.exports=e}))(Error));function S(t,e){if(!t)throw new E(e);return t}function $(t){return"WEBVTT \r\n\r\n".concat(t.replace(/{[\s\S]*?}/g,"").replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"))}function R(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function D(t){var e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(/[:.]/).map((function(t,e,n){if(e===n.length-1){if(1===t.length)return".".concat(t,"00");if(2===t.length)return".".concat(t,"0")}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===n.length-1?".".concat(t):":".concat(t)})).join("")}return"WEBVTT\n\n".concat(t.split(/\r?\n/).map((function(t){var r=t.match(e);return r?{start:n(r[1].trim()),end:n(r[2].trim()),text:r[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map((function(t){return t.trim()})).join("\n")}:null})).filter((function(t){return t})).map((function(t,e){return t?"".concat(e+1,"\n").concat(t.start," --\x3e ").concat(t.end,"\n").concat(t.text):""})).filter((function(t){return t.trim()})).join("\n\n"))}function T(t){return t.includes("?")?T(t.split("?")[0]):t.includes("#")?T(t.split("#")[0]):t.trim().toLowerCase().split(".").pop()}function C(t,e){var n=document.createElement("a");n.style.display="none",n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}var L=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e){return setTimeout(e,t)}))}function N(t,e,n){var r;function i(){for(var i=arguments.length,o=new Array(i),a=0;a0?[e,n,r]:[n,r]).map((function(t){return t<10?"0".concat(t):String(t)})).join(":")}var X=Object.freeze({__proto__:null,query:p,queryAll:d,addClass:h,removeClass:y,hasClass:v,append:m,remove:function(t){return t.parentNode.removeChild(t)},setStyle:g,setStyles:b,getStyle:w,sublings:O,inverseClass:j,tooltip:P,ArtPlayerError:E,errorHandle:S,srtToVtt:$,vttToBlob:R,assToVtt:D,getExt:T,downloadFile:C,hasOwnProperty:W,defineProperty:F,proxyPropertys:H,mergeDeep:B,sleep:I,debounce:N,throttle:U,clamp:_,secondToTime:Y});function Z(t,e,n){return S("string"===e||t instanceof Element,"".concat(n.join(".")," require 'string' or 'Element' type"))}var J={container:Z,url:"string|function",poster:"string",title:"string",theme:"string",lang:"string",volume:"number",isLive:"boolean",muted:"boolean",autoplay:"boolean",autoSize:"boolean",loop:"boolean",flip:"boolean",playbackRate:"boolean",aspectRatio:"boolean",screenshot:"boolean",setting:"boolean",hotkey:"boolean",pip:"boolean",mutex:"boolean",fullscreen:"boolean",fullscreenWeb:"boolean",subtitleOffset:"boolean",miniProgressBar:"boolean",localVideo:"boolean",localSubtitle:"boolean",autoPip:"boolean",networkMonitor:"boolean",plugins:["function"],whitelist:["string|function|regexp"],layers:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],contextmenu:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],quality:[{default:"boolean|undefined",name:"string",url:"string"}],controls:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined",position:function(t,e,n){var r=["top","left","right"];return S(r.includes(t),"".concat(n.join(".")," only accept ").concat(r.toString()," as parameters"))}}],highlight:[{time:"number",text:"string"}],thumbnails:{url:"string",number:"number",width:"number",height:"number",column:"number"},subtitle:{url:"string",style:"object"},moreVideoAttr:"object",icons:"object",customType:"object"},G={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"]}},K=function e(n){var r=this;t(this,e);var i=n.constructor.kindOf,o=n.option.whitelist;this.userAgent=window.navigator.userAgent,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.userAgent),this.state=!this.isMobile||o.some((function(t){switch(i(t)){case"string":return r.userAgent.indexOf(t)>-1;case"function":return t(r.userAgent);case"regexp":return t.test(r.userAgent);default:return!1}}))},Q=function(){function e(n){var r=this;t(this,e),this.art=n,n.option.container instanceof Element?this.$container=n.option.container:(this.$container=p(n.option.container),S(this.$container,"No container element found by ".concat(n.option.container))),S(n.constructor.instances.every((function(t){return t.template.$container!==r.$container})),"Cannot mount multiple instances on the same dom element"),S(this.$container.clientWidth&&this.$container.clientHeight,"The width and height of the container cannot be 0"),n.whitelist.state?this.initDesktop():this.initMobile()}return n(e,[{key:"query",value:function(t){return p(t,this.$container)}},{key:"initDesktop",value:function(){this.$container.innerHTML='\n
Player version:
3.1.19
Video url:
Video volume:
Video time:
Video duration:
Video resolution:
x
[x]
×
\n
'),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query(".art-video track"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$settingInner=this.query(".art-setting-inner"),this.$settingBody=this.query(".art-setting-body"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$pipHeader=this.query(".art-pip-header"),this.$pipTitle=this.query(".art-pip-title"),this.$pipClose=this.query(".art-pip-close"),this.$contextmenu=this.query(".art-contextmenus")}},{key:"initMobile",value:function(){this.$container.innerHTML='\n
\n
',this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video")}},{key:"destroy",value:function(t){t?this.$container.innerHTML="":h(this.$player,"art-destroy")}}]),e}(),tt={"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Flip:"视频翻转",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕","Show setting":"显示设置","Hide setting":"隐藏设置",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常",Open:"打开","Switch video":"切换","Switch subtitle":"切换字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"网页全屏","Exit web fullscreen":"退出网页全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地视频","Subtitle offset time":"字幕偏移时间","No subtitles found":"未发现字幕"},et={"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Flip:"影片翻轉",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕","Show setting":"顯示设置","Hide setting":"隱藏设置",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常",Open:"打開","Switch video":"切換","Switch subtitle":"切換字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"網頁全屏","Exit web fullscreen":"退出網頁全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地視頻","Subtitle offset time":"字幕偏移時間","No subtitles found":"未發現字幕"},nt=function(){function e(n){t(this,e),this.art=n,this.languages={"zh-cn":tt,"zh-tw":et},this.init()}return n(e,[{key:"init",value:function(){var t=this.art.option.lang.toLowerCase();this.language=this.languages[t]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){this.languages=B(this.languages,t),this.init()}}]),e}();var rt=r((function(t){!function(){var e="undefined"!=typeof window&&void 0!==window.document?window.document:{},n=t.exports,r="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,i=function(){for(var t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,o={};rh){var y=h*l/u;g(r,"width","".concat(100*y,"%")),g(r,"height","100%"),g(r,"padding","0 ".concat((f-f*y)/2,"px"))}else{var v=u/h/l;g(r,"width","100%"),g(r,"height","".concat(100*v,"%")),g(r,"padding","".concat((p-p*v)/2,"px 0"))}}i.dataset.aspectRatio=n,a.show("".concat(o.get("Aspect ratio"),": ").concat("default"===n?o.get("Default"):n)),t.emit("aspectRatioChange",n)}else e.aspectRatio&&(g(r,"width",null),g(r,"height",null),g(r,"padding",null),delete i.dataset.aspectRatio,t.emit("aspectRatioRemove"))}}),Object.defineProperty(e,"aspectRatioReset",{set:function(n){if(n&&e.aspectRatio){var r=e.aspectRatio;e.aspectRatio=r,t.emit("aspectRatioReset")}}})}(n,this),function(t,e){var n=t.option,r=t.notice,i=t.template.$video;Object.defineProperty(e,"getScreenshotDataURL",{value:function(){try{var t=document.createElement("canvas");return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),t.toDataURL("image/png")}catch(t){throw r.show(t),t}}}),Object.defineProperty(e,"getScreenshotBlobUrl",{value:function(){return new Promise((function(t,e){try{var n=document.createElement("canvas");n.width=i.videoWidth,n.height=i.videoHeight,n.getContext("2d").drawImage(i,0,0),n.toBlob((function(e){t(URL.createObjectURL(e))}))}catch(t){r.show(t),e(t)}}))}}),Object.defineProperty(e,"screenshot",{value:function(){var r=e.getScreenshotDataURL();r&&(C(r,"".concat(n.title||"artplayer","_").concat(Y(i.currentTime),".png")),t.emit("screenshot",r))}})}(n,this),function(t,e){var n=t.i18n,r=t.notice,i=t.events.destroyEvents,o=t.template.$player,a=function(){t.emit("fullscreenChange",rt.isFullscreen)},c=function(){r.show(n.get("Does not support fullscreen"))};e.fullscreenIsEnabled&&(rt.on("change",a),rt.on("error",c),i.push((function(){rt.off("change",a),rt.off("error",c)}))),Object.defineProperty(e,"fullscreen",{get:function(){return rt.isFullscreen},set:function(n){e.fullscreenIsEnabled?n?(e.fullscreenWeb&&(e.fullscreenWeb=!1),rt.request(o).then((function(){h(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenEnabled")}))):(e.fullscreenWeb&&(e.fullscreenWeb=!1),rt.exit().then((function(){y(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenExit")}))):c()}}),Object.defineProperty(e,"fullscreenToggle",{set:function(t){t&&(e.fullscreen=!e.fullscreen)}}),Object.defineProperty(e,"fullscreenIsEnabled",{get:function(){return rt.isEnabled}})}(n,this),function(t,e){var n=t.template.$player;Object.defineProperty(e,"fullscreenWeb",{get:function(){return v(n,"art-web-fullscreen")},set:function(r){r?(e.fullscreen&&(e.fullscreen=!1),h(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebEnabled")):(e.fullscreen&&(e.fullscreen=!1),y(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebExit"))}}),Object.defineProperty(e,"fullscreenWebToggle",{set:function(t){t&&(e.fullscreenWeb=!e.fullscreenWeb)}})}(n,this),it(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"loaded",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1)/n.duration:0}}),Object.defineProperty(e,"loadedTime",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1):0}})}(n,this),function(t,e){Object.defineProperty(e,"played",{get:function(){return t.template.$video.currentTime/t.template.$video.duration}})}(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"playing",{get:function(){return!!(n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2)}})}(n,this),function(t,e){var n=t.template,r=n.$container,i=n.$player,o=n.$video;Object.defineProperty(e,"autoSize",{get:function(){return v(r,"art-auto-size")},set:function(n){if(n){var a=o.videoWidth,c=o.videoHeight,s=r.getBoundingClientRect(),u=s.width,l=s.height,f=a/c,p=u/l;if(h(r,"art-auto-size"),p>f){g(i,"width","".concat(l*f/u*100,"%")),g(i,"height","100%")}else{var d=u/f/l*100;g(i,"width","100%"),g(i,"height","".concat(d,"%"))}t.emit("autoSizeChange",{width:e.width,height:e.height})}else y(r,"art-auto-size"),g(i,"width",null),g(i,"height",null),t.emit("autoSizeRemove")}})}(n,this),function(t,e){Object.defineProperty(e,"rect",{get:function(){return t.template.$player.getBoundingClientRect()}}),["bottom","height","left","right","top","width"].forEach((function(t){Object.defineProperty(e,t,{get:function(){return e.rect[t]}})})),Object.defineProperty(e,"x",{get:function(){return e.left+window.pageXOffset}}),Object.defineProperty(e,"y",{get:function(){return e.top+window.pageYOffset}})}(n,this),function(t,e){Object.defineProperty(e,"flip",{get:function(){return t.template.$player.dataset.flip},set:function(e){if(e){var n=["normal","horizontal","vertical"];S(n.includes(e),"'flip' only accept ".concat(n.toString()," as parameters")),t.template.$player.dataset.flip=e,t.emit("flipChange",e)}else delete t.template.$player.dataset.flip,t.emit("flipRemove")}})}(n,this),H(n,this)};var at=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t},ct=r((function(t){function e(n,r,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,n){var r=at(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}},e(n,r,i||n)}t.exports=e})),st=function(){function e(n){t(this,e),this.id=0,this.art=n,this.add=this.add.bind(this),this.name=this.constructor.name.toLowerCase()}return n(e,[{key:"toggle",value:function(){this.show=!this.show}},{key:"add",value:function(t,e){var n=this,r="function"==typeof t?t(this.art):t;if(!this.$parent||r.disable)return{};this.id+=1;var i=r.name||"".concat(this.name).concat(this.id);S(!W(this,i),"Cannot add a component that already has the same name: ".concat(i));var o=document.createElement("div");o.classList.value="art-".concat(this.name," art-").concat(this.name,"-").concat(i),r.html&&m(o,r.html),r.style&&b(o,r.style),r.tooltip&&P(o,r.tooltip);var a=Array.from(this.$parent.children);o.dataset.index=r.index||this.id;var c=a.find((function(t){return Number(t.dataset.index)>=Number(o.dataset.index)}));return c?c.insertAdjacentElement("beforebegin",o):m(this.$parent,o),r.click&&this.art.events.proxy(o,"click",(function(t){t.preventDefault(),r.click.call(n.art,n,t)})),r.mounted&&r.mounted(o,this,this.art),e&&e(o,this,this.art),F(this,i,{value:{get $ref(){return o},set show(t){g(o,"display",t?"block":"none")}}}),this.art.emit("".concat(this.name,":add"),r),this[i]}},{key:"show",get:function(){return v(this.art.template.$player,"art-".concat(this.name,"-show"))},set:function(t){S(!1===t||!0===t,"The show attribute expects a boolean value");var e=this.art.template.$player,n="art-".concat(this.name,"-show");t?h(e,n):y(e,n),this.art.emit("".concat(this.name,":toggle"),t)}}]),e}();var ut=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};function lt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ft(t){return function(e){return function(t){for(var e=1;e
\n'),mounted:function(t){var n=!1,i=p(".art-progress-loaded",t),c=p(".art-progress-played",t),s=p(".art-progress-highlight",t),u=p(".art-progress-indicator",t),l=p(".art-progress-tip",t);function f(t,e){"loaded"===t&&g(i,"width","".concat(100*e,"%")),"played"===t&&(g(c,"width","".concat(100*e,"%")),g(u,"left","calc(".concat(100*e,"% - ").concat(w(u,"width")/2,"px)")))}r.forEach((function(t){var e=_(t.time,0,a.duration)/a.duration*100;m(s,''))})),f("loaded",a.loaded),e.on("video:progress",(function(){f("loaded",a.loaded)})),e.on("video:timeupdate",(function(){f("played",a.played)})),e.on("video:ended",(function(){f("played",1)})),o(t,"mousemove",(function(n){g(l,"display","block"),n.composedPath().indexOf(s)>-1?function(n){var r=bt(e,n).width,i=n.target.dataset.text;l.innerHTML=i;var o=l.clientWidth;r<=o/2?g(l,"left",0):r>t.clientWidth-o/2?g(l,"left","".concat(t.clientWidth-o,"px")):g(l,"left","".concat(r-o/2,"px"))}(n):function(n){var r=bt(e,n),i=r.width,o=r.time;l.innerHTML=o;var a=l.clientWidth;i<=a/2?g(l,"left",0):i>t.clientWidth-a/2?g(l,"left","".concat(t.clientWidth-a,"px")):g(l,"left","".concat(i-a/2,"px"))}(n)})),o(t,"mouseout",(function(){g(l,"display","none")})),o(t,"click",(function(t){if(t.target!==u){var n=bt(e,t),r=n.second;f("played",n.percentage),a.seek=r}})),o(u,"mousedown",(function(){n=!0})),o(document,"mousemove",(function(t){if(n){var r=bt(e,t),i=r.second,o=r.percentage;h(u,"art-show-indicator"),f("played",o),a.seek=i}})),o(document,"mouseup",(function(){n&&(n=!1,y(u,"art-show-indicator"))}))}})}}function Ot(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function jt(t){return function(e){return function(t){for(var e=1;e'),l=m(u,'
');function f(t){var e=u.getBoundingClientRect(),n=e.left,r=e.width,i=l.getBoundingClientRect().width;return _(t.pageX-n-i/2,0,r-i/2)/(r-i)}function p(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.7;if(i.muted||0===t)g(c,"display","none"),g(s,"display","flex"),g(l,"left","0");else{var e=((w(u,"width")||60)-w(l,"width"))*t;g(c,"display","flex"),g(s,"display","none"),g(l,"left","".concat(e,"px"))}}P(c,o.get("Mute")),g(s,"display","none"),p(i.volume),e.on("video:volumechange",(function(){p(i.volume)})),n(c,"click",(function(){i.muted=!0})),n(s,"click",(function(){i.muted=!1})),n(u,"click",(function(t){i.muted=!1,i.volume=f(t)})),n(l,"mousedown",(function(){a=!0})),n(document,"mousemove",(function(t){a&&(i.muted=!1,i.volume=f(t))})),n(document,"mouseup",(function(){a&&(a=!1)}))}})}}function St(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function $t(t){return function(e){return function(t){for(var e=1;er.clientWidth-s/2?g(t,"left","".concat(r.clientWidth-s,"px")):g(t,"left","".concat(o-s/2,"px"))}(i))})),o(r,"mouseout",(function(){g(t,"display","none")}))}})}}function Tt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ct(t){return function(e){return function(t){for(var e=1;e'.concat(s.name,"")),l=n.map((function(t,e){return'
').concat(t.name,"
")})).join(""),f=m(t,'
'.concat(l,"
"));o(t,(function(){f.style.left="-".concat(w(f,"width")/2-t.clientWidth/2,"px")})),i(f,"click",(function(t){var e=Number(t.target.dataset.index),r=n[e],i=r.url,o=r.name;i&&o&&c!==e&&(a.switchQuality(i,o),u.innerHTML=o,c=e)}))}})}}var Mt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.option;return e.on("ready",(function(){n.add(wt({name:"progress",disable:i.isLive,position:"top",index:10})),n.add(Dt({name:"thumbnails",disable:!i.thumbnails.url||i.isLive,position:"top",index:20})),n.add(mt({name:"playAndPause",disable:!1,position:"left",index:10})),n.add(Et({name:"volume",disable:!1,position:"left",index:20})),n.add(xt({name:"time",disable:i.isLive,position:"left",index:30})),n.add(At({name:"quality",disable:0===i.quality.length,position:"right",index:10})),n.add(Ct({name:"screenshot",disable:!i.screenshot,position:"right",index:20})),n.add(jt({name:"subtitle",disable:!i.subtitle.url,position:"right",index:30})),n.add($t({name:"setting",disable:!i.setting,position:"right",index:40})),n.add(yt({name:"pip",disable:!i.pip,position:"right",index:50})),n.add(dt({name:"fullscreenWeb",disable:!i.fullscreenWeb,position:"right",index:60})),n.add(ft({name:"fullscreen",disable:!i.fullscreen,position:"right",index:70})),i.controls.forEach((function(t){n.add(t)}))})),n}return u(r,e),n(r,[{key:"add",value:function(t,e){var n="function"==typeof t?t(this.art):t;S(n.position,"Controls option.position can not be empty");var i=this.art.template,o=i.$progress,a=i.$controlsLeft,s=i.$controlsRight;switch(n.position){case"top":this.$parent=o;break;case"left":this.$parent=a;break;case"right":this.$parent=s}var u=ct(c(r.prototype),"add",this).call(this,n,e);return n.disable||"top"===n.position||u.$ref.firstElementChild&&"I"===u.$ref.firstElementChild.tagName||h(u.$ref,"art-control-onlyText"),u}}]),r}(st);function zt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function qt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e0.5\n0.75\n').concat(n.get("Normal"),'\n1.25\n1.5\n2.0'),click:function(t,e){var n=e.target.dataset.rate;n&&(r.playbackRate=Number(n),t.show=!1)},mounted:function(t){e.on("playbackRateChange",(function(e){var n=d("span",t).find((function(t){return Number(t.dataset.rate)===e}));n&&j(n,"art-current")}))}})}}function Wt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Vt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e').concat(n.get("Default"),'\n4:3\n16:9'),click:function(t,e){var n=e.target.dataset.ratio;n&&(r.aspectRatio=n,t.show=!1)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("span",t).find((function(t){return t.dataset.ratio===e}));n&&j(n,"art-current")}))}})}}function Ft(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ht(t){return function(e){return function(t){for(var e=1;eArtPlayer 3.1.19'})}function Nt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ut(t){return function(e){return function(t){for(var e=1;ec+a&&(h=a-d),n+p>l+o&&(y=o-p),g(u,"left","".concat(h,"px")),g(u,"top","".concat(y,"px"))})),l(s,"click",(function(t){t.composedPath().includes(u)||(r.show=!1)})),e.on("blur",(function(){r.show=!1}))})),r}return u(n,e),n}(st),Yt=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.template,o=i.$infoPanel,s=i.$infoClose,u=i.$video;(0,e.events.proxy)(s,"click",(function(){r.show=!1}));var l=null,f=d("[data-video]",o);return e.on("destroy",(function(){clearTimeout(l)})),e.on("info:toggle",(function(t){clearTimeout(l),t&&function t(){f.forEach((function(t){var e=u[t.dataset.video];t.innerHTML="number"==typeof e?e.toFixed(2):e})),l=setTimeout((function(){t()}),1e3)}()})),r}return u(n,e),n}(st),Xt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.events.proxy,s=e.option.subtitle;return b(e.template.$subtitle,s.style),i(n.textTrack,"cuechange",n.update.bind(o(n))),s.url&&n.init(s.url),n}return u(r,e),n(r,[{key:"update",value:function(){var t=this.art.template.$subtitle;t.innerHTML="",this.activeCue&&(t.innerHTML=this.activeCue.text.split(/\r?\n/).map((function(t){return"

".concat(t,"

")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&o.show("".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),T(t)){case"srt":return R($(n));case"ass":return R(D(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show(t),e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(st);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.once("video:canplay",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=U((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Array.isArray(e)?e.forEach((function(e){return r.proxy(t,e,n,i)})):(t.addEventListener(e,n,i),this.destroyEvents.push((function(){t.removeEventListener(e,n,i)})))}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Jt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Gt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(st),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(st),Qt=function(){function e(n){t(this,e),this.art=n,this.timer=null}return n(e,[{key:"show",value:function(t){var e=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=this.art.template,o=i.$player,a=i.$noticeInner;a.innerHTML=t instanceof Error?t.message.trim():t,clearTimeout(this.timer),n&&(this.timer=setTimeout((function(){e.hide()}),r)),h(o,"art-notice-show"),this.art.emit("notice:toggle",!0)}},{key:"hide",value:function(){var t=this.art.template,e=t.$player;t.$noticeInner.innerHTML="",y(e,"art-notice-show"),this.art.emit("notice:toggle",!0)}}]),e}(),te=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(st),ee=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'\n',state:'\n',play:'\n',pause:'\n',volume:'\n',volumeClose:'\n',subtitle:'\n',screenshot:'\n\t\n\n',setting:'\n',fullscreen:'\n\t\n\t\n\t\n\t\n',fullscreenWeb:'\n\t\n',pip:'\n',prev:'\n',next:'\n'},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ne(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function re(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Flip"),'\n
\n
"),click:function(t,e){var n=e.target.dataset.value;n&&(r.flip=n)},mounted:function(t){e.on("flipChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ie(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function oe(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Aspect ratio"),'\n
\n
'),click:function(t,e){var n=e.target.dataset.value;n&&(r.aspectRatio=n)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ae(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ce(t){return function(e){var n=e.i18n,r=e.player,i=e.events.proxy;return function(t){for(var e=1;e'.concat(n.get("Play speed"),': 1.0x\n\n
\n
'),mounted:function(t){var n=p(".art-setting-range input",t),o=p(".art-subtitle-value",t);i(n,"change",(function(){var t=n.value;o.innerText=t,r.playbackRate=Number(t)})),e.on("playbackRateChange",(function(t){n.value!==t&&(n.value=t,o.innerText=t)}))}})}}var se=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.option,o=e.template,s=o.$setting,u=o.$settingBody,l=e.events.proxy;return r.$parent=u,i.setting&&(e.on("ready",(function(){l(s,"click",(function(t){t.target===s&&(r.show=!1)})),r.add(re({disable:!i.flip,name:"flip"})),r.add(oe({disable:!i.aspectRatio,name:"aspectRatio"})),r.add(ce({disable:!i.playbackRate,name:"playbackRate"}))})),e.on("blur",(function(){r.show=!1}))),r}return u(n,e),n}(st),ue=function(){function e(n){t(this,e),this.art=n,this.name="artplayer_settings";var r=n.option,i=this.get("volume");i&&(r.volume=i)}return n(e,[{key:"get",value:function(t){var e=JSON.parse(window.localStorage.getItem(this.name))||{};return t?e[t]:{}}},{key:"set",value:function(t,e){var n=Object.assign({},this.get(),ut({},t,e));window.localStorage.setItem(this.name,JSON.stringify(n))}},{key:"del",value:function(t){var e=this.get();delete e[t],window.localStorage.setItem(this.name,JSON.stringify(e))}},{key:"clean",value:function(){window.localStorage.removeItem(this.name)}}]),e}();function le(t){var e=t.i18n,n=t.subtitle,r=t.events.proxy;return{title:"Subtitle",name:"subtitleOffset",index:20,html:'\n
'.concat(e.get("Subtitle offset time"),': 0s\n
\n
\n
'),mounted:function(e){var i=p(".art-setting-range input",e),o=p(".art-subtitle-value",e);r(i,"change",(function(){var e=i.value;o.innerText=e,t.plugins.subtitleOffset.offset(Number(e))})),t.on("subtitle:switch",(function(){i.value=0,o.innerText=0})),t.on("subtitleOffset",(function(t){n.update(),i.value!==t&&(i.value=t,o.innerText=t)}))}}}function fe(t){var e=t.constructor.utils.clamp,n=t.setting,r=t.notice,i=t.template,o=t.i18n,a=t.player;n.add(le);var c=[];return t.on("subtitle:switch",(function(){c=[]})),{name:"subtitleOffset",offset:function(n){if(i.$track&&i.$track.track){var s=Array.from(i.$track.track.cues),u=e(n,-5,5);s.forEach((function(t,n){c[n]||(c[n]={startTime:t.startTime,endTime:t.endTime}),t.startTime=e(c[n].startTime+u,0,a.duration),t.endTime=e(c[n].endTime+u,0,a.duration)})),r.show("".concat(o.get("Subtitle offset time"),": ").concat(n,"s")),t.emit("subtitleOffset",n)}else r.show("".concat(o.get("No subtitles found"))),t.emit("subtitleOffset",0)}}}function pe(t){var e=t.events.proxy,n=t.template,r=t.player,i=t.option,o=t.setting,a=t.i18n;function c(e){if(e){var o=n.$video.canPlayType(e.type);if("maybe"===o||"probably"===o){var a=URL.createObjectURL(e);i.title=e.name,r.switchUrl(a,e.name),t.emit("localVideo",e)}else S(!1,"Playback of this file format is not supported")}}function s(t){var n=m(t,'');g(t,"position","relative"),b(n,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(n,"change",(function(){c(n.files[0])}))}return e(n.$player,"dragover",(function(t){t.preventDefault()})),e(n.$player,"drop",(function(t){t.preventDefault(),c(t.dataTransfer.files[0])})),t.on("ready",(function(){o.add({title:"Local Video",name:"localVideo",index:30,html:'\n
'.concat(a.get("Local Video"),'\n
\n
').concat(a.get("Open"),'
\n
'),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localVideo",(function(t){r.textContent=t.name,r.title=t.name})),s(n)}})})),{name:"localVideo",attach:s}}function de(t){var e=t.events.proxy,n=t.subtitle,r=t.setting,i=t.i18n;function o(r){var i=m(r,'');g(r,"position","relative"),b(i,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(i,"change",(function(){!function(r){if(r){var i=T(r.name);if(["ass","vtt","srt"].includes(i)){var o=new FileReader;e(o,"load",(function(e){var o=e.target.result;switch(i){case"srt":var a=R($(o));n.switch(a,r.name);break;case"ass":var c=R(D(o));n.switch(c,r.name);break;case"vtt":var s=R(o);n.switch(s,r.name)}t.emit("localSubtitle",r)})),o.readAsText(r)}else S(!1,"Only supports subtitle files in .ass, .vtt and .srt format")}}(i.files[0])}))}return t.on("ready",(function(){r.add({title:"Local Subtitle",name:"localSubtitle",index:40,html:'\n
'.concat(i.get("Local Subtitle"),'\n
\n
').concat(i.get("Open"),'
\n
'),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localSubtitle",(function(t){r.textContent=t.name,r.title=t.name})),o(n)}})})),{name:"localSubtitle",attach:o}}function he(t){var e=t.layers,n=t.player,r=t.option.theme;return e.add({name:"miniProgressBar",style:{display:"none",position:"absolute",left:0,right:0,bottom:0,height:"2px",background:r},mounted:function(e){t.on("control:toggle",(function(t){e.style.display=t?"none":"block"})),t.on("destroy",(function(){e.style.display="none"})),t.on("video:timeupdate",(function(){e.style.width="".concat(100*n.played,"%")}))}}),{name:"miniProgressBar"}}function ye(t){var e=1e4,n=0,r=0,i=0,o=null;function a(){n=0,r=0,i=0,cancelAnimationFrame(o),o=null}function c(){o||function a(){t.isDestroy||(o=requestAnimationFrame((function(){var o=Date.now();if(i){var c=o-i;r+=c,t.player.playing||(n+=c)}i=o,t.emit("networkMonitor",n/r),r>=e&&(n=0,r=0),a()})))}()}return t.on("play",c),t.on("pause",a),{name:"networkMonitor",reset:a,start:c,sample:function(t){e=t}}}function ve(t){var e=t.events,n=t.player,r=t.template,i=N((function(){var e=r.$player.getBoundingClientRect();e.top+e.height<=0&&!n.pip?(n.pip=!0,t.emit("autoPip",!0)):n.pip&&(n.pip=!1,t.emit("autoPip",!1))}),300);return e.proxy(window,"scroll",i),{name:"autoPip"}}var me=function(){function e(n){var r=this;t(this,e),this.art=n,this.id=0;var i=n.option;i.subtitle.url&&i.subtitleOffset&&this.add(fe),!i.isLive&&i.miniProgressBar&&this.add(he),i.localVideo&&this.add(pe),i.localSubtitle&&this.add(de),i.networkMonitor&&this.add(ye),i.autoPip&&this.add(ve),n.option.plugins.forEach((function(t){r.add(t)}))}return n(e,[{key:"add",value:function(t){this.id+=1;var e=t.call(this,this.art),n="";return S(!W(this,n=e&&e.name?e.name:t.name?t.name:"plugin".concat(this.id)),"Cannot add a plugin that already has the same name: ".concat(n)),Object.defineProperty(this,n,{value:e}),this.art.emit("plugin:add",t),this}}]),e}(),ge=function e(n){t(this,e);var r=n.option,i=n.events.proxy,o=n.template.$video;G.video.events.forEach((function(t){i(o,t,(function(t){n.emit("video:".concat(t.type),t)}))})),Object.keys(r.moreVideoAttr).forEach((function(t){o[t]=r.moreVideoAttr[t]})),r.muted&&(o.muted=r.muted),r.volume&&(o.volume=_(r.volume,0,1)),r.poster&&(o.poster=r.poster),r.autoplay&&(o.autoplay=r.autoplay),o.controls=!0;var a=r.type||T(r.url),c=r.customType[a];a&&c?(n.emit("beforeCustomType",a),c(o,r.url,n),n.emit("afterCustomType",a)):(n.emit("beforeAttachUrl",r.url),o.src=r.url,n.emit("afterAttachUrl",o.src))},be=0,we=function(e){function r(e){var n;return t(this,r),(n=a(this,c(r).call(this))).option=l(B(r.option,e),J),n.isFocus=!1,n.isDestroy=!1,n.whitelist=new K(o(n)),n.template=new Q(o(n)),n.events=new Zt(o(n)),n.whitelist.state?(n.storage=new ue(o(n)),n.icons=new ee(o(n)),n.i18n=new nt(o(n)),n.notice=new Qt(o(n)),n.player=new ot(o(n)),n.layers=new Gt(o(n)),n.controls=new Mt(o(n)),n.contextmenu=new _t(o(n)),n.subtitle=new Xt(o(n)),n.info=new Yt(o(n)),n.loading=new Kt(o(n)),n.hotkey=new Jt(o(n)),n.mask=new te(o(n)),n.setting=new se(o(n)),n.plugins=new me(o(n))):n.mobile=new ge(o(n)),be+=1,n.id=be,r.instances.push(o(n)),n}return u(r,e),n(r,[{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.events.destroy(),this.template.destroy(t),r.instances.splice(r.instances.indexOf(this),1),this.isDestroy=!0,this.emit("destroy")}}],[{key:"version",get:function(){return"3.1.19"}},{key:"env",get:function(){return'"production"'}},{key:"config",get:function(){return G}},{key:"utils",get:function(){return X}},{key:"scheme",get:function(){return J}},{key:"Emitter",get:function(){return f}},{key:"validator",get:function(){return l}},{key:"kindOf",get:function(){return l.kindOf}},{key:"option",get:function(){return{container:"#artplayer",url:"",poster:"",title:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,localVideo:!1,localSubtitle:!1,autoPip:!1,networkMonitor:!1,layers:[],contextmenu:[],quality:[],controls:[],highlight:[],plugins:[],whitelist:[],thumbnails:{url:"",number:60,width:160,height:90,column:10},subtitle:{url:"",style:{}},moreVideoAttr:{controls:!1,preload:"metadata"},icons:{},customType:{},lang:navigator.language.toLowerCase()}}}]),r}(f);return Object.defineProperty(we,"instances",{value:[]}),console.log("%c ArtPlayer %c 3.1.19 %c https://artplayer.org","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),we})); diff --git a/packages/artplayer/dist/artplayer.js b/packages/artplayer/dist/artplayer.js index 714c4d3da..cc4b5a243 100644 --- a/packages/artplayer/dist/artplayer.js +++ b/packages/artplayer/dist/artplayer.js @@ -5,4 +5,4 @@ * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,(function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function e(t,e){for(var n=0;n1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:document).querySelector(t)}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(e.querySelectorAll(t))}function h(t,e){return t.classList.add(e)}function y(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function m(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function g(t,e,n){return t.style[e]=n,t}function b(t,e){return Object.keys(e).forEach((function(n){g(t,n,e[n])})),t}function w(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=window.getComputedStyle(t,null).getPropertyValue(e);return n?parseFloat(r):r}function O(t){return Array.from(t.parentElement.children).filter((function(e){return e!==t}))}function j(t,e){O(t).forEach((function(t){return y(t,e)})),h(t,e)}function P(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"up";t.setAttribute("aria-label",e),t.setAttribute("data-balloon-pos",n)}var x=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},k=r((function(t){function e(n,r,i){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}}()?t.exports=e=function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&s(i,n.prototype),i}:t.exports=e=Reflect.construct,e.apply(null,arguments)}t.exports=e})),E=function(e){function n(e,r){var i;return t(this,n),i=a(this,c(n).call(this,e)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),r||i.constructor),i.name="ArtPlayerError",i}return u(n,e),n}(r((function(t){function e(n){var r="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!x(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return k(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},e(n)}t.exports=e}))(Error));function S(t,e){if(!t)throw new E(e);return t}function $(t){return"WEBVTT \r\n\r\n".concat(t.replace(/{[\s\S]*?}/g,"").replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"))}function R(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function T(t){var e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(/[:.]/).map((function(t,e,n){if(e===n.length-1){if(1===t.length)return".".concat(t,"00");if(2===t.length)return".".concat(t,"0")}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===n.length-1?".".concat(t):":".concat(t)})).join("")}return"WEBVTT\n\n".concat(t.split(/\r?\n/).map((function(t){var r=t.match(e);return r?{start:n(r[1].trim()),end:n(r[2].trim()),text:r[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map((function(t){return t.trim()})).join("\n")}:null})).filter((function(t){return t})).map((function(t,e){return t?"".concat(e+1,"\n").concat(t.start," --\x3e ").concat(t.end,"\n").concat(t.text):""})).filter((function(t){return t.trim()})).join("\n\n"))}function D(t){return t.includes("?")?D(t.split("?")[0]):t.includes("#")?D(t.split("#")[0]):t.trim().toLowerCase().split(".").pop()}function C(t,e){var n=document.createElement("a");n.style.display="none",n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}var L=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e){return setTimeout(e,t)}))}function B(t,e,n){var r;function i(){for(var i=arguments.length,o=new Array(i),a=0;a0?[e,n,r]:[n,r]).map((function(t){return t<10?"0".concat(t):String(t)})).join(":")}var _=Object.freeze({__proto__:null,query:p,queryAll:d,addClass:h,removeClass:y,hasClass:v,append:m,remove:function(t){return t.parentNode.removeChild(t)},setStyle:g,setStyles:b,getStyle:w,sublings:O,inverseClass:j,tooltip:P,ArtPlayerError:E,errorHandle:S,srtToVtt:$,vttToBlob:R,assToVtt:T,getExt:D,downloadFile:C,hasOwnProperty:q,defineProperty:W,proxyPropertys:V,mergeDeep:F,sleep:H,debounce:B,throttle:I,clamp:N,secondToTime:U});function X(t,e,n){return S("string"===e||t instanceof Element,"".concat(n.join(".")," require 'string' or 'Element' type"))}var Y={container:X,url:"string|function",poster:"string",title:"string",theme:"string",lang:"string",volume:"number",isLive:"boolean",muted:"boolean",autoplay:"boolean",autoSize:"boolean",loop:"boolean",flip:"boolean",playbackRate:"boolean",aspectRatio:"boolean",screenshot:"boolean",setting:"boolean",hotkey:"boolean",pip:"boolean",mutex:"boolean",fullscreen:"boolean",fullscreenWeb:"boolean",subtitleOffset:"boolean",miniProgressBar:"boolean",localVideo:"boolean",localSubtitle:"boolean",autoPip:"boolean",networkMonitor:"boolean",plugins:["function"],whitelist:["string|function|regexp"],layers:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],contextmenu:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],quality:[{default:"boolean|undefined",name:"string",url:"string"}],controls:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:X,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined",position:function(t,e,n){var r=["top","left","right"];return S(r.includes(t),"".concat(n.join(".")," only accept ").concat(r.toString()," as parameters"))}}],highlight:[{time:"number",text:"string"}],thumbnails:{url:"string",number:"number",width:"number",height:"number",column:"number"},subtitle:{url:"string",style:"object"},moreVideoAttr:"object",icons:"object",customType:"object"},Z={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"]}},J=function e(n){var r=this;t(this,e);var i=n.constructor.kindOf,o=n.option.whitelist;this.userAgent=window.navigator.userAgent,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.userAgent),this.state=!this.isMobile||o.some((function(t){switch(i(t)){case"string":return r.userAgent.indexOf(t)>-1;case"function":return t(r.userAgent);case"regexp":return t.test(r.userAgent);default:return!1}}))},G=function(){function e(n){var r=this;t(this,e),this.art=n,n.option.container instanceof Element?this.$container=n.option.container:(this.$container=p(n.option.container),S(this.$container,"No container element found by ".concat(n.option.container))),S(n.constructor.instances.every((function(t){return t.template.$container!==r.$container})),"Cannot mount multiple instances on the same dom element"),S(this.$container.clientWidth&&this.$container.clientHeight,"The width and height of the container cannot be 0"),n.whitelist.state?this.initDesktop():this.initMobile()}return n(e,[{key:"query",value:function(t){return p(t,this.$container)}},{key:"initDesktop",value:function(){this.$container.innerHTML='\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
Player version:
\n
3.1.19
\n
\n
\n
Video url:
\n
\n
\n
\n
Video volume:
\n
\n
\n
\n
Video time:
\n
\n
\n
\n
Video duration:
\n
\n
\n
\n
Video resolution:
\n
\n x \n
\n
\n
\n
[x]
\n
\n
\n
\n
×
\n
\n
\n
\n '),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query(".art-video track"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$settingInner=this.query(".art-setting-inner"),this.$settingBody=this.query(".art-setting-body"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$pipHeader=this.query(".art-pip-header"),this.$pipTitle=this.query(".art-pip-title"),this.$pipClose=this.query(".art-pip-close"),this.$contextmenu=this.query(".art-contextmenus")}},{key:"initMobile",value:function(){this.$container.innerHTML='\n
\n \n
\n ',this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video")}},{key:"destroy",value:function(t){t?this.$container.innerHTML="":h(this.$player,"art-destroy")}}]),e}(),Q={"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Flip:"视频翻转",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕","Show setting":"显示设置","Hide setting":"隐藏设置",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常",Open:"打开","Switch video":"切换","Switch subtitle":"切换字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"网页全屏","Exit web fullscreen":"退出网页全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地视频","Subtitle offset time":"字幕偏移时间","No subtitles found":"未发现字幕"},K={"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Flip:"影片翻轉",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕","Show setting":"顯示设置","Hide setting":"隱藏设置",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常",Open:"打開","Switch video":"切換","Switch subtitle":"切換字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"網頁全屏","Exit web fullscreen":"退出網頁全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地視頻","Subtitle offset time":"字幕偏移時間","No subtitles found":"未發現字幕"},tt=function(){function e(n){t(this,e),this.art=n,this.languages={"zh-cn":Q,"zh-tw":K},this.init()}return n(e,[{key:"init",value:function(){var t=this.art.option.lang.toLowerCase();this.language=this.languages[t]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){this.languages=F(this.languages,t),this.init()}}]),e}();var et=r((function(t){!function(){var e="undefined"!=typeof window&&void 0!==window.document?window.document:{},n=t.exports,r=function(){for(var t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,o={};rh){var y=h*l/u;g(r,"width","".concat(100*y,"%")),g(r,"height","100%"),g(r,"padding","0 ".concat((f-f*y)/2,"px"))}else{var v=u/h/l;g(r,"width","100%"),g(r,"height","".concat(100*v,"%")),g(r,"padding","".concat((p-p*v)/2,"px 0"))}}i.dataset.aspectRatio=n,a.show("".concat(o.get("Aspect ratio"),": ").concat("default"===n?o.get("Default"):n)),t.emit("aspectRatioChange",n)}else e.aspectRatio&&(g(r,"width",null),g(r,"height",null),g(r,"padding",null),delete i.dataset.aspectRatio,t.emit("aspectRatioRemove"))}}),Object.defineProperty(e,"aspectRatioReset",{set:function(n){if(n&&e.aspectRatio){var r=e.aspectRatio;e.aspectRatio=r,t.emit("aspectRatioReset")}}})}(n,this),function(t,e){var n=t.option,r=t.notice,i=t.template.$video;Object.defineProperty(e,"getScreenshotDataURL",{value:function(){try{var t=document.createElement("canvas");return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),t.toDataURL("image/png")}catch(t){throw r.show(t),t}}}),Object.defineProperty(e,"getScreenshotBlobUrl",{value:function(){return new Promise((function(t,e){try{var n=document.createElement("canvas");n.width=i.videoWidth,n.height=i.videoHeight,n.getContext("2d").drawImage(i,0,0),n.toBlob((function(e){t(URL.createObjectURL(e))}))}catch(t){r.show(t),e(t)}}))}}),Object.defineProperty(e,"screenshot",{value:function(){var r=e.getScreenshotDataURL();r&&(C(r,"".concat(n.title||"artplayer","_").concat(U(i.currentTime),".png")),t.emit("screenshot",r))}})}(n,this),function(t,e){var n=t.i18n,r=t.notice,i=t.events.destroyEvents,o=t.template.$player,a=function(){t.emit("fullscreenChange",et.isFullscreen)},c=function(){r.show(n.get("Does not support fullscreen"))};e.fullscreenIsEnabled&&(et.on("change",a),et.on("error",c),i.push((function(){et.off("change",a),et.off("error",c)}))),Object.defineProperty(e,"fullscreen",{get:function(){return et.isFullscreen},set:function(n){e.fullscreenIsEnabled?n?(e.fullscreenWeb&&(e.fullscreenWeb=!1),et.request(o).then((function(){h(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenEnabled")}))):(e.fullscreenWeb&&(e.fullscreenWeb=!1),et.exit().then((function(){y(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenExit")}))):c()}}),Object.defineProperty(e,"fullscreenToggle",{set:function(t){t&&(e.fullscreen=!e.fullscreen)}}),Object.defineProperty(e,"fullscreenIsEnabled",{get:function(){return et.isEnabled}})}(n,this),function(t,e){var n=t.template.$player;Object.defineProperty(e,"fullscreenWeb",{get:function(){return v(n,"art-web-fullscreen")},set:function(r){r?(e.fullscreen&&(e.fullscreen=!1),h(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebEnabled")):(e.fullscreen&&(e.fullscreen=!1),y(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebExit"))}}),Object.defineProperty(e,"fullscreenWebToggle",{set:function(t){t&&(e.fullscreenWeb=!e.fullscreenWeb)}})}(n,this),nt(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"loaded",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1)/n.duration:0}}),Object.defineProperty(e,"loadedTime",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1):0}})}(n,this),function(t,e){Object.defineProperty(e,"played",{get:function(){return t.template.$video.currentTime/t.template.$video.duration}})}(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"playing",{get:function(){return!!(n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2)}})}(n,this),function(t,e){var n=t.template,r=n.$container,i=n.$player,o=n.$video;Object.defineProperty(e,"autoSize",{get:function(){return v(r,"art-auto-size")},set:function(n){if(n){var a=o.videoWidth,c=o.videoHeight,s=r.getBoundingClientRect(),u=s.width,l=s.height,f=a/c,p=u/l;if(h(r,"art-auto-size"),p>f){g(i,"width","".concat(l*f/u*100,"%")),g(i,"height","100%")}else{var d=u/f/l*100;g(i,"width","100%"),g(i,"height","".concat(d,"%"))}t.emit("autoSizeChange",{width:e.width,height:e.height})}else y(r,"art-auto-size"),g(i,"width",null),g(i,"height",null),t.emit("autoSizeRemove")}})}(n,this),function(t,e){Object.defineProperty(e,"rect",{get:function(){return t.template.$player.getBoundingClientRect()}}),["bottom","height","left","right","top","width"].forEach((function(t){Object.defineProperty(e,t,{get:function(){return e.rect[t]}})})),Object.defineProperty(e,"x",{get:function(){return e.left+window.pageXOffset}}),Object.defineProperty(e,"y",{get:function(){return e.top+window.pageYOffset}})}(n,this),function(t,e){Object.defineProperty(e,"flip",{get:function(){return t.template.$player.dataset.flip},set:function(e){if(e){var n=["normal","horizontal","vertical"];S(n.includes(e),"'flip' only accept ".concat(n.toString()," as parameters")),t.template.$player.dataset.flip=e,t.emit("flipChange",e)}else delete t.template.$player.dataset.flip,t.emit("flipRemove")}})}(n,this),V(n,this)};var it=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t},ot=r((function(t){function e(n,r,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,n){var r=it(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}},e(n,r,i||n)}t.exports=e})),at=function(){function e(n){t(this,e),this.id=0,this.art=n,this.add=this.add.bind(this),this.name=this.constructor.name.toLowerCase()}return n(e,[{key:"toggle",value:function(){this.show=!this.show}},{key:"add",value:function(t,e){var n=this,r="function"==typeof t?t(this.art):t;if(!this.$parent||r.disable)return{};this.id+=1;var i=r.name||"".concat(this.name).concat(this.id);S(!q(this,i),"Cannot add a component that already has the same name: ".concat(i));var o=document.createElement("div");o.classList.value="art-".concat(this.name," art-").concat(this.name,"-").concat(i),r.html&&m(o,r.html),r.style&&b(o,r.style),r.tooltip&&P(o,r.tooltip);var a=Array.from(this.$parent.children);o.dataset.index=r.index||this.id;var c=a.find((function(t){return Number(t.dataset.index)>=Number(o.dataset.index)}));return c?c.insertAdjacentElement("beforebegin",o):m(this.$parent,o),r.click&&this.art.events.proxy(o,"click",(function(t){t.preventDefault(),r.click.call(n.art,n,t)})),r.mounted&&r.mounted(o,this,this.art),e&&e(o,this,this.art),W(this,i,{value:{get $ref(){return o},set show(t){g(o,"display",t?"block":"none")}}}),this.art.emit("".concat(this.name,":add"),r),this[i]}},{key:"show",get:function(){return v(this.art.template.$player,"art-".concat(this.name,"-show"))},set:function(t){S(!1===t||!0===t,"The show attribute expects a boolean value");var e=this.art.template.$player,n="art-".concat(this.name,"-show");t?h(e,n):y(e,n),this.art.emit("".concat(this.name,":toggle"),t)}}]),e}();var ct=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};function st(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ut(t){return function(e){return function(t){for(var e=1;e\n
\n
\n
\n
\n
\n\n '),mounted:function(t){var n=!1,i=p(".art-progress-loaded",t),c=p(".art-progress-played",t),s=p(".art-progress-highlight",t),u=p(".art-progress-indicator",t),l=p(".art-progress-tip",t);function f(t,e){"loaded"===t&&g(i,"width","".concat(100*e,"%")),"played"===t&&(g(c,"width","".concat(100*e,"%")),g(u,"left","calc(".concat(100*e,"% - ").concat(w(u,"width")/2,"px)")))}r.forEach((function(t){var e=N(t.time,0,a.duration)/a.duration*100;m(s,''))})),f("loaded",a.loaded),e.on("video:progress",(function(){f("loaded",a.loaded)})),e.on("video:timeupdate",(function(){f("played",a.played)})),e.on("video:ended",(function(){f("played",1)})),o(t,"mousemove",(function(n){g(l,"display","block"),n.composedPath().indexOf(s)>-1?function(n){var r=mt(e,n).width,i=n.target.dataset.text;l.innerHTML=i;var o=l.clientWidth;r<=o/2?g(l,"left",0):r>t.clientWidth-o/2?g(l,"left","".concat(t.clientWidth-o,"px")):g(l,"left","".concat(r-o/2,"px"))}(n):function(n){var r=mt(e,n),i=r.width,o=r.time;l.innerHTML=o;var a=l.clientWidth;i<=a/2?g(l,"left",0):i>t.clientWidth-a/2?g(l,"left","".concat(t.clientWidth-a,"px")):g(l,"left","".concat(i-a/2,"px"))}(n)})),o(t,"mouseout",(function(){g(l,"display","none")})),o(t,"click",(function(t){if(t.target!==u){var n=mt(e,t),r=n.second;f("played",n.percentage),a.seek=r}})),o(u,"mousedown",(function(){n=!0})),o(document,"mousemove",(function(t){if(n){var r=mt(e,t),i=r.second,o=r.percentage;h(u,"art-show-indicator"),f("played",o),a.seek=i}})),o(document,"mouseup",(function(){n&&(n=!1,y(u,"art-show-indicator"))}))}})}}function bt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function wt(t){return function(e){return function(t){for(var e=1;e'),l=m(u,'
');function f(t){var e=u.getBoundingClientRect(),n=e.left,r=e.width,i=l.getBoundingClientRect().width;return N(t.pageX-n-i/2,0,r-i/2)/(r-i)}function p(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.7;if(i.muted||0===t)g(c,"display","none"),g(s,"display","flex"),g(l,"left","0");else{var e=((w(u,"width")||60)-w(l,"width"))*t;g(c,"display","flex"),g(s,"display","none"),g(l,"left","".concat(e,"px"))}}P(c,o.get("Mute")),g(s,"display","none"),p(i.volume),e.on("video:volumechange",(function(){p(i.volume)})),n(c,"click",(function(){i.muted=!0})),n(s,"click",(function(){i.muted=!1})),n(u,"click",(function(t){i.muted=!1,i.volume=f(t)})),n(l,"mousedown",(function(){a=!0})),n(document,"mousemove",(function(t){a&&(i.muted=!1,i.volume=f(t))})),n(document,"mouseup",(function(){a&&(a=!1)}))}})}}function kt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Et(t){return function(e){return function(t){for(var e=1;er.clientWidth-s/2?g(t,"left","".concat(r.clientWidth-s,"px")):g(t,"left","".concat(o-s/2,"px"))}(i))})),o(r,"mouseout",(function(){g(t,"display","none")}))}})}}function Rt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Tt(t){return function(e){return function(t){for(var e=1;e'.concat(s.name,"")),l=n.map((function(t,e){return'
').concat(t.name,"
")})).join(""),f=m(t,'
'.concat(l,"
"));o(t,(function(){f.style.left="-".concat(w(f,"width")/2-t.clientWidth/2,"px")})),i(f,"click",(function(t){var e=Number(t.target.dataset.index),r=n[e],i=r.url,o=r.name;i&&o&&c!==e&&(a.switchQuality(i,o),u.innerHTML=o,c=e)}))}})}}var Lt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.option;return e.on("ready",(function(){n.add(gt({name:"progress",disable:i.isLive,position:"top",index:10})),n.add($t({name:"thumbnails",disable:!i.thumbnails.url||i.isLive,position:"top",index:20})),n.add(yt({name:"playAndPause",disable:!1,position:"left",index:10})),n.add(xt({name:"volume",disable:!1,position:"left",index:20})),n.add(jt({name:"time",disable:i.isLive,position:"left",index:30})),n.add(Ct({name:"quality",disable:0===i.quality.length,position:"right",index:10})),n.add(Tt({name:"screenshot",disable:!i.screenshot,position:"right",index:20})),n.add(wt({name:"subtitle",disable:!i.subtitle.url,position:"right",index:30})),n.add(Et({name:"setting",disable:!i.setting,position:"right",index:40})),n.add(dt({name:"pip",disable:!i.pip,position:"right",index:50})),n.add(ft({name:"fullscreenWeb",disable:!i.fullscreenWeb,position:"right",index:60})),n.add(ut({name:"fullscreen",disable:!i.fullscreen,position:"right",index:70})),i.controls.forEach((function(t){n.add(t)}))})),n}return u(r,e),n(r,[{key:"add",value:function(t,e){var n="function"==typeof t?t(this.art):t;S(n.position,"Controls option.position can not be empty");var i=this.art.template,o=i.$progress,a=i.$controlsLeft,s=i.$controlsRight;switch(n.position){case"top":this.$parent=o;break;case"left":this.$parent=a;break;case"right":this.$parent=s}var u=ot(c(r.prototype),"add",this).call(this,n,e);return n.disable||"top"===n.position||u.$ref.firstElementChild&&"I"===u.$ref.firstElementChild.tagName||h(u.$ref,"art-control-onlyText"),u}}]),r}(at);function At(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Mt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e0.5\n0.75\n').concat(n.get("Normal"),'\n1.25\n1.5\n2.0\n '),click:function(t,e){var n=e.target.dataset.rate;n&&(r.playbackRate=Number(n),t.show=!1)},mounted:function(t){e.on("playbackRateChange",(function(e){var n=d("span",t).find((function(t){return Number(t.dataset.rate)===e}));n&&j(n,"art-current")}))}})}}function zt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function qt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e').concat(n.get("Default"),'\n4:3\n16:9\n '),click:function(t,e){var n=e.target.dataset.ratio;n&&(r.aspectRatio=n,t.show=!1)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("span",t).find((function(t){return t.dataset.ratio===e}));n&&j(n,"art-current")}))}})}}function Wt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Vt(t){return function(e){return function(t){for(var e=1;eArtPlayer 3.1.19'})}function Bt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function It(t){return function(e){return function(t){for(var e=1;ec+a&&(h=a-d),n+p>l+o&&(y=o-p),g(u,"left","".concat(h,"px")),g(u,"top","".concat(y,"px"))})),l(s,"click",(function(t){t.composedPath().includes(u)||(r.show=!1)})),e.on("blur",(function(){r.show=!1}))})),r}return u(n,e),n}(at),Ut=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.template,o=i.$infoPanel,s=i.$infoClose,u=i.$video;(0,e.events.proxy)(s,"click",(function(){r.show=!1}));var l=null,f=d("[data-video]",o);return e.on("destroy",(function(){clearTimeout(l)})),e.on("info:toggle",(function(t){clearTimeout(l),t&&function t(){f.forEach((function(t){var e=u[t.dataset.video];t.innerHTML="number"==typeof e?e.toFixed(2):e})),l=setTimeout((function(){t()}),1e3)}()})),r}return u(n,e),n}(at),_t=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.events.proxy,s=e.option.subtitle;return b(e.template.$subtitle,s.style),i(n.textTrack,"cuechange",n.update.bind(o(n))),s.url&&n.init(s.url),n}return u(r,e),n(r,[{key:"update",value:function(){var t=this.art.template.$subtitle;t.innerHTML="",this.activeCue&&(t.innerHTML=this.activeCue.text.split(/\r?\n/).map((function(t){return"

".concat(t,"

")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&o.show("".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),D(t)){case"srt":return R($(n));case"ass":return R(T(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show(t),e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(at);var Xt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.once("video:canplay",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=B((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Array.isArray(e)?e.forEach((function(e){return r.proxy(t,e,n,i)})):(t.addEventListener(e,n,i),this.destroyEvents.push((function(){t.removeEventListener(e,n,i)})))}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Zt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(at),Jt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(at),Gt=function(){function e(n){t(this,e),this.art=n,this.timer=null}return n(e,[{key:"show",value:function(t){var e=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=this.art.template,o=i.$player,a=i.$noticeInner;a.innerHTML=t instanceof Error?t.message.trim():t,clearTimeout(this.timer),n&&(this.timer=setTimeout((function(){e.hide()}),r)),h(o,"art-notice-show"),this.art.emit("notice:toggle",!0)}},{key:"hide",value:function(){var t=this.art.template,e=t.$player;t.$noticeInner.innerHTML="",y(e,"art-notice-show"),this.art.emit("notice:toggle",!0)}}]),e}(),Qt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(at),Kt=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'\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',state:'\n \n',play:'\n \n',pause:'\n \n',volume:'\n \n \n',volumeClose:'\n \n \n',subtitle:'\n \n \n',screenshot:'\n\t\n\n',setting:'\n \n \n',fullscreen:'\n\t\n\t\n\t\n\t\n',fullscreenWeb:'\n\t\n',pip:'\n \n',prev:'\n \n',next:'\n \n'},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function te(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ee(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Flip"),'\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n "),click:function(t,e){var n=e.target.dataset.value;n&&(r.flip=n)},mounted:function(t){e.on("flipChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ne(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function re(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Aspect ratio"),'\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n '),click:function(t,e){var n=e.target.dataset.value;n&&(r.aspectRatio=n)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ie(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function oe(t){return function(e){var n=e.i18n,r=e.player,i=e.events.proxy;return function(t){for(var e=1;e\n '.concat(n.get("Play speed"),': 1.0x\n\n
\n \n
\n '),mounted:function(t){var n=p(".art-setting-range input",t),o=p(".art-subtitle-value",t);i(n,"change",(function(){var t=n.value;o.innerText=t,r.playbackRate=Number(t)})),e.on("playbackRateChange",(function(t){n.value!==t&&(n.value=t,o.innerText=t)}))}})}}var ae=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.option,o=e.template,s=o.$setting,u=o.$settingBody,l=e.events.proxy;return r.$parent=u,i.setting&&(e.on("ready",(function(){l(s,"click",(function(t){t.target===s&&(r.show=!1)})),r.add(ee({disable:!i.flip,name:"flip"})),r.add(re({disable:!i.aspectRatio,name:"aspectRatio"})),r.add(oe({disable:!i.playbackRate,name:"playbackRate"}))})),e.on("blur",(function(){r.show=!1}))),r}return u(n,e),n}(at),ce=function(){function e(n){t(this,e),this.art=n,this.name="artplayer_settings";var r=n.option,i=this.get("volume");i&&(r.volume=i)}return n(e,[{key:"get",value:function(t){var e=JSON.parse(window.localStorage.getItem(this.name))||{};return t?e[t]:{}}},{key:"set",value:function(t,e){var n=Object.assign({},this.get(),ct({},t,e));window.localStorage.setItem(this.name,JSON.stringify(n))}},{key:"del",value:function(t){var e=this.get();delete e[t],window.localStorage.setItem(this.name,JSON.stringify(e))}},{key:"clean",value:function(){window.localStorage.removeItem(this.name)}}]),e}();function se(t){var e=t.i18n,n=t.subtitle,r=t.events.proxy;return{title:"Subtitle",name:"subtitleOffset",index:20,html:'\n
\n '.concat(e.get("Subtitle offset time"),': 0s\n
\n
\n \n
\n '),mounted:function(e){var i=p(".art-setting-range input",e),o=p(".art-subtitle-value",e);r(i,"change",(function(){var e=i.value;o.innerText=e,t.plugins.subtitleOffset.offset(Number(e))})),t.on("subtitle:switch",(function(){i.value=0,o.innerText=0})),t.on("subtitleOffset",(function(t){n.update(),i.value!==t&&(i.value=t,o.innerText=t)}))}}}function ue(t){var e=t.constructor.utils.clamp,n=t.setting,r=t.notice,i=t.template,o=t.i18n,a=t.player;n.add(se);var c=[];return t.on("subtitle:switch",(function(){c=[]})),{name:"subtitleOffset",offset:function(n){if(i.$track&&i.$track.track){var s=Array.from(i.$track.track.cues),u=e(n,-5,5);s.forEach((function(t,n){c[n]||(c[n]={startTime:t.startTime,endTime:t.endTime}),t.startTime=e(c[n].startTime+u,0,a.duration),t.endTime=e(c[n].endTime+u,0,a.duration)})),r.show("".concat(o.get("Subtitle offset time"),": ").concat(n,"s")),t.emit("subtitleOffset",n)}else r.show("".concat(o.get("No subtitles found"))),t.emit("subtitleOffset",0)}}}function le(t){var e=t.events.proxy,n=t.template,r=t.player,i=t.option,o=t.setting,a=t.i18n;function c(e){if(e){var o=n.$video.canPlayType(e.type);if("maybe"===o||"probably"===o){var a=URL.createObjectURL(e);i.title=e.name,r.switchUrl(a,e.name),t.emit("localVideo",e)}else S(!1,"Playback of this file format is not supported")}}function s(t){var n=m(t,'');g(t,"position","relative"),b(n,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(n,"change",(function(){c(n.files[0])}))}return e(n.$player,"dragover",(function(t){t.preventDefault()})),e(n.$player,"drop",(function(t){t.preventDefault(),c(t.dataTransfer.files[0])})),t.on("ready",(function(){o.add({title:"Local Video",name:"localVideo",index:30,html:'\n
\n '.concat(a.get("Local Video"),'\n
\n
\n
').concat(a.get("Open"),'
\n
\n
\n '),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localVideo",(function(t){r.textContent=t.name,r.title=t.name})),s(n)}})})),{name:"localVideo",attach:s}}function fe(t){var e=t.events.proxy,n=t.subtitle,r=t.setting,i=t.i18n;function o(r){var i=m(r,'');g(r,"position","relative"),b(i,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(i,"change",(function(){!function(r){if(r){var i=D(r.name);if(["ass","vtt","srt"].includes(i)){var o=new FileReader;e(o,"load",(function(e){var o=e.target.result;switch(i){case"srt":var a=R($(o));n.switch(a,r.name);break;case"ass":var c=R(T(o));n.switch(c,r.name);break;case"vtt":var s=R(o);n.switch(s,r.name)}t.emit("localSubtitle",r)})),o.readAsText(r)}else S(!1,"Only supports subtitle files in .ass, .vtt and .srt format")}}(i.files[0])}))}return t.on("ready",(function(){r.add({title:"Local Subtitle",name:"localSubtitle",index:40,html:'\n
\n '.concat(i.get("Local Subtitle"),'\n
\n
\n
').concat(i.get("Open"),'
\n
\n
\n '),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localSubtitle",(function(t){r.textContent=t.name,r.title=t.name})),o(n)}})})),{name:"localSubtitle",attach:o}}function pe(t){var e=t.layers,n=t.player,r=t.option.theme;return e.add({name:"miniProgressBar",style:{display:"none",position:"absolute",left:0,right:0,bottom:0,height:"2px",background:r},mounted:function(e){t.on("control:toggle",(function(t){e.style.display=t?"none":"block"})),t.on("destroy",(function(){e.style.display="none"})),t.on("video:timeupdate",(function(){e.style.width="".concat(100*n.played,"%")}))}}),{name:"miniProgressBar"}}function de(t){var e=1e4,n=0,r=0,i=0,o=null;function a(){n=0,r=0,i=0,cancelAnimationFrame(o),o=null}function c(){o||function a(){t.isDestroy||(o=requestAnimationFrame((function(){var o=Date.now();if(i){var c=o-i;r+=c,t.player.playing||(n+=c)}i=o,t.emit("networkMonitor",n/r),r>=e&&(n=0,r=0),a()})))}()}return t.on("play",c),t.on("pause",a),{name:"networkMonitor",reset:a,start:c,sample:function(t){e=t}}}function he(t){var e=t.events,n=t.player,r=t.template,i=B((function(){var e=r.$player.getBoundingClientRect();e.top+e.height<=0&&!n.pip?(n.pip=!0,t.emit("autoPip",!0)):n.pip&&(n.pip=!1,t.emit("autoPip",!1))}),300);return e.proxy(window,"scroll",i),{name:"autoPip"}}var ye=function(){function e(n){var r=this;t(this,e),this.art=n,this.id=0;var i=n.option;i.subtitle.url&&i.subtitleOffset&&this.add(ue),!i.isLive&&i.miniProgressBar&&this.add(pe),i.localVideo&&this.add(le),i.localSubtitle&&this.add(fe),i.networkMonitor&&this.add(de),i.autoPip&&this.add(he),n.option.plugins.forEach((function(t){r.add(t)}))}return n(e,[{key:"add",value:function(t){this.id+=1;var e=t.call(this,this.art),n="";return S(!q(this,n=e&&e.name?e.name:t.name?t.name:"plugin".concat(this.id)),"Cannot add a plugin that already has the same name: ".concat(n)),Object.defineProperty(this,n,{value:e}),this.art.emit("plugin:add",t),this}}]),e}(),ve=function e(n){t(this,e);var r=n.option,i=n.events.proxy,o=n.template.$video;Z.video.events.forEach((function(t){i(o,t,(function(t){n.emit("video:".concat(t.type),t)}))})),Object.keys(r.moreVideoAttr).forEach((function(t){o[t]=r.moreVideoAttr[t]})),r.muted&&(o.muted=r.muted),r.volume&&(o.volume=N(r.volume,0,1)),r.poster&&(o.poster=r.poster),r.autoplay&&(o.autoplay=r.autoplay),o.controls=!0;var a=r.type||D(r.url),c=r.customType[a];a&&c?(n.emit("beforeCustomType",a),c(o,r.url,n),n.emit("afterCustomType",a)):(n.emit("beforeAttachUrl",r.url),o.src=r.url,n.emit("afterAttachUrl",o.src))},me=0,ge=function(e){function r(e){var n;return t(this,r),(n=a(this,c(r).call(this))).option=l(F(r.option,e),Y),n.isFocus=!1,n.isDestroy=!1,n.whitelist=new J(o(n)),n.template=new G(o(n)),n.events=new Xt(o(n)),n.whitelist.state?(n.storage=new ce(o(n)),n.icons=new Kt(o(n)),n.i18n=new tt(o(n)),n.notice=new Gt(o(n)),n.player=new rt(o(n)),n.layers=new Zt(o(n)),n.controls=new Lt(o(n)),n.contextmenu=new Nt(o(n)),n.subtitle=new _t(o(n)),n.info=new Ut(o(n)),n.loading=new Jt(o(n)),n.hotkey=new Yt(o(n)),n.mask=new Qt(o(n)),n.setting=new ae(o(n)),n.plugins=new ye(o(n))):n.mobile=new ve(o(n)),me+=1,n.id=me,r.instances.push(o(n)),n}return u(r,e),n(r,[{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.events.destroy(),this.template.destroy(t),r.instances.splice(r.instances.indexOf(this),1),this.isDestroy=!0,this.emit("destroy")}}],[{key:"version",get:function(){return"3.1.19"}},{key:"env",get:function(){return'"production"'}},{key:"config",get:function(){return Z}},{key:"utils",get:function(){return _}},{key:"scheme",get:function(){return Y}},{key:"Emitter",get:function(){return f}},{key:"validator",get:function(){return l}},{key:"kindOf",get:function(){return l.kindOf}},{key:"option",get:function(){return{container:"#artplayer",url:"",poster:"",title:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,localVideo:!1,localSubtitle:!1,autoPip:!1,networkMonitor:!1,layers:[],contextmenu:[],quality:[],controls:[],highlight:[],plugins:[],whitelist:[],thumbnails:{url:"",number:60,width:160,height:90,column:10},subtitle:{url:"",style:{}},moreVideoAttr:{controls:!1,preload:"metadata"},icons:{},customType:{},lang:navigator.language.toLowerCase()}}}]),r}(f);return Object.defineProperty(ge,"instances",{value:[]}),console.log("%c ArtPlayer %c 3.1.19 %c https://artplayer.org","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),ge})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Artplayer=e()}(this,(function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function e(t,e){for(var n=0;n1?n-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:document).querySelector(t)}function d(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.from(e.querySelectorAll(t))}function h(t,e){return t.classList.add(e)}function y(t,e){return t.classList.remove(e)}function v(t,e){return t.classList.contains(e)}function m(t,e){return e instanceof Element?t.appendChild(e):t.insertAdjacentHTML("beforeend",String(e)),t.lastElementChild||t.lastChild}function g(t,e,n){return t.style[e]=n,t}function b(t,e){return Object.keys(e).forEach((function(n){g(t,n,e[n])})),t}function w(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=window.getComputedStyle(t,null).getPropertyValue(e);return n?parseFloat(r):r}function O(t){return Array.from(t.parentElement.children).filter((function(e){return e!==t}))}function j(t,e){O(t).forEach((function(t){return y(t,e)})),h(t,e)}function P(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"up";t.setAttribute("aria-label",e),t.setAttribute("data-balloon-pos",n)}var x=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")},k=r((function(t){function e(n,r,i){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}}()?t.exports=e=function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&s(i,n.prototype),i}:t.exports=e=Reflect.construct,e.apply(null,arguments)}t.exports=e})),E=function(e){function n(e,r){var i;return t(this,n),i=a(this,c(n).call(this,e)),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),r||i.constructor),i.name="ArtPlayerError",i}return u(n,e),n}(r((function(t){function e(n){var r="function"==typeof Map?new Map:void 0;return t.exports=e=function(t){if(null===t||!x(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return k(t,arguments,c(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),s(e,t)},e(n)}t.exports=e}))(Error));function S(t,e){if(!t)throw new E(e);return t}function $(t){return"WEBVTT \r\n\r\n".concat(t.replace(/{[\s\S]*?}/g,"").replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"))}function R(t){return URL.createObjectURL(new Blob([t],{type:"text/vtt"}))}function D(t){var e=new RegExp("Dialogue:\\s\\d,(\\d+:\\d\\d:\\d\\d.\\d\\d),(\\d+:\\d\\d:\\d\\d.\\d\\d),([^,]*),([^,]*),(?:[^,]*,){4}([\\s\\S]*)$","i");function n(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(/[:.]/).map((function(t,e,n){if(e===n.length-1){if(1===t.length)return".".concat(t,"00");if(2===t.length)return".".concat(t,"0")}else if(1===t.length)return(0===e?"0":":0")+t;return 0===e?t:e===n.length-1?".".concat(t):":".concat(t)})).join("")}return"WEBVTT\n\n".concat(t.split(/\r?\n/).map((function(t){var r=t.match(e);return r?{start:n(r[1].trim()),end:n(r[2].trim()),text:r[5].replace(/{[\s\S]*?}/g,"").replace(/(\\N)/g,"\n").trim().split(/\r?\n/).map((function(t){return t.trim()})).join("\n")}:null})).filter((function(t){return t})).map((function(t,e){return t?"".concat(e+1,"\n").concat(t.start," --\x3e ").concat(t.end,"\n").concat(t.text):""})).filter((function(t){return t.trim()})).join("\n\n"))}function T(t){return t.includes("?")?T(t.split("?")[0]):t.includes("#")?T(t.split("#")[0]):t.trim().toLowerCase().split(".").pop()}function C(t,e){var n=document.createElement("a");n.style.display="none",n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}var L=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e1?e-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(e){return setTimeout(e,t)}))}function N(t,e,n){var r;function i(){for(var i=arguments.length,o=new Array(i),a=0;a0?[e,n,r]:[n,r]).map((function(t){return t<10?"0".concat(t):String(t)})).join(":")}var X=Object.freeze({__proto__:null,query:p,queryAll:d,addClass:h,removeClass:y,hasClass:v,append:m,remove:function(t){return t.parentNode.removeChild(t)},setStyle:g,setStyles:b,getStyle:w,sublings:O,inverseClass:j,tooltip:P,ArtPlayerError:E,errorHandle:S,srtToVtt:$,vttToBlob:R,assToVtt:D,getExt:T,downloadFile:C,hasOwnProperty:W,defineProperty:F,proxyPropertys:H,mergeDeep:B,sleep:I,debounce:N,throttle:U,clamp:_,secondToTime:Y});function Z(t,e,n){return S("string"===e||t instanceof Element,"".concat(n.join(".")," require 'string' or 'Element' type"))}var J={container:Z,url:"string|function",poster:"string",title:"string",theme:"string",lang:"string",volume:"number",isLive:"boolean",muted:"boolean",autoplay:"boolean",autoSize:"boolean",loop:"boolean",flip:"boolean",playbackRate:"boolean",aspectRatio:"boolean",screenshot:"boolean",setting:"boolean",hotkey:"boolean",pip:"boolean",mutex:"boolean",fullscreen:"boolean",fullscreenWeb:"boolean",subtitleOffset:"boolean",miniProgressBar:"boolean",localVideo:"boolean",localSubtitle:"boolean",autoPip:"boolean",networkMonitor:"boolean",plugins:["function"],whitelist:["string|function|regexp"],layers:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],contextmenu:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined"}],quality:[{default:"boolean|undefined",name:"string",url:"string"}],controls:[{disable:"boolean|undefined",name:"string|undefined",index:"number|undefined",html:Z,style:"object|undefined",click:"function|undefined",mounted:"function|undefined",tooltip:"string|undefined",position:function(t,e,n){var r=["top","left","right"];return S(r.includes(t),"".concat(n.join(".")," only accept ").concat(r.toString()," as parameters"))}}],highlight:[{time:"number",text:"string"}],thumbnails:{url:"string",number:"number",width:"number",height:"number",column:"number"},subtitle:{url:"string",style:"object"},moreVideoAttr:"object",icons:"object",customType:"object"},G={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"]}},K=function e(n){var r=this;t(this,e);var i=n.constructor.kindOf,o=n.option.whitelist;this.userAgent=window.navigator.userAgent,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.userAgent),this.state=!this.isMobile||o.some((function(t){switch(i(t)){case"string":return r.userAgent.indexOf(t)>-1;case"function":return t(r.userAgent);case"regexp":return t.test(r.userAgent);default:return!1}}))},Q=function(){function e(n){var r=this;t(this,e),this.art=n,n.option.container instanceof Element?this.$container=n.option.container:(this.$container=p(n.option.container),S(this.$container,"No container element found by ".concat(n.option.container))),S(n.constructor.instances.every((function(t){return t.template.$container!==r.$container})),"Cannot mount multiple instances on the same dom element"),S(this.$container.clientWidth&&this.$container.clientHeight,"The width and height of the container cannot be 0"),n.whitelist.state?this.initDesktop():this.initMobile()}return n(e,[{key:"query",value:function(t){return p(t,this.$container)}},{key:"initDesktop",value:function(){this.$container.innerHTML='\n
Player version:
3.1.19
Video url:
Video volume:
Video time:
Video duration:
Video resolution:
x
[x]
×
\n
'),this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video"),this.$track=this.query(".art-video track"),this.$subtitle=this.query(".art-subtitle"),this.$danmuku=this.query(".art-danmuku"),this.$bottom=this.query(".art-bottom"),this.$progress=this.query(".art-progress"),this.$controls=this.query(".art-controls"),this.$controlsLeft=this.query(".art-controls-left"),this.$controlsRight=this.query(".art-controls-right"),this.$layer=this.query(".art-layers"),this.$loading=this.query(".art-loading"),this.$notice=this.query(".art-notice"),this.$noticeInner=this.query(".art-notice-inner"),this.$mask=this.query(".art-mask"),this.$state=this.query(".art-state"),this.$setting=this.query(".art-settings"),this.$settingInner=this.query(".art-setting-inner"),this.$settingBody=this.query(".art-setting-body"),this.$info=this.query(".art-info"),this.$infoPanel=this.query(".art-info-panel"),this.$infoClose=this.query(".art-info-close"),this.$pipHeader=this.query(".art-pip-header"),this.$pipTitle=this.query(".art-pip-title"),this.$pipClose=this.query(".art-pip-close"),this.$contextmenu=this.query(".art-contextmenus")}},{key:"initMobile",value:function(){this.$container.innerHTML='\n
\n
',this.$player=this.query(".art-video-player"),this.$video=this.query(".art-video")}},{key:"destroy",value:function(t){t?this.$container.innerHTML="":h(this.$player,"art-destroy")}}]),e}(),tt={"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Flip:"视频翻转",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕","Show setting":"显示设置","Hide setting":"隐藏设置",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常",Open:"打开","Switch video":"切换","Switch subtitle":"切换字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"网页全屏","Exit web fullscreen":"退出网页全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地视频","Subtitle offset time":"字幕偏移时间","No subtitles found":"未发现字幕"},et={"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Flip:"影片翻轉",Horizontal:"水平",Vertical:"垂直",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕","Show setting":"顯示设置","Hide setting":"隱藏设置",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常",Open:"打開","Switch video":"切換","Switch subtitle":"切換字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"網頁全屏","Exit web fullscreen":"退出網頁全屏","Mini player":"迷你播放器","Does not support fullscreen":"不支持全屏","Local Subtitle":"本地字幕","Local Video":"本地視頻","Subtitle offset time":"字幕偏移時間","No subtitles found":"未發現字幕"},nt=function(){function e(n){t(this,e),this.art=n,this.languages={"zh-cn":tt,"zh-tw":et},this.init()}return n(e,[{key:"init",value:function(){var t=this.art.option.lang.toLowerCase();this.language=this.languages[t]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){this.languages=B(this.languages,t),this.init()}}]),e}();var rt=r((function(t){!function(){var e="undefined"!=typeof window&&void 0!==window.document?window.document:{},n=t.exports,r="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,i=function(){for(var t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],r=0,i=n.length,o={};rh){var y=h*l/u;g(r,"width","".concat(100*y,"%")),g(r,"height","100%"),g(r,"padding","0 ".concat((f-f*y)/2,"px"))}else{var v=u/h/l;g(r,"width","100%"),g(r,"height","".concat(100*v,"%")),g(r,"padding","".concat((p-p*v)/2,"px 0"))}}i.dataset.aspectRatio=n,a.show("".concat(o.get("Aspect ratio"),": ").concat("default"===n?o.get("Default"):n)),t.emit("aspectRatioChange",n)}else e.aspectRatio&&(g(r,"width",null),g(r,"height",null),g(r,"padding",null),delete i.dataset.aspectRatio,t.emit("aspectRatioRemove"))}}),Object.defineProperty(e,"aspectRatioReset",{set:function(n){if(n&&e.aspectRatio){var r=e.aspectRatio;e.aspectRatio=r,t.emit("aspectRatioReset")}}})}(n,this),function(t,e){var n=t.option,r=t.notice,i=t.template.$video;Object.defineProperty(e,"getScreenshotDataURL",{value:function(){try{var t=document.createElement("canvas");return t.width=i.videoWidth,t.height=i.videoHeight,t.getContext("2d").drawImage(i,0,0),t.toDataURL("image/png")}catch(t){throw r.show(t),t}}}),Object.defineProperty(e,"getScreenshotBlobUrl",{value:function(){return new Promise((function(t,e){try{var n=document.createElement("canvas");n.width=i.videoWidth,n.height=i.videoHeight,n.getContext("2d").drawImage(i,0,0),n.toBlob((function(e){t(URL.createObjectURL(e))}))}catch(t){r.show(t),e(t)}}))}}),Object.defineProperty(e,"screenshot",{value:function(){var r=e.getScreenshotDataURL();r&&(C(r,"".concat(n.title||"artplayer","_").concat(Y(i.currentTime),".png")),t.emit("screenshot",r))}})}(n,this),function(t,e){var n=t.i18n,r=t.notice,i=t.events.destroyEvents,o=t.template.$player,a=function(){t.emit("fullscreenChange",rt.isFullscreen)},c=function(){r.show(n.get("Does not support fullscreen"))};e.fullscreenIsEnabled&&(rt.on("change",a),rt.on("error",c),i.push((function(){rt.off("change",a),rt.off("error",c)}))),Object.defineProperty(e,"fullscreen",{get:function(){return rt.isFullscreen},set:function(n){e.fullscreenIsEnabled?n?(e.fullscreenWeb&&(e.fullscreenWeb=!1),rt.request(o).then((function(){h(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenEnabled")}))):(e.fullscreenWeb&&(e.fullscreenWeb=!1),rt.exit().then((function(){y(o,"art-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenExit")}))):c()}}),Object.defineProperty(e,"fullscreenToggle",{set:function(t){t&&(e.fullscreen=!e.fullscreen)}}),Object.defineProperty(e,"fullscreenIsEnabled",{get:function(){return rt.isEnabled}})}(n,this),function(t,e){var n=t.template.$player;Object.defineProperty(e,"fullscreenWeb",{get:function(){return v(n,"art-web-fullscreen")},set:function(r){r?(e.fullscreen&&(e.fullscreen=!1),h(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebEnabled")):(e.fullscreen&&(e.fullscreen=!1),y(n,"art-web-fullscreen"),e.aspectRatioReset=!0,t.emit("fullscreenWebExit"))}}),Object.defineProperty(e,"fullscreenWebToggle",{set:function(t){t&&(e.fullscreenWeb=!e.fullscreenWeb)}})}(n,this),it(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"loaded",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1)/n.duration:0}}),Object.defineProperty(e,"loadedTime",{get:function(){return n.buffered.length?n.buffered.end(n.buffered.length-1):0}})}(n,this),function(t,e){Object.defineProperty(e,"played",{get:function(){return t.template.$video.currentTime/t.template.$video.duration}})}(n,this),function(t,e){var n=t.template.$video;Object.defineProperty(e,"playing",{get:function(){return!!(n.currentTime>0&&!n.paused&&!n.ended&&n.readyState>2)}})}(n,this),function(t,e){var n=t.template,r=n.$container,i=n.$player,o=n.$video;Object.defineProperty(e,"autoSize",{get:function(){return v(r,"art-auto-size")},set:function(n){if(n){var a=o.videoWidth,c=o.videoHeight,s=r.getBoundingClientRect(),u=s.width,l=s.height,f=a/c,p=u/l;if(h(r,"art-auto-size"),p>f){g(i,"width","".concat(l*f/u*100,"%")),g(i,"height","100%")}else{var d=u/f/l*100;g(i,"width","100%"),g(i,"height","".concat(d,"%"))}t.emit("autoSizeChange",{width:e.width,height:e.height})}else y(r,"art-auto-size"),g(i,"width",null),g(i,"height",null),t.emit("autoSizeRemove")}})}(n,this),function(t,e){Object.defineProperty(e,"rect",{get:function(){return t.template.$player.getBoundingClientRect()}}),["bottom","height","left","right","top","width"].forEach((function(t){Object.defineProperty(e,t,{get:function(){return e.rect[t]}})})),Object.defineProperty(e,"x",{get:function(){return e.left+window.pageXOffset}}),Object.defineProperty(e,"y",{get:function(){return e.top+window.pageYOffset}})}(n,this),function(t,e){Object.defineProperty(e,"flip",{get:function(){return t.template.$player.dataset.flip},set:function(e){if(e){var n=["normal","horizontal","vertical"];S(n.includes(e),"'flip' only accept ".concat(n.toString()," as parameters")),t.template.$player.dataset.flip=e,t.emit("flipChange",e)}else delete t.template.$player.dataset.flip,t.emit("flipRemove")}})}(n,this),H(n,this)};var at=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t},ct=r((function(t){function e(n,r,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=e=Reflect.get:t.exports=e=function(t,e,n){var r=at(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}},e(n,r,i||n)}t.exports=e})),st=function(){function e(n){t(this,e),this.id=0,this.art=n,this.add=this.add.bind(this),this.name=this.constructor.name.toLowerCase()}return n(e,[{key:"toggle",value:function(){this.show=!this.show}},{key:"add",value:function(t,e){var n=this,r="function"==typeof t?t(this.art):t;if(!this.$parent||r.disable)return{};this.id+=1;var i=r.name||"".concat(this.name).concat(this.id);S(!W(this,i),"Cannot add a component that already has the same name: ".concat(i));var o=document.createElement("div");o.classList.value="art-".concat(this.name," art-").concat(this.name,"-").concat(i),r.html&&m(o,r.html),r.style&&b(o,r.style),r.tooltip&&P(o,r.tooltip);var a=Array.from(this.$parent.children);o.dataset.index=r.index||this.id;var c=a.find((function(t){return Number(t.dataset.index)>=Number(o.dataset.index)}));return c?c.insertAdjacentElement("beforebegin",o):m(this.$parent,o),r.click&&this.art.events.proxy(o,"click",(function(t){t.preventDefault(),r.click.call(n.art,n,t)})),r.mounted&&r.mounted(o,this,this.art),e&&e(o,this,this.art),F(this,i,{value:{get $ref(){return o},set show(t){g(o,"display",t?"block":"none")}}}),this.art.emit("".concat(this.name,":add"),r),this[i]}},{key:"show",get:function(){return v(this.art.template.$player,"art-".concat(this.name,"-show"))},set:function(t){S(!1===t||!0===t,"The show attribute expects a boolean value");var e=this.art.template.$player,n="art-".concat(this.name,"-show");t?h(e,n):y(e,n),this.art.emit("".concat(this.name,":toggle"),t)}}]),e}();var ut=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};function lt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ft(t){return function(e){return function(t){for(var e=1;e
\n'),mounted:function(t){var n=!1,i=p(".art-progress-loaded",t),c=p(".art-progress-played",t),s=p(".art-progress-highlight",t),u=p(".art-progress-indicator",t),l=p(".art-progress-tip",t);function f(t,e){"loaded"===t&&g(i,"width","".concat(100*e,"%")),"played"===t&&(g(c,"width","".concat(100*e,"%")),g(u,"left","calc(".concat(100*e,"% - ").concat(w(u,"width")/2,"px)")))}r.forEach((function(t){var e=_(t.time,0,a.duration)/a.duration*100;m(s,''))})),f("loaded",a.loaded),e.on("video:progress",(function(){f("loaded",a.loaded)})),e.on("video:timeupdate",(function(){f("played",a.played)})),e.on("video:ended",(function(){f("played",1)})),o(t,"mousemove",(function(n){g(l,"display","block"),n.composedPath().indexOf(s)>-1?function(n){var r=bt(e,n).width,i=n.target.dataset.text;l.innerHTML=i;var o=l.clientWidth;r<=o/2?g(l,"left",0):r>t.clientWidth-o/2?g(l,"left","".concat(t.clientWidth-o,"px")):g(l,"left","".concat(r-o/2,"px"))}(n):function(n){var r=bt(e,n),i=r.width,o=r.time;l.innerHTML=o;var a=l.clientWidth;i<=a/2?g(l,"left",0):i>t.clientWidth-a/2?g(l,"left","".concat(t.clientWidth-a,"px")):g(l,"left","".concat(i-a/2,"px"))}(n)})),o(t,"mouseout",(function(){g(l,"display","none")})),o(t,"click",(function(t){if(t.target!==u){var n=bt(e,t),r=n.second;f("played",n.percentage),a.seek=r}})),o(u,"mousedown",(function(){n=!0})),o(document,"mousemove",(function(t){if(n){var r=bt(e,t),i=r.second,o=r.percentage;h(u,"art-show-indicator"),f("played",o),a.seek=i}})),o(document,"mouseup",(function(){n&&(n=!1,y(u,"art-show-indicator"))}))}})}}function Ot(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function jt(t){return function(e){return function(t){for(var e=1;e'),l=m(u,'
');function f(t){var e=u.getBoundingClientRect(),n=e.left,r=e.width,i=l.getBoundingClientRect().width;return _(t.pageX-n-i/2,0,r-i/2)/(r-i)}function p(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.7;if(i.muted||0===t)g(c,"display","none"),g(s,"display","flex"),g(l,"left","0");else{var e=((w(u,"width")||60)-w(l,"width"))*t;g(c,"display","flex"),g(s,"display","none"),g(l,"left","".concat(e,"px"))}}P(c,o.get("Mute")),g(s,"display","none"),p(i.volume),e.on("video:volumechange",(function(){p(i.volume)})),n(c,"click",(function(){i.muted=!0})),n(s,"click",(function(){i.muted=!1})),n(u,"click",(function(t){i.muted=!1,i.volume=f(t)})),n(l,"mousedown",(function(){a=!0})),n(document,"mousemove",(function(t){a&&(i.muted=!1,i.volume=f(t))})),n(document,"mouseup",(function(){a&&(a=!1)}))}})}}function St(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function $t(t){return function(e){return function(t){for(var e=1;er.clientWidth-s/2?g(t,"left","".concat(r.clientWidth-s,"px")):g(t,"left","".concat(o-s/2,"px"))}(i))})),o(r,"mouseout",(function(){g(t,"display","none")}))}})}}function Tt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ct(t){return function(e){return function(t){for(var e=1;e'.concat(s.name,"")),l=n.map((function(t,e){return'
').concat(t.name,"
")})).join(""),f=m(t,'
'.concat(l,"
"));o(t,(function(){f.style.left="-".concat(w(f,"width")/2-t.clientWidth/2,"px")})),i(f,"click",(function(t){var e=Number(t.target.dataset.index),r=n[e],i=r.url,o=r.name;i&&o&&c!==e&&(a.switchQuality(i,o),u.innerHTML=o,c=e)}))}})}}var Mt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.option;return e.on("ready",(function(){n.add(wt({name:"progress",disable:i.isLive,position:"top",index:10})),n.add(Dt({name:"thumbnails",disable:!i.thumbnails.url||i.isLive,position:"top",index:20})),n.add(mt({name:"playAndPause",disable:!1,position:"left",index:10})),n.add(Et({name:"volume",disable:!1,position:"left",index:20})),n.add(xt({name:"time",disable:i.isLive,position:"left",index:30})),n.add(At({name:"quality",disable:0===i.quality.length,position:"right",index:10})),n.add(Ct({name:"screenshot",disable:!i.screenshot,position:"right",index:20})),n.add(jt({name:"subtitle",disable:!i.subtitle.url,position:"right",index:30})),n.add($t({name:"setting",disable:!i.setting,position:"right",index:40})),n.add(yt({name:"pip",disable:!i.pip,position:"right",index:50})),n.add(dt({name:"fullscreenWeb",disable:!i.fullscreenWeb,position:"right",index:60})),n.add(ft({name:"fullscreen",disable:!i.fullscreen,position:"right",index:70})),i.controls.forEach((function(t){n.add(t)}))})),n}return u(r,e),n(r,[{key:"add",value:function(t,e){var n="function"==typeof t?t(this.art):t;S(n.position,"Controls option.position can not be empty");var i=this.art.template,o=i.$progress,a=i.$controlsLeft,s=i.$controlsRight;switch(n.position){case"top":this.$parent=o;break;case"left":this.$parent=a;break;case"right":this.$parent=s}var u=ct(c(r.prototype),"add",this).call(this,n,e);return n.disable||"top"===n.position||u.$ref.firstElementChild&&"I"===u.$ref.firstElementChild.tagName||h(u.$ref,"art-control-onlyText"),u}}]),r}(st);function zt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function qt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e0.5\n0.75\n').concat(n.get("Normal"),'\n1.25\n1.5\n2.0'),click:function(t,e){var n=e.target.dataset.rate;n&&(r.playbackRate=Number(n),t.show=!1)},mounted:function(t){e.on("playbackRateChange",(function(e){var n=d("span",t).find((function(t){return Number(t.dataset.rate)===e}));n&&j(n,"art-current")}))}})}}function Wt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Vt(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e').concat(n.get("Default"),'\n4:3\n16:9'),click:function(t,e){var n=e.target.dataset.ratio;n&&(r.aspectRatio=n,t.show=!1)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("span",t).find((function(t){return t.dataset.ratio===e}));n&&j(n,"art-current")}))}})}}function Ft(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ht(t){return function(e){return function(t){for(var e=1;eArtPlayer 3.1.19'})}function Nt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function Ut(t){return function(e){return function(t){for(var e=1;ec+a&&(h=a-d),n+p>l+o&&(y=o-p),g(u,"left","".concat(h,"px")),g(u,"top","".concat(y,"px"))})),l(s,"click",(function(t){t.composedPath().includes(u)||(r.show=!1)})),e.on("blur",(function(){r.show=!1}))})),r}return u(n,e),n}(st),Yt=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.template,o=i.$infoPanel,s=i.$infoClose,u=i.$video;(0,e.events.proxy)(s,"click",(function(){r.show=!1}));var l=null,f=d("[data-video]",o);return e.on("destroy",(function(){clearTimeout(l)})),e.on("info:toggle",(function(t){clearTimeout(l),t&&function t(){f.forEach((function(t){var e=u[t.dataset.video];t.innerHTML="number"==typeof e?e.toFixed(2):e})),l=setTimeout((function(){t()}),1e3)}()})),r}return u(n,e),n}(st),Xt=function(e){function r(e){var n;t(this,r),n=a(this,c(r).call(this,e));var i=e.events.proxy,s=e.option.subtitle;return b(e.template.$subtitle,s.style),i(n.textTrack,"cuechange",n.update.bind(o(n))),s.url&&n.init(s.url),n}return u(r,e),n(r,[{key:"update",value:function(){var t=this.art.template.$subtitle;t.innerHTML="",this.activeCue&&(t.innerHTML=this.activeCue.text.split(/\r?\n/).map((function(t){return"

".concat(t,"

")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&o.show("".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),T(t)){case"srt":return R($(n));case"ass":return R(D(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show(t),e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(st);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.once("video:canplay",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=U((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Array.isArray(e)?e.forEach((function(e){return r.proxy(t,e,n,i)})):(t.addEventListener(e,n,i),this.destroyEvents.push((function(){t.removeEventListener(e,n,i)})))}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Jt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Gt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(st),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(st),Qt=function(){function e(n){t(this,e),this.art=n,this.timer=null}return n(e,[{key:"show",value:function(t){var e=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=this.art.template,o=i.$player,a=i.$noticeInner;a.innerHTML=t instanceof Error?t.message.trim():t,clearTimeout(this.timer),n&&(this.timer=setTimeout((function(){e.hide()}),r)),h(o,"art-notice-show"),this.art.emit("notice:toggle",!0)}},{key:"hide",value:function(){var t=this.art.template,e=t.$player;t.$noticeInner.innerHTML="",y(e,"art-notice-show"),this.art.emit("notice:toggle",!0)}}]),e}(),te=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(st),ee=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'\n',state:'\n',play:'\n',pause:'\n',volume:'\n',volumeClose:'\n',subtitle:'\n',screenshot:'\n\t\n\n',setting:'\n',fullscreen:'\n\t\n\t\n\t\n\t\n',fullscreenWeb:'\n\t\n',pip:'\n',prev:'\n',next:'\n'},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ne(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function re(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Flip"),'\n
\n
"),click:function(t,e){var n=e.target.dataset.value;n&&(r.flip=n)},mounted:function(t){e.on("flipChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ie(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function oe(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e'.concat(n.get("Aspect ratio"),'\n
\n
'),click:function(t,e){var n=e.target.dataset.value;n&&(r.aspectRatio=n)},mounted:function(t){e.on("aspectRatioChange",(function(e){var n=d("button",t).find((function(t){return t.dataset.value===e}));n&&j(n.parentElement,"current")}))}})}}function ae(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ce(t){return function(e){var n=e.i18n,r=e.player,i=e.events.proxy;return function(t){for(var e=1;e'.concat(n.get("Play speed"),': 1.0x\n\n
\n
'),mounted:function(t){var n=p(".art-setting-range input",t),o=p(".art-subtitle-value",t);i(n,"change",(function(){var t=n.value;o.innerText=t,r.playbackRate=Number(t)})),e.on("playbackRateChange",(function(t){n.value!==t&&(n.value=t,o.innerText=t)}))}})}}var se=function(e){function n(e){var r;t(this,n),r=a(this,c(n).call(this,e));var i=e.option,o=e.template,s=o.$setting,u=o.$settingBody,l=e.events.proxy;return r.$parent=u,i.setting&&(e.on("ready",(function(){l(s,"click",(function(t){t.target===s&&(r.show=!1)})),r.add(re({disable:!i.flip,name:"flip"})),r.add(oe({disable:!i.aspectRatio,name:"aspectRatio"})),r.add(ce({disable:!i.playbackRate,name:"playbackRate"}))})),e.on("blur",(function(){r.show=!1}))),r}return u(n,e),n}(st),ue=function(){function e(n){t(this,e),this.art=n,this.name="artplayer_settings";var r=n.option,i=this.get("volume");i&&(r.volume=i)}return n(e,[{key:"get",value:function(t){var e=JSON.parse(window.localStorage.getItem(this.name))||{};return t?e[t]:{}}},{key:"set",value:function(t,e){var n=Object.assign({},this.get(),ut({},t,e));window.localStorage.setItem(this.name,JSON.stringify(n))}},{key:"del",value:function(t){var e=this.get();delete e[t],window.localStorage.setItem(this.name,JSON.stringify(e))}},{key:"clean",value:function(){window.localStorage.removeItem(this.name)}}]),e}();function le(t){var e=t.i18n,n=t.subtitle,r=t.events.proxy;return{title:"Subtitle",name:"subtitleOffset",index:20,html:'\n
'.concat(e.get("Subtitle offset time"),': 0s\n
\n
\n
'),mounted:function(e){var i=p(".art-setting-range input",e),o=p(".art-subtitle-value",e);r(i,"change",(function(){var e=i.value;o.innerText=e,t.plugins.subtitleOffset.offset(Number(e))})),t.on("subtitle:switch",(function(){i.value=0,o.innerText=0})),t.on("subtitleOffset",(function(t){n.update(),i.value!==t&&(i.value=t,o.innerText=t)}))}}}function fe(t){var e=t.constructor.utils.clamp,n=t.setting,r=t.notice,i=t.template,o=t.i18n,a=t.player;n.add(le);var c=[];return t.on("subtitle:switch",(function(){c=[]})),{name:"subtitleOffset",offset:function(n){if(i.$track&&i.$track.track){var s=Array.from(i.$track.track.cues),u=e(n,-5,5);s.forEach((function(t,n){c[n]||(c[n]={startTime:t.startTime,endTime:t.endTime}),t.startTime=e(c[n].startTime+u,0,a.duration),t.endTime=e(c[n].endTime+u,0,a.duration)})),r.show("".concat(o.get("Subtitle offset time"),": ").concat(n,"s")),t.emit("subtitleOffset",n)}else r.show("".concat(o.get("No subtitles found"))),t.emit("subtitleOffset",0)}}}function pe(t){var e=t.events.proxy,n=t.template,r=t.player,i=t.option,o=t.setting,a=t.i18n;function c(e){if(e){var o=n.$video.canPlayType(e.type);if("maybe"===o||"probably"===o){var a=URL.createObjectURL(e);i.title=e.name,r.switchUrl(a,e.name),t.emit("localVideo",e)}else S(!1,"Playback of this file format is not supported")}}function s(t){var n=m(t,'');g(t,"position","relative"),b(n,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(n,"change",(function(){c(n.files[0])}))}return e(n.$player,"dragover",(function(t){t.preventDefault()})),e(n.$player,"drop",(function(t){t.preventDefault(),c(t.dataTransfer.files[0])})),t.on("ready",(function(){o.add({title:"Local Video",name:"localVideo",index:30,html:'\n
'.concat(a.get("Local Video"),'\n
\n
').concat(a.get("Open"),'
\n
'),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localVideo",(function(t){r.textContent=t.name,r.title=t.name})),s(n)}})})),{name:"localVideo",attach:s}}function de(t){var e=t.events.proxy,n=t.subtitle,r=t.setting,i=t.i18n;function o(r){var i=m(r,'');g(r,"position","relative"),b(i,{position:"absolute",width:"100%",height:"100%",left:"0",top:"0",opacity:"0"}),e(i,"change",(function(){!function(r){if(r){var i=T(r.name);if(["ass","vtt","srt"].includes(i)){var o=new FileReader;e(o,"load",(function(e){var o=e.target.result;switch(i){case"srt":var a=R($(o));n.switch(a,r.name);break;case"ass":var c=R(D(o));n.switch(c,r.name);break;case"vtt":var s=R(o);n.switch(s,r.name)}t.emit("localSubtitle",r)})),o.readAsText(r)}else S(!1,"Only supports subtitle files in .ass, .vtt and .srt format")}}(i.files[0])}))}return t.on("ready",(function(){r.add({title:"Local Subtitle",name:"localSubtitle",index:40,html:'\n
'.concat(i.get("Local Subtitle"),'\n
\n
').concat(i.get("Open"),'
\n
'),mounted:function(e){var n=p(".art-upload-btn",e),r=p(".art-upload-value",e);t.on("localSubtitle",(function(t){r.textContent=t.name,r.title=t.name})),o(n)}})})),{name:"localSubtitle",attach:o}}function he(t){var e=t.layers,n=t.player,r=t.option.theme;return e.add({name:"miniProgressBar",style:{display:"none",position:"absolute",left:0,right:0,bottom:0,height:"2px",background:r},mounted:function(e){t.on("control:toggle",(function(t){e.style.display=t?"none":"block"})),t.on("destroy",(function(){e.style.display="none"})),t.on("video:timeupdate",(function(){e.style.width="".concat(100*n.played,"%")}))}}),{name:"miniProgressBar"}}function ye(t){var e=1e4,n=0,r=0,i=0,o=null;function a(){n=0,r=0,i=0,cancelAnimationFrame(o),o=null}function c(){o||function a(){t.isDestroy||(o=requestAnimationFrame((function(){var o=Date.now();if(i){var c=o-i;r+=c,t.player.playing||(n+=c)}i=o,t.emit("networkMonitor",n/r),r>=e&&(n=0,r=0),a()})))}()}return t.on("play",c),t.on("pause",a),{name:"networkMonitor",reset:a,start:c,sample:function(t){e=t}}}function ve(t){var e=t.events,n=t.player,r=t.template,i=N((function(){var e=r.$player.getBoundingClientRect();e.top+e.height<=0&&!n.pip?(n.pip=!0,t.emit("autoPip",!0)):n.pip&&(n.pip=!1,t.emit("autoPip",!1))}),300);return e.proxy(window,"scroll",i),{name:"autoPip"}}var me=function(){function e(n){var r=this;t(this,e),this.art=n,this.id=0;var i=n.option;i.subtitle.url&&i.subtitleOffset&&this.add(fe),!i.isLive&&i.miniProgressBar&&this.add(he),i.localVideo&&this.add(pe),i.localSubtitle&&this.add(de),i.networkMonitor&&this.add(ye),i.autoPip&&this.add(ve),n.option.plugins.forEach((function(t){r.add(t)}))}return n(e,[{key:"add",value:function(t){this.id+=1;var e=t.call(this,this.art),n="";return S(!W(this,n=e&&e.name?e.name:t.name?t.name:"plugin".concat(this.id)),"Cannot add a plugin that already has the same name: ".concat(n)),Object.defineProperty(this,n,{value:e}),this.art.emit("plugin:add",t),this}}]),e}(),ge=function e(n){t(this,e);var r=n.option,i=n.events.proxy,o=n.template.$video;G.video.events.forEach((function(t){i(o,t,(function(t){n.emit("video:".concat(t.type),t)}))})),Object.keys(r.moreVideoAttr).forEach((function(t){o[t]=r.moreVideoAttr[t]})),r.muted&&(o.muted=r.muted),r.volume&&(o.volume=_(r.volume,0,1)),r.poster&&(o.poster=r.poster),r.autoplay&&(o.autoplay=r.autoplay),o.controls=!0;var a=r.type||T(r.url),c=r.customType[a];a&&c?(n.emit("beforeCustomType",a),c(o,r.url,n),n.emit("afterCustomType",a)):(n.emit("beforeAttachUrl",r.url),o.src=r.url,n.emit("afterAttachUrl",o.src))},be=0,we=function(e){function r(e){var n;return t(this,r),(n=a(this,c(r).call(this))).option=l(B(r.option,e),J),n.isFocus=!1,n.isDestroy=!1,n.whitelist=new K(o(n)),n.template=new Q(o(n)),n.events=new Zt(o(n)),n.whitelist.state?(n.storage=new ue(o(n)),n.icons=new ee(o(n)),n.i18n=new nt(o(n)),n.notice=new Qt(o(n)),n.player=new ot(o(n)),n.layers=new Gt(o(n)),n.controls=new Mt(o(n)),n.contextmenu=new _t(o(n)),n.subtitle=new Xt(o(n)),n.info=new Yt(o(n)),n.loading=new Kt(o(n)),n.hotkey=new Jt(o(n)),n.mask=new te(o(n)),n.setting=new se(o(n)),n.plugins=new me(o(n))):n.mobile=new ge(o(n)),be+=1,n.id=be,r.instances.push(o(n)),n}return u(r,e),n(r,[{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.events.destroy(),this.template.destroy(t),r.instances.splice(r.instances.indexOf(this),1),this.isDestroy=!0,this.emit("destroy")}}],[{key:"version",get:function(){return"3.1.19"}},{key:"env",get:function(){return'"production"'}},{key:"config",get:function(){return G}},{key:"utils",get:function(){return X}},{key:"scheme",get:function(){return J}},{key:"Emitter",get:function(){return f}},{key:"validator",get:function(){return l}},{key:"kindOf",get:function(){return l.kindOf}},{key:"option",get:function(){return{container:"#artplayer",url:"",poster:"",title:"",theme:"#f00",volume:.7,isLive:!1,muted:!1,autoplay:!1,autoSize:!1,loop:!1,flip:!1,playbackRate:!1,aspectRatio:!1,screenshot:!1,setting:!1,hotkey:!0,pip:!1,mutex:!0,fullscreen:!1,fullscreenWeb:!1,subtitleOffset:!1,miniProgressBar:!1,localVideo:!1,localSubtitle:!1,autoPip:!1,networkMonitor:!1,layers:[],contextmenu:[],quality:[],controls:[],highlight:[],plugins:[],whitelist:[],thumbnails:{url:"",number:60,width:160,height:90,column:10},subtitle:{url:"",style:{}},moreVideoAttr:{controls:!1,preload:"metadata"},icons:{},customType:{},lang:navigator.language.toLowerCase()}}}]),r}(f);return Object.defineProperty(we,"instances",{value:[]}),console.log("%c ArtPlayer %c 3.1.19 %c https://artplayer.org","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),we})); diff --git a/packages/artplayer/src/utils/property.js b/packages/artplayer/src/utils/property.js index 9f257325d..903229f01 100644 --- a/packages/artplayer/src/utils/property.js +++ b/packages/artplayer/src/utils/property.js @@ -1,18 +1,20 @@ import { errorHandle } from './error'; +const has = Object.prototype.hasOwnProperty; export function hasOwnProperty(obj, name) { - return Object.prototype.hasOwnProperty.call(obj, name); + return has.call(obj, name); } +const def = Object.defineProperty; export function defineProperty(obj, key, prop) { - return Object.defineProperty(obj, key, prop); + return def(obj, key, prop); } export function proxyPropertys(target, ...sources) { return sources.reduce((result, source) => { Object.getOwnPropertyNames(source).forEach(key => { errorHandle(!hasOwnProperty(result, key), `Target attribute name is duplicated: ${key}`); - Object.defineProperty(result, key, Object.getOwnPropertyDescriptor(source, key)); + def(result, key, Object.getOwnPropertyDescriptor(source, key)); }); return result; }, target); diff --git a/scripts/creatRollupConfig.js b/scripts/creatRollupConfig.js index c25e125a7..3ba587e37 100644 --- a/scripts/creatRollupConfig.js +++ b/scripts/creatRollupConfig.js @@ -12,6 +12,7 @@ const svgo = require('rollup-plugin-svgo'); const { sizeSnapshot } = require('rollup-plugin-size-snapshot'); const { terser } = require('rollup-plugin-terser'); const copyAfterBuild = require('./copyAfterBuild'); +const removeHtmlSpace = require('./removeHtmlSpace'); const json = require('rollup-plugin-json'); module.exports = function creatRollupConfig(projectPath) { @@ -82,6 +83,7 @@ module.exports = function creatRollupConfig(projectPath) { __ENV__: JSON.stringify(process.env.NODE_ENV || 'development'), __VERSION__: version, }), + isProd && removeHtmlSpace(), isProd && sizeSnapshot(), isProd && terser({ diff --git a/scripts/removeHtmlSpace.js b/scripts/removeHtmlSpace.js new file mode 100644 index 000000000..47213211b --- /dev/null +++ b/scripts/removeHtmlSpace.js @@ -0,0 +1,8 @@ +module.exports = () => ({ + name: 'removeHtmlSpace', + transform(code) { + return { + code: code.replace(/\\n?\s+\\n?\s+/g, '>'), + }; + }, +}); diff --git a/test/document.test.js b/test/document.test.js index b58d7c0f3..197ee5cd0 100644 --- a/test/document.test.js +++ b/test/document.test.js @@ -48,16 +48,16 @@ var art = new Artplayer({ var url = 'https://zhw2590582.github.io/assets-cdn'; var art = new Artplayer({ - container: '.artplayer-app', - url: url + '/video/one-more-time-one-more-chance-480p.flv', - type: 'flv', - customType: { - flv: function(video, url, art) { - // video: The video element - // url: The video url - // art: The Artplayer instance - } - } + container: '.artplayer-app', + url: url + '/video/one-more-time-one-more-chance-480p.flv', + type: 'flv', + customType: { + flv: function(video, url, art) { + // video: The video element + // url: The video url + // art: The Artplayer instance + }, + }, }); });