xgplayer-subtitles
Advanced tools
Comparing version 3.0.20-rc.5 to 3.0.20-rc.6
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.object.to-string.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.sticky.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.string.split.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.array.join.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.object.to-string.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.array.splice.js","core-js/modules/es.array.map.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.concat.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.includes.js","core-js/modules/es.string.includes.js","core-js/modules/es.function.name.js","core-js/modules/es.number.constructor.js","core-js/modules/es.array.slice.js","core-js/modules/es.symbol.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.string.match.js","core-js/modules/es.regexp.constructor.js","core-js/modules/es.regexp.sticky.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.string.split.js","core-js/modules/es.string.replace.js","core-js/modules/es.regexp.test.js","core-js/modules/es.string.trim.js","core-js/modules/es.array.join.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).XgSubtitle=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function s(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t,r){return(t=p(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function h(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return u(this,r)}}function f(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=f(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},d.apply(this,arguments)}function p(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var v={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,s||e,o),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,s,o){var a=r?r+e:e;if(!this._events[a])return!1;var l,c,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,s),!0;case 6:return u.fn.call(u.context,t,n,i,s,o),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var f,d=u.length;for(c=0;c<d;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,i);break;default:if(!l)for(f=1,l=new Array(h-1);f<h;f++)l[f-1]=arguments[f];u[c].fn.apply(u[c].context,l)}}return!0},a.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||o(this,s);else{for(var l=0,c=[],u=a.length;l<u;l++)(a[l].fn!==t||i&&!a[l].once||n&&a[l].context!==n)&&c.push(a[l]);c.length?this._events[s]=1===c.length?c[0]:c:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(v);var g=v.exports,m=/^WEBVTT/,y=/^STYLE+$/,_=/^\:\:cue/,T=/^}+$/,x=/^\[Script Info\].*/,b=[/[0-9]{1,3}:[0-9]{2}:[0-9]{2}\.[0-9]{1,3}-->[0-9]{1,3}:[0-9]{2}:[0-9]{2}\.[0-9]{1,3}/,/[0-9]{1,3}:[0-9]{2}\.[0-9]{1,3}-->[0-9]{1,3}:[0-9]{2}\.[0-9]{1,3}/,/[0-9]{1,2}\.[0-9]{1,3}-->[0-9]{1,2}\.[0-9]{1,3}/],j=/^Format:\s/,k=/^Style:\s/,w=/^Dialogue:\s/;function O(e){var t=e.length;return 3===t?(60*(60*Number(e[0])+Number(e[1]))*1e3+1e3*Number(e[2]))/1e3:2===t?(60*Number(e[0])*1e3+1e3*Number(e[1]))/1e3:Number(e[0])}function S(e){return/^(\-|\+)?\d+(\.\d+)?$/.test(e)}function R(e,t){return e>=0&&e<t.length?t[e]:""}var E=function(){function e(){n(this,e)}return s(e,null,[{key:"parseJson",value:function(e){for(var t=[],r=0,n=0;n<e.length;n++){if(r>=50&&(r=0),0===r){var i={start:e[n].start,list:[e[n]],end:e[n].end};t.push(i)}else t[t.length-1].list.push(e[n]),t[t.length-1].end=e[n].end;r++}return t}},{key:"parse",value:function(t,r){var n=e.checkFormat(t);n||r({format:n});try{var i=[];"ass"===n?i=e.parseASS(t):"vtt"===n&&(i=e.parseVTT(t)),r({format:n,list:i.list,styles:i.styles})}catch(s){console.error(s),r({format:n},s)}}},{key:"parseASSItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=e.split(","),n={},i="";try{var s=r.length-t.length;return i=(i=s>0?r.splice(t.length-1,s+1).join(",")+"":r[r.length-1]+"").replace(/\\n+/g,""),r[t.length-1]=i,t.map((function(e,t){"end"===e||"start"===e?n[e]=O(r[t].split(":")):"text"===e?n[e]=[r[t]]:"layer"===e?(n[e]=[r[t]],n.textTag=[r[t]]):n[e]="style"===e?[r[t]]:Number(r[t])?Number(r[t]):r[t]})),n}catch(o){return console.error(o),{}}}},{key:"parseASS",value:function(t){for(var r=t.split("\n"),n=[],i=0,s=0,o=[],a=[],l=null;i<r.length;){if(j.test(r[i]))a=(a=r[i].replace(j,"").replace(/\s+/g,"").split(",")).map((function(e){return e.toLocaleLowerCase()}));else if(k.test(r[i]))o.push(r[i].replace(k,"").replace(/\s+/g,""));else if(w.test(r[i])){var c=e.parseASSItem(r[i].replace(w,""),a);if(l&&c.start===l.start&&c.end===l.end)try{var u=l,h=u.text,f=u.textTag,d=u.style;h.push(c.text[0]),f.push(c.textTag[0]),d.push(c.style[0])}catch(v){console.error(v)}else{l=c;var p=null;s%50==0?((p={start:l.start,end:l.end,list:[]}).list.push(l),n.push(p)):((p=n[n.length-1]).end=l.end,p.list.push(l)),s++}}i++}return{list:n,style:{}}}},{key:"parseVTTStyle",value:function(e,t){var r=e.split(":");if(r.length>1){var n=r[0].trim().split("-"),i="";n.length>1?n.map((function(e,t){i+=0===t?e:e.charAt(0).toUpperCase()+e.slice(1)})):i=n[0],t[i]=r[1].trim().replace(/;$/,"")}return t}},{key:"parseVTT",value:function(e){for(var t=(e=e.replace(m,"")).split("\n"),r=[],n=0,i=0,s=null,o=!1,a=!1,l=null,c=null,u=[];n<t.length;){var h=R(n,t).trim();if(!h||o&&S(h))o=!h;else if(_.test(h)&&y.test(R(n-1,t).trim())){a=!0;var f=/\((.+?)\)/g.exec(h);c=f?f[1]:"",l=""}else if(a)T.test(h)?(u.push({key:c,style:l}),l=null,c=null,a=!1):l+=h;else if(h){o=!1;var d=this.checkIsTime(t[n]);if(d){var p=this.parseVttTime(d);if(!s||p.start!==s.start||p.end!==s.end){(s=p).text=[],s.textTag=[];var v=null;i%50==0?((v={start:s.start,end:s.end,list:[]}).list.push(s),r.push(v)):((v=r[r.length-1]).end=s.end,v.list.push(s)),i++}}else if(s){var g=s,x=g.text,b=g.textTag,j=this.parseVttText(t[n]);x.push(j.text),b.push(j.tag)}o=!1}n++}return{list:r,styles:u}}},{key:"checkIsTime",value:function(e){e=e.replace(/\s+/g,"");for(var t=0,r=null;t<b.length&&!(r=b[t].exec(e));)t++;return r?r[0]:null}},{key:"parseVttText",value:function(e){var t=/^(<?.+?>)/g.exec(e),r="",n="default";if(t){n=t[0].replace(/\<|\>|\&/g,"");var i=RegExp("^<".concat(n,">(([\\s\\S])*?)</").concat(n,">$")).exec(e);i?r=i[1]:(r=e,n="")}else r=e;for(var s=/<(\w+).(\w+)>/g,o=s.exec(r);o&&o.length>2;)r=r.replace(o[0],"<".concat(o[1],' class="').concat(o[2],'">')),o=s.exec(r);return{tag:n,text:r.replace(/\\n+/g,"<br/>")}}},{key:"parseVttTime",value:function(e){var t,r=e.split("--\x3e"),n=0;if(2===r.length){var i=r[0].split(":"),s=r[1].split(":");t=O(i),n=O(s)}return{start:t,end:n,time:e}}},{key:"isVTT",value:function(e){return m.test(e)}},{key:"isASS",value:function(e){return x.test(e)}},{key:"checkFormat",value:function(e){return e?m.test(e)?"vtt":x.test(e)?"ass":null:null}}]),e}(),P=[{code:0,msg:"SUCCESS"},{code:1,msg:"LOAD_ERROR"},{code:2,msg:"PARSER_ERROR"},{code:3,msg:"FORMAT_NOT_SUPPORTED"},{code:4,msg:"ID_OR_LANGUAGE_NOT_EXIST"},{code:5,msg:"PARAMETERS_ERROR"},{code:6,msg:"ABORT"},{code:7,msg:"UNKNOWN"},{code:8,msg:"DATA_ERROR:subtitle.url is null"},{code:9,msg:"DATA_ERROR:subtitle.url length is 0"}];function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={code:P[e].code,msg:P[e].msg};return Object.keys(t).map((function(e){r[e]=t[e]})),r}var A=s((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.url,i=t.method,s=void 0===i?"GET":i,o=t.type,a=void 0===o?"arraybuffer":o,l=t.timeout,c=void 0===l?1e4:l,u=t.data,h=void 0===u?{}:u,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n(this,e),new Promise((function(e,t){var n=new window.XMLHttpRequest,i=s.toUpperCase(),o=[];if(a&&(n.responseType=a),c&&(n.timeout=c),Object.keys(h).forEach((function(e){o.push("k=".concat(h[e]))})),n.onload=function(){200===n.status||206===n.status?e({context:f,res:n}):t(new Error({context:f,res:n,type:"error"}))},n.onerror=function(e){t(new Error({context:f,res:n,type:"error"}))},n.ontimeout=function(e){t(new Error({context:f,res:n,type:"error"}))},n.onabort=function(){t(new Error({context:f,res:n,type:"error"}))},"GET"===i)n.open(i,"".concat(r)),n.send();else{if("post"!==i)throw new Error("xhr ".concat(i," is not supported"));n.open(i,r),n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.send(o.join("&"))}}))})),I=function(){function e(){var t,r;n(this,e);var i=new Promise((function(e,n){t=e,r=n}));return i.resolve=function(e){t(e),i.state="fulfilled"},i.reject=function(e){r(e),i.state="rejected",i.isBreak="DESTROYED"===e},i.state="pending",i}return s(e,[{key:"resolve",value:function(e){}},{key:"reject",value:function(e){}}]),e}();function N(e,t){if(!e)return!1;if(e.classList)return Array.prototype.some.call(e.classList,(function(e){return e===t}));var n=e.className&&"object"===r(e.className)?e.getAttribute("class"):e.className;return n&&!!n.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function L(e,t){e&&(e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach((function(t){t&&e.classList.add(t)})):N(e,t)||(e.className&&"object"===r(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t))}function M(e,t,r){var n=t.length;if(n<1)return-1;if(t[r=r<0?0:r>=n?n-1:r].start<=e&&e<t[r].end)return r;for(var i=t[r].end<=e?r+1:0;i<n;i++){if(t[i].start<=e&&e<t[i].end)return i;if(e>t[i].end&&i+1<n&&e<t[i+1].start)return-1;if(e>t[i].end&&i+1>=n)return-1}return-1}function B(e,t,r){var n=t.length;if(n<1)return[];var i=[];if((r=r<0?0:r>=n?n-1:r)<n)for(var s=t[r].end<=e?r:0;s<n&&(t[s].start<=e&&e<t[s].end&&i.push(s),!(e<t[s].start));s++);return i}function q(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=document.createElement(e);return i.className=n,i.innerHTML=t,Object.keys(r).forEach((function(t){var n=t,s=r[t];"video"===e||"audio"===e||"live-video"===e?s&&i.setAttribute(n,s):i.setAttribute(n,s)})),i}function D(e,t,r){if(r||(r=new I),"json"===t){var n=E.parseJson(e);r.resolve({list:n,format:"json"})}else"string"===t&&E.parse(e,(function(e,t){if(t){var n=C(2,t);r.reject(n,{format:e.format})}else if(e.format)r.resolve({styles:e.styles,list:e.list,format:e.format});else{var i=C(3);r.reject(i)}}));return r}function U(e,r){return r||(r=new I),new A({url:e.url,type:"text"}).then((function(n){D(n.res.response,"string").then((function(n){r.resolve(t(t({},n),e))})).catch((function(e){r.reject(e)}))})).catch((function(n){var i=C(1,t({statusText:n.statusText,status:n.status,type:n.type,message:"http load error",url:e.src},e));r.reject(i)})),r}function W(e,t){return!!(e.id&&t.id&&e.id===t.id||e.language&&t.language&&e.language===t.language)}function H(e){return null!==e&&""!==e.trim()&&/^[a-zA-Z]+$/.test(e)}function V(e){return!!/[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F]/.test(e)}var $=function(){function e(){var t=this;n(this,e),this.__handlers=[],window.ResizeObserver&&(this.observer=new window.ResizeObserver((function(e){t.__trigger(e)})))}return s(e,[{key:"addObserver",value:function(e,t){if(this.observer){this.observer&&this.observer.observe(e);for(var r=this.__handlers,n=-1,i=0;i<r.length;i++)r[i]&&e===r[i].target&&(n=i);n>-1?this.__handlers[n].handler.push(t):this.__handlers.push({target:e,handler:[t]})}}},{key:"unObserver",value:function(e){var t=-1;this.__handlers.map((function(r,n){e===r.target&&(t=n)})),this.observer&&this.observer.unobserve(e),t>-1&&this.__handlers.splice(t,1)}},{key:"destroyObserver",value:function(){this.observer&&this.observer.disconnect(),this.observer=null,this.__handlers=null}},{key:"__runHandler",value:function(e,t){for(var r=this.__handlers,n=0;n<r.length;n++)if(r[n]&&e===r[n].target){r[n].handler&&r[n].handler.forEach((function(r){try{r(e,t)}catch(n){console.error(n)}}));break}}},{key:"__trigger",value:function(e){var t=this;e.map((function(e){var r=e.contentRect;t.__runHandler(e.target,r)}))}}]),e}(),F=null;var X="resize",G="change",Y="off";function J(e){var t=[];return e&&"String"===q(e)?t.push({url:e,index:0,start:-1,end:-1}):"Array"===q(e)&&e.forEach((function(e,r){t.push({url:e.url||e.src,index:r,start:e.start||-1,end:e.end||-1})})),t}var K=!1,Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(f,e);var i=h(f);function f(e){var t,r,s,a,l,h,d;return n(this,f),o(c(t=i.call(this)),"_onPause",(function(){t.stopRender()})),o(c(t),"_onPlay",(function(){t._curRenderTask.length>0&&t.startRender(-1)})),o(c(t),"_onTimeupdate",(function(){if(t._isOpen){var e=t.player.video,r=e.videoWidth,n=e.videoHeight;!t._videoMeta.scale&&r&&n&&t._onResize(t.player.root);var i=t._getPlayerCurrentTime();Math.round(Math.abs(1e3*i-t._ctime))<200||(t._ctime=1e3*i,t.currentText&&t.currentText.list&&("live"===t.config.updateMode?t._liveUpdate(i):t._update(i)))}})),o(c(t),"_onResize",(function(e){var r=c(t),n=r._videoMeta;if(r.config.domRender){if(e&&e instanceof window.Element||(e=t.player.root),t._iId&&(clearTimeout(t._iId),t._iId=null),!n.scale){if(!t.player.video)return;var i=t.player.video,s=i.videoWidth,o=i.videoHeight;if(!s||!o)return;n.videoWidth=s,n.videoHeight=o,n.scale=parseInt(o/s*100,10)}t.__startResize(e)}})),o(c(t),"_onCoreEvents",(function(e){try{switch(e.eventName){case"core.subtitlesegments":t._onSubtitleSegment(e.list||[]);break;case"core.subtitleplaylist":t._onSubtitlePlaylist(e.list||[]);break;case"core.seipayloadtime":t._onCoreSeiintime(e)}}catch(r){console.error(r)}})),o(c(t),"startRender",(function(e){if(e>0&&t._renderIntervalId&&(window.cancelAnimationFrame(t._renderIntervalId),t._renderIntervalId=-1),t.textTrack){var r=c(t)._curRenderTask;t._lastTimeStamp=(new Date).getTime();var n=[];r.forEach((function(r,i){var s=r.lastTime,o=r.wordList,a=r.interval,l=r.dom,c=r.ids;if(e<0||t._lastTimeStamp<0||t._lastTimeStamp-s>=a){var u=o.shift();u&&l.appendData(u),r.lastTime=t._lastTimeStamp}o.length<1&&n.push({index:i,ids:c})})),t._log(">>>>_renderByWords emptyArr",n.length,r.length),n.forEach((function(e){r.splice(e.index,1),t._log(">>>_renderByWords remove emptyArr",e.index,r.length)})),r.length>0&&(t._renderIntervalId=window.requestAnimationFrame(t.startRender))}})),o(c(t),"destroy",(function(){t.detachPlayer(),t.removeAllListeners(),t.player=null,t.textTrack=null,t._curRenderTask=[],t.stopRender()})),r=navigator.userAgent,s=/(?:Windows Phone)/.test(r),a=/(?:SymbianOS)/.test(r)||s,l=/(?:Android)/.test(r),h=/(?:Firefox)/.test(r),d=/(?:iPad|PlayBook)/.test(r)||l&&!/(?:Mobile)/.test(r)||h&&/(?:Tablet)/.test(r),K=/(?:iPhone)/.test(r)&&!d||l||a||d,t.currentText=null,t.currentExtText=null,t.textTrack=[],t._cid=-1,t._gid=-1,t._cids=[],t._iId=null,t._iC=0,t.player=null,t.root=null,t.config={line:"double",bottom:0,mode:"stroke",defaultOpen:!1,baseSizeX:49,baseSizeY:28,minSize:16,minMobileSize:13,fitVideo:!0,offsetBottom:2,fontColor:"#fff",domRender:!0,updateMode:"vod",renderMode:"",debugger:!1},t._ctime=0,t._loadingTrack={},Object.keys(t.config).map((function(r){void 0!==e[r]&&null!==e[r]&&(t.config[r]=e[r])})),t._isOpen=t.config.defaultOpen||!1,t._videoMeta={scale:0,videoHeight:0,videoWidth:0,lwidth:0,lheight:0,vWidth:0,vHeight:0,vBottom:0,vLeft:0,marginBottom:0},e.subTitles&&"Array"===q(e.subTitles)?(e.player&&t.attachPlayer(e.player),t.seiTime=0,t.lastSeiTime=0,t._curTexts=[],t._curRenderTask=[],t._renderIntervalId=-1,t._lastTimeStamp=-1,t.setSubTitles(e.subTitles,t.config.defaultOpen),t):u(t)}return s(f,[{key:"version",get:function(){return"3.0.20-rc.5"}},{key:"setSubTitles",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this._isOpen||r;n&&this.innerRoot&&this.switchOff(),this.currentText=null,this.textTrack=[],t.forEach((function(t){var r={};Object.keys(t).map((function(e){r[e]=t[e]})),r.url=J(r.url),r.isDefault&&(e.currentText=r),e.textTrack.push(r)})),this._log("setSubTitles",i),i&&this.switch().catch((function(t){e._log("[switch]",t)})),this.currentText&&this._loadTrack(this.currentText).then((function(t){e.addStyles(t)})),this.emit("reset",{list:this.textTrack,isOpen:i})}},{key:"updateSubTitle",value:function(e){for(var t=this,r=-1,n=0;n<this.textTrack.length;n++)if(W(e,this.textTrack[n])){r=n;break}if(this._log("updateSubTitle",r,e),r>-1){var i=W(this.currentText,this.textTrack[r]);if(this._log("updateSubTitle","_isCurrent",i,"this.isOpen",this.isOpen,this.currentText),!i)return;var s=J(e.url);this.isOpen?(s.forEach((function(e){t.textTrack[r].url.push(e)})),this._log("updateSubTitle _loadTrackUrls",this.textTrack[r]),this._loadTrackUrls(this.currentText,2)):this.textTrack[r].url=s}}},{key:"addStyles",value:function(e){var t=e.styles,r=e.format;t&&"vtt"===r&&(t.map((function(e){e.key||(e.key="xg-text-track-span")})),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r="";e.map((function(e){r+=" ".concat(t," ").concat(e.key," {").concat(e.style,"}")}));var n=document.createElement("style"),i=document.head||document.getElementsByTagName("head")[0];if(n.type="text/css",n.id="ssss",n.styleSheet){var s=function(){try{n.styleSheet.cssText=r}catch(e){}};n.styleSheet.disabled?setTimeout(s,10):s()}else{var o=document.createTextNode(r);n.appendChild(o)}i.appendChild(n)}(t,"xg-text-track"))}},{key:"attachPlayer",value:function(e){var t=this;if(this._log("attachPlayer"),e){this.player&&this.detachPlayer();var r,n,i=this.config,s=i.fontColor,o=i.mode,a=i.fitVideo,l=i.domRender;this.player=e,l&&(this.root=document.createElement("xg-text-track"),this.root.className="xg-text-track",!this._isOpen&&L(this.root,"text-track-hide"),!a&&L(this.root,"text-track-no-fitvideo"),o&&L(this.root,"text-track-".concat(o)),this.innerRoot=document.createElement("xg-text-track-inner"),this.root.appendChild(this.innerRoot),s&&(this.root.style.color=s),this.currentText&&["language","id","label"].map((function(e){t.root.setAttribute("data-".concat(e),t.currentText[e]||"")})),this.player.root.appendChild(this.root),r=e.root,n=this._onResize,F||(F=new $),F.addObserver(r,n)),this.player.on("destroy",this.destroy),this.player.on("timeupdate",this._onTimeupdate),this.player.on("pause",this._onPause),this.player.on("play",this._onPlay),this.player.on("core_event",this._onCoreEvents),this._isOpen&&this.switch().catch((function(e){t._log("[switch]",e)}))}}},{key:"detachPlayer",value:function(){var e,t,r=this.player,n=this.config;r&&(r.off("destroy",this.destroy),r.off("timeupdate",this._onTimeupdate),r.off("pause",this._onPause),r.off("play",this._onPlay),r.off("core_event",this._onCoreEvents),n.domRender&&(r.root&&(e=r.root,t=this._onResize,F&&F.unObserver(e,t),r.root.removeChild(this.root)),this.innerRoot=null,this.root=null),this.player=null)}},{key:"switch",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:"",language:""};return this._log("switch",t),this._loadingTrack=t,new Promise((function(r,n){if(t.id||t.language)if(e.currentText&&W(t,e.currentText))e._loadingTrack={},e._updateCurrent(e.currentText),e.switchOn(),r(C(0));else{var i=null;e.__removeByTime(e._curTexts,0);for(var s=0;s<e.textTrack.length;s++)if(W(t,e.textTrack[s])){i=e.textTrack[s];break}if(e._log("nextSubtitle",i),i)e._emitPlayerSwitch(e.currentText,i),i.list?(e._loadingTrack={},e._updateCurrent(i),e.switchOn(),r(C(0))):(e._log("this._loadTrack",i),e._updateCurrent(i),e._loadTrack(i).then((function(t){if(e.addStyles(t),e._loadingTrack.id===i.id||e._loadingTrack.language===t.language)e._loadingTrack={},e._updateCurrent(t),e.switchOn(),r(C(0));else{var s=C(6,{message:"check _loadingTrack fail id: ".concat(e._loadingTrack.id," nextSubtitle:").concat(t.id)});n(s)}})).catch((function(e){n(e)})));else{var o=C(4,new Error("The is no subtitle with id:[{".concat(t.id,"}] or language:[").concat(t.language,"]")));n(o)}}else{if(e.currentText){e._loadingTrack={},e._updateCurrent(e.currentText),e.switchOn();var a=C(0,{message:"switch default subtitle success"});return void r(a)}var l=C(5,{message:"no default subtitle"});n(l)}}))}},{key:"switchExt",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:"",language:""};return new Promise((function(r,n){if(t.id||t.language){for(var i=null,s=0;s<e.textTrack.length;s++)if(W(t,e.textTrack[s])){i=e.textTrack[s];break}i&&!W(i,e.currentText)&&e._loadTrack(i).then((function(t){e.currentExtText=t,r(C(0))}))}else e.currentExtText=null,r(C(0))}))}},{key:"switchOn",value:function(){this._log("switchOn"),this._isOpen=!0,this.show(),this.emit(G,this.currentText)}},{key:"switchOff",value:function(){this._isOpen=!1,this.hide(),this.emit(Y)}},{key:"isOpen",get:function(){return this._isOpen}},{key:"_log",value:function(){if(this.config.debugger){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,["[xgSubtitle]"].concat(r))}}},{key:"_loadTrack",value:function(e){var t=this;this._log("_loadTrack",e.language,e);var r=new I,n="",i="";if(e.json?(n="json",i=e.json):e.stringContent&&!e.url&&(n="string",i=e.stringContent),i)return D(i,n).then((function(t){e.format=t.format,e.styles=t.styles,e.list=t.list,r.resolve(e)})).catch((function(e){r.reject(e)})),r;var s=e.url;return 0===s.length?(r.resolve(e),r):(U(s.splice(0,1)[0]).then((function(n){e.format=n.format,e.styles=n.styles,e.list||(e.list=[]),t._pushList(e.list,n.list),s.length>1&&t._loadTrackUrls(e,2),r.resolve(e)})).catch((function(e){r.reject(e)})),r)}},{key:"_emitPlayerSwitch",value:function(e,r){e&&"live"===this.config.updateMode&&(e.list=[],e.url=[]);var n=t({lang:r.language},r);this._log("emit subtile_switch ",r,n),this.player&&this.player.emit("switch_subtitle",n)}},{key:"_loadTrackUrls",value:function(e,r,n){var i=this,s=e.url.length,o=s>r?e.url.splice(0,r):e.url.splice(0,s),a=o.length;this._log("_loadTrackUrls",e.language,s,o.length,a),o.forEach((function(r,s){U(t(t({},r),{},{index:s})).then((function(t){e.format=t.format,e.styles=t.format,e.list||(e.list=[]),i._pushList(e.list,t.list),a--})).catch((function(e){a--})).finally((function(t){0===a&&(n&&n.resolve(e),i._loadTrackUrls(e,2))}))}))}},{key:"_freshUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{url:""},r=-1;e.url.forEach((function(e,n){e.url===t.url&&(r=n)})),r>-1&&e.url.splice(r,1)}},{key:"_pushList",value:function(e,t){var r=t[0].start,n=t[t.length-1].end;if(0===e.length||r>=e[e.length-1].end)t.forEach((function(t){e.push(t)}));else{for(var i=-1,s=0;s<e.length;s++)if(e[s].start>n){i=s;break}i>-1&&t.forEach((function(t,r){e.splice(i+r,0,t)}))}return e}},{key:"_updateCurrent",value:function(e){var t=this;this.currentText=e,this.config.domRender&&this.root&&(["language","id","label"].map((function(e){t.root.setAttribute("data-".concat(e),t.currentText[e]||"")})),this.__remove(this._cids)),this._cids=[],this._gid=-1,this._cid=-1,this._curTexts=[];var r=this._getPlayerCurrentTime();r&&("live"===this.config.updateMode?this._liveUpdate(r):this._update(r))}},{key:"__loadAll",value:function(){var e=this;this.textTrack.forEach((function(t){e._loadTrack(t)}))}},{key:"getDelCid",value:function(e,t){for(var r=[],n=0;n<e.length;n++)t.includes(e[n])||r.push(e[n]);return r}},{key:"getNewCid",value:function(e,t){for(var r=[],n=0;n<t.length;n++)e.includes(t[n])||r.push(t[n]);return r}},{key:"_liveUpdate",value:function(e){var t=this;if(this.currentText&&this.currentText.list&&this.currentText.list.length){var r=[],n=M(e,this.currentText.list,this._gid);if(n>-1&&(r=B(e,this.currentText.list[n].list,this._cid)),this.__removeByTime(this._curTexts,e),this._log("_liveUpdate",e,n,r,this.currentText.list[0].list[0].start,this.currentText.list[0].list[0].end),r.length>0){var i=function(e,t,r){if(0===e.length||t<0||t>e.length-1)return[];var n=e[t].list;if(0===r.length)return[];var i=n.splice(r[0],r.length);return t>0&&e.splice(0,t),0===n.length&&e.splice(0,1),i}(this.currentText.list,n,r),s=this._curTexts.length,o=s>0?this._curTexts[s-1].index:0;i.forEach((function(e,r){e.index=r+o,t._curTexts.push(e)})),this.__render(i)}this.emit("update",this._curTexts)}}},{key:"_update",value:function(e){var t=this;if(this.currentText&&this.currentText.list&&this.currentText.list.length){var r=M(e,this.currentText.list,this._gid),n=[];if(r>-1&&(n=B(e,this.currentText.list[r].list,this._cid)),n.length<1)return this._cids.length>0&&this.config.domRender&&this.__remove(this._cids),void(this._cids=[]);if(this._cids!==n||r!==this._gid){this._gid=r,this._cid=n[0];var i=this.getDelCid(this._cids,n),s=this.getNewCid(this._cids,n);this._cids=n,this.config.domRender&&this.__remove(i);var o=[];s.map((function(e){var n=t.currentText.list[r].list[e];n.index=e,o.push(n)})),this.currentExtText&&s.map((function(e){var n=t.currentText.list[r].list[e];n.index=e,o.push(n)})),this._log("update",o,e),this.emit("update",o),this.__render(o,e)}}}},{key:"_getPlayerCurrentTime",value:function(){if(!this.player)return 0;var e=this.player.currentTime;return parseInt(1e3*e+1e3*this.seiTime-1e3*this.lastSeiTime,10)/1e3}},{key:"_onSubtitlePlaylist",value:function(e){this._log("_onSubtitlePlaylist",e);var t=e.map((function(e){return{label:e.name,language:e.lang,id:e.id,isDefault:e.default,url:[],mUrl:e.url}}));this.setSubTitles(t)}},{key:"_onSubtitleSegment",value:function(e){if(this._log("_onSubtitleSegment",e.length,e[0].lang,e[0].sn,e[e.length-1].sn,e[0].start,e[e.length-1].end),e&&0!==e.length){var t={language:e[0].lang,url:e.map((function(e){return{id:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end}}))};W(t,this.currentText)&&this.updateSubTitle(t)}}},{key:"_onCoreSeiintime",value:function(e){try{var t=e.time/1e3;this._log("_onCoreSeiintime sei",t,this.seiTime,this.lastSeiTime),this.seiTime=t,this.lastSeiTime=this.player?this.player.currentTime:0}catch(r){}}},{key:"resize",value:function(e,t){var r,n=this,i=this.config,s=i.baseSizeX,o=i.baseSizeY,a=i.minMobileSize,l=i.minSize,c=i.fitVideo,u=i.offsetBottom,h=this._videoMeta.scale;this._videoMeta.lwidth=e,this._videoMeta.lheight=t;var f=0;t/e*100>=h?(f=parseInt(h*e,10)/100,r=e):(f=t,r=parseInt(t/h*100,10)),this._videoMeta.vWidth=r,this._videoMeta.vHeight=f;var d=0,p=0;h>120?(d=o,p=parseInt(d*f/1080,10)):(d=s,p=parseInt(d*r/1920,10));var v=K?a:l,g={fontSize:p=p<v?v:p>d?d:p},m=parseInt((t-f)/2,10),y=parseInt((e-r)/2,10),_=parseInt(f*u,10)/100;this._videoMeta.vBottom=m,this._videoMeta.vLeft=y,this._videoMeta.marginBottom=_,c&&(g.bottom=m+_,g.left=g.right=y),Object.keys(g).map((function(e){n.root.style[e]="".concat(g[e],"px")})),this.emit(X,{vLeft:y,vBottom:m,marginBottom:_,vWidth:r,vHeight:f,fontSize:p,scale:h})}},{key:"__startResize",value:function(e){var t=this,r=e.getBoundingClientRect(),n=this._videoMeta,i=r.width,s=r.height;if(this._iId&&(clearTimeout(this._iId),this._iId=null),i>0&&s>0&&(i!==n.lwidth||s!==n.lheight))this._iC=0,this.resize(i,s);else{if(this._iC>=5)return void(this._iC=0);this._iC++,this._iId=setTimeout((function(){t.__startResize(e)}),50)}}},{key:"__removeByTime",value:function(e,t){for(var r=[],n=0;n<e.length;n++)(!t||e[n].end<t)&&r.push(n);0!==r.length&&(e.splice(r[0],r.length),this.config.domRender&&this.__remove(r))}},{key:"__remove",value:function(e){var t=this;if(e&&!(e.length<1)){this._log(">>>>_renderByWords__remove",e);for(var r=this.innerRoot.children,n=[],i=0;i<r.length;i++){var s=Number(r[i].getAttribute("data-index"));e.includes(s)&&n.push(r[i])}n.map((function(e){t.innerRoot.removeChild(e)}))}}},{key:"__render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this._log("__render",t.length,this.config.domRender);var r=this.config,n=r.renderMode,i=r.domRender;t.length>0&&i&&t.forEach((function(t){var r="text-track-".concat(e.config.line);t.text.forEach((function(i,s){s>0&&(r+=" text-track-deputy");var o={"data-start":t.start,"data-end":t.end,"data-index":t.index},a=z("xg-text-track-span","",o,r);if(e.innerRoot.appendChild(a),"step"===n){var l=z("xg-text-track-span","",o,"".concat(r," text-track-space"));e.innerRoot.appendChild(l),l.innerHTML=i,setTimeout((function(){e._renderByWords(a,s,t.start,t.end,i)}),600)}else a.innerHTML=i}))}))}},{key:"_renderByWords",value:function(e,t,r,n,i){var s=document.createTextNode("");e.appendChild(s);var o=function(e){for(var t=e.split(""),r=[],n=!1,i=0;i<t.length;i++){var s=t[i];if(H(s))if(n){var o=r.length-1;r[o]="".concat(r[o]).concat(s)}else r.push(s),n=!0;else if(s.match(/^[ ]*$/)||V(s)||/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(s)){n=!1;var a=r.length-1;r[a]="".concat(r[a]).concat(s)}else n=!1,r.push(s)}return r}(i),a=this._getPlayerCurrentTime(),l=parseInt(1e3*(n-a),10);if(!(a>=n)){r>=a&&(a=r),l>300&&(l-=50);var c={dom:s,ids:t,wordList:o,interval:l/o.length,start:a,end:n,duration:l,lastTime:0};this._log(">>>>_renderByWords",l,c);for(var u=this._curRenderTask,h=-1,f=0;f<u.length;f++)if(u[f].ids===t){h=f;break}h>-1&&u.slice(h,1),u.push(c),this.startRender(-1)}}},{key:"stopRender",value:function(){this._renderIntervalId&&window.cancelAnimationFrame(this._renderIntervalId)}},{key:"show",value:function(){var e,t;this.config.domRender&&(e=this.root,t="text-track-hide",e&&(e.classList?t.split(/\s+/g).forEach((function(t){e.classList.remove(t)})):N(e,t)&&t.split(/\s+/g).forEach((function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===r(e.className)?e.setAttribute("class",e.getAttribute("class").replace(n," ")):e.className=e.className.replace(n," ")}))))}},{key:"hide",value:function(){this.config.domRender&&(L(this.root,"text-track-hide"),this.innerRoot.innerHTML="")}},{key:"emit",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"emit",this)).call.apply(r,[this,e,t].concat(i))}},{key:"on",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"on",this)).call.apply(r,[this,e,t].concat(i))}},{key:"once",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"once",this)).call.apply(r,[this,e,t].concat(i))}},{key:"off",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"off",this)).call.apply(r,[this,e,t].concat(i))}},{key:"offAll",value:function(){d(a(f.prototype),"removeAllListeners",this).call(this)}},{key:"marginBottom",get:function(){var e=this._videoMeta,t=e.bottom,r=e.marginBottom;return this.config.fitVideo?t+r:r}}]),f}(g);return Z})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.object.to-string.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.sticky.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.string.split.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.array.join.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.object.to-string.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.array.splice.js","core-js/modules/es.array.map.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.concat.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.includes.js","core-js/modules/es.string.includes.js","core-js/modules/es.function.name.js","core-js/modules/es.number.constructor.js","core-js/modules/es.array.slice.js","core-js/modules/es.symbol.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.string.match.js","core-js/modules/es.regexp.constructor.js","core-js/modules/es.regexp.sticky.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.string.split.js","core-js/modules/es.string.replace.js","core-js/modules/es.regexp.test.js","core-js/modules/es.string.trim.js","core-js/modules/es.array.join.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).XgSubtitle=t()}(this,(function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function s(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t,r){return(t=p(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function h(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return u(this,r)}}function f(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=f(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},d.apply(this,arguments)}function p(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var v={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,s||e,o),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,s,o){var a=r?r+e:e;if(!this._events[a])return!1;var l,c,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,s),!0;case 6:return u.fn.call(u.context,t,n,i,s,o),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var f,d=u.length;for(c=0;c<d;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,n);break;case 4:u[c].fn.call(u[c].context,t,n,i);break;default:if(!l)for(f=1,l=new Array(h-1);f<h;f++)l[f-1]=arguments[f];u[c].fn.apply(u[c].context,l)}}return!0},a.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||o(this,s);else{for(var l=0,c=[],u=a.length;l<u;l++)(a[l].fn!==t||i&&!a[l].once||n&&a[l].context!==n)&&c.push(a[l]);c.length?this._events[s]=1===c.length?c[0]:c:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a}(v);var g=v.exports,m=/^WEBVTT/,y=/^STYLE+$/,_=/^\:\:cue/,T=/^}+$/,x=/^\[Script Info\].*/,b=[/[0-9]{1,3}:[0-9]{2}:[0-9]{2}\.[0-9]{1,3}-->[0-9]{1,3}:[0-9]{2}:[0-9]{2}\.[0-9]{1,3}/,/[0-9]{1,3}:[0-9]{2}\.[0-9]{1,3}-->[0-9]{1,3}:[0-9]{2}\.[0-9]{1,3}/,/[0-9]{1,2}\.[0-9]{1,3}-->[0-9]{1,2}\.[0-9]{1,3}/],j=/^Format:\s/,k=/^Style:\s/,w=/^Dialogue:\s/;function O(e){var t=e.length;return 3===t?(60*(60*Number(e[0])+Number(e[1]))*1e3+1e3*Number(e[2]))/1e3:2===t?(60*Number(e[0])*1e3+1e3*Number(e[1]))/1e3:Number(e[0])}function S(e){return/^(\-|\+)?\d+(\.\d+)?$/.test(e)}function R(e,t){return e>=0&&e<t.length?t[e]:""}var E=function(){function e(){n(this,e)}return s(e,null,[{key:"parseJson",value:function(e){for(var t=[],r=0,n=0;n<e.length;n++){if(r>=50&&(r=0),0===r){var i={start:e[n].start,list:[e[n]],end:e[n].end};t.push(i)}else t[t.length-1].list.push(e[n]),t[t.length-1].end=e[n].end;r++}return t}},{key:"parse",value:function(t,r){var n=e.checkFormat(t);n||r({format:n});try{var i=[];"ass"===n?i=e.parseASS(t):"vtt"===n&&(i=e.parseVTT(t)),r({format:n,list:i.list,styles:i.styles})}catch(s){console.error(s),r({format:n},s)}}},{key:"parseASSItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=e.split(","),n={},i="";try{var s=r.length-t.length;return i=(i=s>0?r.splice(t.length-1,s+1).join(",")+"":r[r.length-1]+"").replace(/\\n+/g,""),r[t.length-1]=i,t.map((function(e,t){"end"===e||"start"===e?n[e]=O(r[t].split(":")):"text"===e?n[e]=[r[t]]:"layer"===e?(n[e]=[r[t]],n.textTag=[r[t]]):n[e]="style"===e?[r[t]]:Number(r[t])?Number(r[t]):r[t]})),n}catch(o){return console.error(o),{}}}},{key:"parseASS",value:function(t){for(var r=t.split("\n"),n=[],i=0,s=0,o=[],a=[],l=null;i<r.length;){if(j.test(r[i]))a=(a=r[i].replace(j,"").replace(/\s+/g,"").split(",")).map((function(e){return e.toLocaleLowerCase()}));else if(k.test(r[i]))o.push(r[i].replace(k,"").replace(/\s+/g,""));else if(w.test(r[i])){var c=e.parseASSItem(r[i].replace(w,""),a);if(l&&c.start===l.start&&c.end===l.end)try{var u=l,h=u.text,f=u.textTag,d=u.style;h.push(c.text[0]),f.push(c.textTag[0]),d.push(c.style[0])}catch(v){console.error(v)}else{l=c;var p=null;s%50==0?((p={start:l.start,end:l.end,list:[]}).list.push(l),n.push(p)):((p=n[n.length-1]).end=l.end,p.list.push(l)),s++}}i++}return{list:n,style:{}}}},{key:"parseVTTStyle",value:function(e,t){var r=e.split(":");if(r.length>1){var n=r[0].trim().split("-"),i="";n.length>1?n.map((function(e,t){i+=0===t?e:e.charAt(0).toUpperCase()+e.slice(1)})):i=n[0],t[i]=r[1].trim().replace(/;$/,"")}return t}},{key:"parseVTT",value:function(e){for(var t=(e=e.replace(m,"")).split("\n"),r=[],n=0,i=0,s=null,o=!1,a=!1,l=null,c=null,u=[];n<t.length;){var h=R(n,t).trim();if(!h||o&&S(h))o=!h;else if(_.test(h)&&y.test(R(n-1,t).trim())){a=!0;var f=/\((.+?)\)/g.exec(h);c=f?f[1]:"",l=""}else if(a)T.test(h)?(u.push({key:c,style:l}),l=null,c=null,a=!1):l+=h;else if(h){o=!1;var d=this.checkIsTime(t[n]);if(d){var p=this.parseVttTime(d);if(!s||p.start!==s.start||p.end!==s.end){(s=p).text=[],s.textTag=[];var v=null;i%50==0?((v={start:s.start,end:s.end,list:[]}).list.push(s),r.push(v)):((v=r[r.length-1]).end=s.end,v.list.push(s)),i++}}else if(s){var g=s,x=g.text,b=g.textTag,j=this.parseVttText(t[n]);x.push(j.text),b.push(j.tag)}o=!1}n++}return{list:r,styles:u}}},{key:"checkIsTime",value:function(e){e=e.replace(/\s+/g,"");for(var t=0,r=null;t<b.length&&!(r=b[t].exec(e));)t++;return r?r[0]:null}},{key:"parseVttText",value:function(e){var t=/^(<?.+?>)/g.exec(e),r="",n="default";if(t){n=t[0].replace(/\<|\>|\&/g,"");var i=RegExp("^<".concat(n,">(([\\s\\S])*?)</").concat(n,">$")).exec(e);i?r=i[1]:(r=e,n="")}else r=e;for(var s=/<(\w+).(\w+)>/g,o=s.exec(r);o&&o.length>2;)r=r.replace(o[0],"<".concat(o[1],' class="').concat(o[2],'">')),o=s.exec(r);return{tag:n,text:r.replace(/\\n+/g,"<br/>")}}},{key:"parseVttTime",value:function(e){var t,r=e.split("--\x3e"),n=0;if(2===r.length){var i=r[0].split(":"),s=r[1].split(":");t=O(i),n=O(s)}return{start:t,end:n,time:e}}},{key:"isVTT",value:function(e){return m.test(e)}},{key:"isASS",value:function(e){return x.test(e)}},{key:"checkFormat",value:function(e){return e?m.test(e)?"vtt":x.test(e)?"ass":null:null}}]),e}(),P=[{code:0,msg:"SUCCESS"},{code:1,msg:"LOAD_ERROR"},{code:2,msg:"PARSER_ERROR"},{code:3,msg:"FORMAT_NOT_SUPPORTED"},{code:4,msg:"ID_OR_LANGUAGE_NOT_EXIST"},{code:5,msg:"PARAMETERS_ERROR"},{code:6,msg:"ABORT"},{code:7,msg:"UNKNOWN"},{code:8,msg:"DATA_ERROR:subtitle.url is null"},{code:9,msg:"DATA_ERROR:subtitle.url length is 0"}];function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={code:P[e].code,msg:P[e].msg};return Object.keys(t).map((function(e){r[e]=t[e]})),r}var A=s((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.url,i=t.method,s=void 0===i?"GET":i,o=t.type,a=void 0===o?"arraybuffer":o,l=t.timeout,c=void 0===l?1e4:l,u=t.data,h=void 0===u?{}:u,f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n(this,e),new Promise((function(e,t){var n=new window.XMLHttpRequest,i=s.toUpperCase(),o=[];if(a&&(n.responseType=a),c&&(n.timeout=c),Object.keys(h).forEach((function(e){o.push("k=".concat(h[e]))})),n.onload=function(){200===n.status||206===n.status?e({context:f,res:n}):t(new Error({context:f,res:n,type:"error"}))},n.onerror=function(e){t(new Error({context:f,res:n,type:"error"}))},n.ontimeout=function(e){t(new Error({context:f,res:n,type:"error"}))},n.onabort=function(){t(new Error({context:f,res:n,type:"error"}))},"GET"===i)n.open(i,"".concat(r)),n.send();else{if("post"!==i)throw new Error("xhr ".concat(i," is not supported"));n.open(i,r),n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.send(o.join("&"))}}))})),I=function(){function e(){var t,r;n(this,e);var i=new Promise((function(e,n){t=e,r=n}));return i.resolve=function(e){t(e),i.state="fulfilled"},i.reject=function(e){r(e),i.state="rejected",i.isBreak="DESTROYED"===e},i.state="pending",i}return s(e,[{key:"resolve",value:function(e){}},{key:"reject",value:function(e){}}]),e}();function N(e,t){if(!e)return!1;if(e.classList)return Array.prototype.some.call(e.classList,(function(e){return e===t}));var n=e.className&&"object"===r(e.className)?e.getAttribute("class"):e.className;return n&&!!n.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function L(e,t){e&&(e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach((function(t){t&&e.classList.add(t)})):N(e,t)||(e.className&&"object"===r(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t))}function M(e,t,r){var n=t.length;if(n<1)return-1;if(t[r=r<0?0:r>=n?n-1:r].start<=e&&e<t[r].end)return r;for(var i=t[r].end<=e?r+1:0;i<n;i++){if(t[i].start<=e&&e<t[i].end)return i;if(e>t[i].end&&i+1<n&&e<t[i+1].start)return-1;if(e>t[i].end&&i+1>=n)return-1}return-1}function B(e,t,r){var n=t.length;if(n<1)return[];var i=[];if((r=r<0?0:r>=n?n-1:r)<n)for(var s=t[r].end<=e?r:0;s<n&&(t[s].start<=e&&e<t[s].end&&i.push(s),!(e<t[s].start));s++);return i}function q(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=document.createElement(e);return i.className=n,i.innerHTML=t,Object.keys(r).forEach((function(t){var n=t,s=r[t];"video"===e||"audio"===e||"live-video"===e?s&&i.setAttribute(n,s):i.setAttribute(n,s)})),i}function D(e,t,r){if(r||(r=new I),"json"===t){var n=E.parseJson(e);r.resolve({list:n,format:"json"})}else"string"===t&&E.parse(e,(function(e,t){if(t){var n=C(2,t);r.reject(n,{format:e.format})}else if(e.format)r.resolve({styles:e.styles,list:e.list,format:e.format});else{var i=C(3);r.reject(i)}}));return r}function U(e,r){return r||(r=new I),new A({url:e.url,type:"text"}).then((function(n){D(n.res.response,"string").then((function(n){r.resolve(t(t({},n),e))})).catch((function(e){r.reject(e)}))})).catch((function(n){var i=C(1,t({statusText:n.statusText,status:n.status,type:n.type,message:"http load error",url:e.src},e));r.reject(i)})),r}function W(e,t){return!!(e.id&&t.id&&e.id===t.id||e.language&&t.language&&e.language===t.language)}function H(e){return null!==e&&""!==e.trim()&&/^[a-zA-Z]+$/.test(e)}function V(e){return!!/[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F]/.test(e)}var $=function(){function e(){var t=this;n(this,e),this.__handlers=[],window.ResizeObserver&&(this.observer=new window.ResizeObserver((function(e){t.__trigger(e)})))}return s(e,[{key:"addObserver",value:function(e,t){if(this.observer){this.observer&&this.observer.observe(e);for(var r=this.__handlers,n=-1,i=0;i<r.length;i++)r[i]&&e===r[i].target&&(n=i);n>-1?this.__handlers[n].handler.push(t):this.__handlers.push({target:e,handler:[t]})}}},{key:"unObserver",value:function(e){var t=-1;this.__handlers.map((function(r,n){e===r.target&&(t=n)})),this.observer&&this.observer.unobserve(e),t>-1&&this.__handlers.splice(t,1)}},{key:"destroyObserver",value:function(){this.observer&&this.observer.disconnect(),this.observer=null,this.__handlers=null}},{key:"__runHandler",value:function(e,t){for(var r=this.__handlers,n=0;n<r.length;n++)if(r[n]&&e===r[n].target){r[n].handler&&r[n].handler.forEach((function(r){try{r(e,t)}catch(n){console.error(n)}}));break}}},{key:"__trigger",value:function(e){var t=this;e.map((function(e){var r=e.contentRect;t.__runHandler(e.target,r)}))}}]),e}(),F=null;var X="resize",G="change",Y="off";function J(e){var t=[];return e&&"String"===q(e)?t.push({url:e,index:0,start:-1,end:-1}):"Array"===q(e)&&e.forEach((function(e,r){t.push({url:e.url||e.src,index:r,start:e.start||-1,end:e.end||-1})})),t}var K=!1,Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(f,e);var i=h(f);function f(e){var t,r,s,a,l,h,d;return n(this,f),o(c(t=i.call(this)),"_onPause",(function(){t.stopRender()})),o(c(t),"_onPlay",(function(){t._curRenderTask.length>0&&t.startRender(-1)})),o(c(t),"_onTimeupdate",(function(){if(t._isOpen){var e=t.player.video,r=e.videoWidth,n=e.videoHeight;!t._videoMeta.scale&&r&&n&&t._onResize(t.player.root);var i=t._getPlayerCurrentTime();Math.round(Math.abs(1e3*i-t._ctime))<200||(t._ctime=1e3*i,t.currentText&&t.currentText.list&&("live"===t.config.updateMode?t._liveUpdate(i):t._update(i)))}})),o(c(t),"_onResize",(function(e){var r=c(t),n=r._videoMeta;if(r.config.domRender){if(e&&e instanceof window.Element||(e=t.player.root),t._iId&&(clearTimeout(t._iId),t._iId=null),!n.scale){if(!t.player.video)return;var i=t.player.video,s=i.videoWidth,o=i.videoHeight;if(!s||!o)return;n.videoWidth=s,n.videoHeight=o,n.scale=parseInt(o/s*100,10)}t.__startResize(e)}})),o(c(t),"_onCoreEvents",(function(e){try{switch(e.eventName){case"core.subtitlesegments":t._onSubtitleSegment(e.list||[]);break;case"core.subtitleplaylist":t._onSubtitlePlaylist(e.list||[]);break;case"core.seipayloadtime":t._onCoreSeiintime(e)}}catch(r){console.error(r)}})),o(c(t),"startRender",(function(e){if(e>0&&t._renderIntervalId&&(window.cancelAnimationFrame(t._renderIntervalId),t._renderIntervalId=-1),t.textTrack){var r=c(t)._curRenderTask;t._lastTimeStamp=(new Date).getTime();var n=[];r.forEach((function(r,i){var s=r.lastTime,o=r.wordList,a=r.interval,l=r.dom,c=r.ids;if(e<0||t._lastTimeStamp<0||t._lastTimeStamp-s>=a){var u=o.shift();u&&l.appendData(u),r.lastTime=t._lastTimeStamp}o.length<1&&n.push({index:i,ids:c})})),t._log(">>>>_renderByWords emptyArr",n.length,r.length),n.forEach((function(e){r.splice(e.index,1),t._log(">>>_renderByWords remove emptyArr",e.index,r.length)})),r.length>0&&(t._renderIntervalId=window.requestAnimationFrame(t.startRender))}})),o(c(t),"destroy",(function(){t.detachPlayer(),t.removeAllListeners(),t.player=null,t.textTrack=null,t._curRenderTask=[],t.stopRender()})),r=navigator.userAgent,s=/(?:Windows Phone)/.test(r),a=/(?:SymbianOS)/.test(r)||s,l=/(?:Android)/.test(r),h=/(?:Firefox)/.test(r),d=/(?:iPad|PlayBook)/.test(r)||l&&!/(?:Mobile)/.test(r)||h&&/(?:Tablet)/.test(r),K=/(?:iPhone)/.test(r)&&!d||l||a||d,t.currentText=null,t.currentExtText=null,t.textTrack=[],t._cid=-1,t._gid=-1,t._cids=[],t._iId=null,t._iC=0,t.player=null,t.root=null,t.config={line:"double",bottom:0,mode:"stroke",defaultOpen:!1,baseSizeX:49,baseSizeY:28,minSize:16,minMobileSize:13,fitVideo:!0,offsetBottom:2,fontColor:"#fff",domRender:!0,updateMode:"vod",renderMode:"",debugger:!1},t._ctime=0,t._loadingTrack={},Object.keys(t.config).map((function(r){void 0!==e[r]&&null!==e[r]&&(t.config[r]=e[r])})),t._isOpen=t.config.defaultOpen||!1,t._videoMeta={scale:0,videoHeight:0,videoWidth:0,lwidth:0,lheight:0,vWidth:0,vHeight:0,vBottom:0,vLeft:0,marginBottom:0},e.subTitles&&"Array"===q(e.subTitles)?(e.player&&t.attachPlayer(e.player),t.seiTime=0,t.lastSeiTime=0,t._curTexts=[],t._curRenderTask=[],t._renderIntervalId=-1,t._lastTimeStamp=-1,t.setSubTitles(e.subTitles,t.config.defaultOpen),t):u(t)}return s(f,[{key:"version",get:function(){return"3.0.20-rc.6"}},{key:"setSubTitles",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this._isOpen||r;n&&this.innerRoot&&this.switchOff(),this.currentText=null,this.textTrack=[],t.forEach((function(t){var r={};Object.keys(t).map((function(e){r[e]=t[e]})),r.url=J(r.url),r.isDefault&&(e.currentText=r),e.textTrack.push(r)})),this._log("setSubTitles",i),i&&this.switch().catch((function(t){e._log("[switch]",t)})),this.currentText&&this._loadTrack(this.currentText).then((function(t){e.addStyles(t)})),this.emit("reset",{list:this.textTrack,isOpen:i})}},{key:"updateSubTitle",value:function(e){for(var t=this,r=-1,n=0;n<this.textTrack.length;n++)if(W(e,this.textTrack[n])){r=n;break}if(this._log("updateSubTitle",r,e),r>-1){var i=W(this.currentText,this.textTrack[r]);if(this._log("updateSubTitle","_isCurrent",i,"this.isOpen",this.isOpen,this.currentText),!i)return;var s=J(e.url);this.isOpen?(s.forEach((function(e){t.textTrack[r].url.push(e)})),this._log("updateSubTitle _loadTrackUrls",this.textTrack[r]),this._loadTrackUrls(this.currentText,2)):this.textTrack[r].url=s}}},{key:"addStyles",value:function(e){var t=e.styles,r=e.format;t&&"vtt"===r&&(t.map((function(e){e.key||(e.key="xg-text-track-span")})),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r="";e.map((function(e){r+=" ".concat(t," ").concat(e.key," {").concat(e.style,"}")}));var n=document.createElement("style"),i=document.head||document.getElementsByTagName("head")[0];if(n.type="text/css",n.id="ssss",n.styleSheet){var s=function(){try{n.styleSheet.cssText=r}catch(e){}};n.styleSheet.disabled?setTimeout(s,10):s()}else{var o=document.createTextNode(r);n.appendChild(o)}i.appendChild(n)}(t,"xg-text-track"))}},{key:"attachPlayer",value:function(e){var t=this;if(this._log("attachPlayer"),e){this.player&&this.detachPlayer();var r,n,i=this.config,s=i.fontColor,o=i.mode,a=i.fitVideo,l=i.domRender;this.player=e,l&&(this.root=document.createElement("xg-text-track"),this.root.className="xg-text-track",!this._isOpen&&L(this.root,"text-track-hide"),!a&&L(this.root,"text-track-no-fitvideo"),o&&L(this.root,"text-track-".concat(o)),this.innerRoot=document.createElement("xg-text-track-inner"),this.root.appendChild(this.innerRoot),s&&(this.root.style.color=s),this.currentText&&["language","id","label"].map((function(e){t.root.setAttribute("data-".concat(e),t.currentText[e]||"")})),this.player.root.appendChild(this.root),r=e.root,n=this._onResize,F||(F=new $),F.addObserver(r,n)),this.player.on("destroy",this.destroy),this.player.on("timeupdate",this._onTimeupdate),this.player.on("pause",this._onPause),this.player.on("play",this._onPlay),this.player.on("core_event",this._onCoreEvents),this._isOpen&&this.switch().catch((function(e){t._log("[switch]",e)}))}}},{key:"detachPlayer",value:function(){var e,t,r=this.player,n=this.config;r&&(r.off("destroy",this.destroy),r.off("timeupdate",this._onTimeupdate),r.off("pause",this._onPause),r.off("play",this._onPlay),r.off("core_event",this._onCoreEvents),n.domRender&&(r.root&&(e=r.root,t=this._onResize,F&&F.unObserver(e,t),r.root.removeChild(this.root)),this.innerRoot=null,this.root=null),this.player=null)}},{key:"switch",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:"",language:""};return this._log("switch",t),this._loadingTrack=t,new Promise((function(r,n){if(t.id||t.language)if(e.currentText&&W(t,e.currentText))e._loadingTrack={},e._updateCurrent(e.currentText),e.switchOn(),r(C(0));else{var i=null;e.__removeByTime(e._curTexts,0);for(var s=0;s<e.textTrack.length;s++)if(W(t,e.textTrack[s])){i=e.textTrack[s];break}if(e._log("nextSubtitle",i),i)e._emitPlayerSwitch(e.currentText,i),i.list?(e._loadingTrack={},e._updateCurrent(i),e.switchOn(),r(C(0))):(e._log("this._loadTrack",i),e._updateCurrent(i),e._loadTrack(i).then((function(t){if(e.addStyles(t),e._loadingTrack.id===i.id||e._loadingTrack.language===t.language)e._loadingTrack={},e._updateCurrent(t),e.switchOn(),r(C(0));else{var s=C(6,{message:"check _loadingTrack fail id: ".concat(e._loadingTrack.id," nextSubtitle:").concat(t.id)});n(s)}})).catch((function(e){n(e)})));else{var o=C(4,new Error("The is no subtitle with id:[{".concat(t.id,"}] or language:[").concat(t.language,"]")));n(o)}}else{if(e.currentText){e._loadingTrack={},e._updateCurrent(e.currentText),e.switchOn();var a=C(0,{message:"switch default subtitle success"});return void r(a)}var l=C(5,{message:"no default subtitle"});n(l)}}))}},{key:"switchExt",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:"",language:""};return new Promise((function(r,n){if(t.id||t.language){for(var i=null,s=0;s<e.textTrack.length;s++)if(W(t,e.textTrack[s])){i=e.textTrack[s];break}i&&!W(i,e.currentText)&&e._loadTrack(i).then((function(t){e.currentExtText=t,r(C(0))}))}else e.currentExtText=null,r(C(0))}))}},{key:"switchOn",value:function(){this._log("switchOn"),this._isOpen=!0,this.show(),this.emit(G,this.currentText)}},{key:"switchOff",value:function(){this._isOpen=!1,this.hide(),this.emit(Y)}},{key:"isOpen",get:function(){return this._isOpen}},{key:"_log",value:function(){if(this.config.debugger){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];(e=console).log.apply(e,["[xgSubtitle]"].concat(r))}}},{key:"_loadTrack",value:function(e){var t=this;this._log("_loadTrack",e.language,e);var r=new I,n="",i="";if(e.json?(n="json",i=e.json):e.stringContent&&!e.url&&(n="string",i=e.stringContent),i)return D(i,n).then((function(t){e.format=t.format,e.styles=t.styles,e.list=t.list,r.resolve(e)})).catch((function(e){r.reject(e)})),r;var s=e.url;return 0===s.length?(r.resolve(e),r):(U(s.splice(0,1)[0]).then((function(n){e.format=n.format,e.styles=n.styles,e.list||(e.list=[]),t._pushList(e.list,n.list),s.length>1&&t._loadTrackUrls(e,2),r.resolve(e)})).catch((function(e){r.reject(e)})),r)}},{key:"_emitPlayerSwitch",value:function(e,r){e&&"live"===this.config.updateMode&&(e.list=[],e.url=[]);var n=t({lang:r.language},r);this._log("emit subtile_switch ",r,n),this.player&&this.player.emit("switch_subtitle",n)}},{key:"_loadTrackUrls",value:function(e,r,n){var i=this,s=e.url.length,o=s>r?e.url.splice(0,r):e.url.splice(0,s),a=o.length;this._log("_loadTrackUrls",e.language,s,o.length,a),o.forEach((function(r,s){U(t(t({},r),{},{index:s})).then((function(t){e.format=t.format,e.styles=t.format,e.list||(e.list=[]),i._pushList(e.list,t.list),a--})).catch((function(e){a--})).finally((function(t){0===a&&(n&&n.resolve(e),i._loadTrackUrls(e,2))}))}))}},{key:"_freshUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{url:""},r=-1;e.url.forEach((function(e,n){e.url===t.url&&(r=n)})),r>-1&&e.url.splice(r,1)}},{key:"_pushList",value:function(e,t){var r=t[0].start,n=t[t.length-1].end;if(0===e.length||r>=e[e.length-1].end)t.forEach((function(t){e.push(t)}));else{for(var i=-1,s=0;s<e.length;s++)if(e[s].start>n){i=s;break}i>-1&&t.forEach((function(t,r){e.splice(i+r,0,t)}))}return e}},{key:"_updateCurrent",value:function(e){var t=this;this.currentText=e,this.config.domRender&&this.root&&(["language","id","label"].map((function(e){t.root.setAttribute("data-".concat(e),t.currentText[e]||"")})),this.__remove(this._cids)),this._cids=[],this._gid=-1,this._cid=-1,this._curTexts=[];var r=this._getPlayerCurrentTime();r&&("live"===this.config.updateMode?this._liveUpdate(r):this._update(r))}},{key:"__loadAll",value:function(){var e=this;this.textTrack.forEach((function(t){e._loadTrack(t)}))}},{key:"getDelCid",value:function(e,t){for(var r=[],n=0;n<e.length;n++)t.includes(e[n])||r.push(e[n]);return r}},{key:"getNewCid",value:function(e,t){for(var r=[],n=0;n<t.length;n++)e.includes(t[n])||r.push(t[n]);return r}},{key:"_liveUpdate",value:function(e){var t=this;if(this.currentText&&this.currentText.list&&this.currentText.list.length){var r=[],n=M(e,this.currentText.list,this._gid);if(n>-1&&(r=B(e,this.currentText.list[n].list,this._cid)),this.__removeByTime(this._curTexts,e),this._log("_liveUpdate",e,n,r,this.currentText.list[0].list[0].start,this.currentText.list[0].list[0].end),r.length>0){var i=function(e,t,r){if(0===e.length||t<0||t>e.length-1)return[];var n=e[t].list;if(0===r.length)return[];var i=n.splice(r[0],r.length);return t>0&&e.splice(0,t),0===n.length&&e.splice(0,1),i}(this.currentText.list,n,r),s=this._curTexts.length,o=s>0?this._curTexts[s-1].index:0;i.forEach((function(e,r){e.index=r+o,t._curTexts.push(e)})),this.__render(i)}this.emit("update",this._curTexts)}}},{key:"_update",value:function(e){var t=this;if(this.currentText&&this.currentText.list&&this.currentText.list.length){var r=M(e,this.currentText.list,this._gid),n=[];if(r>-1&&(n=B(e,this.currentText.list[r].list,this._cid)),n.length<1)return this._cids.length>0&&this.config.domRender&&this.__remove(this._cids),void(this._cids=[]);if(this._cids!==n||r!==this._gid){this._gid=r,this._cid=n[0];var i=this.getDelCid(this._cids,n),s=this.getNewCid(this._cids,n);this._cids=n,this.config.domRender&&this.__remove(i);var o=[];s.map((function(e){var n=t.currentText.list[r].list[e];n.index=e,o.push(n)})),this.currentExtText&&s.map((function(e){var n=t.currentText.list[r].list[e];n.index=e,o.push(n)})),this._log("update",o,e),this.emit("update",o),this.__render(o,e)}}}},{key:"_getPlayerCurrentTime",value:function(){if(!this.player)return 0;var e=this.player.currentTime;return parseInt(1e3*e+1e3*this.seiTime-1e3*this.lastSeiTime,10)/1e3}},{key:"_onSubtitlePlaylist",value:function(e){this._log("_onSubtitlePlaylist",e);var t=e.map((function(e){return{label:e.name,language:e.lang,id:e.id,isDefault:e.default,url:[],mUrl:e.url}}));this.setSubTitles(t)}},{key:"_onSubtitleSegment",value:function(e){if(this._log("_onSubtitleSegment",e.length,e[0].lang,e[0].sn,e[e.length-1].sn,e[0].start,e[e.length-1].end),e&&0!==e.length){var t={language:e[0].lang,url:e.map((function(e){return{id:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end}}))};W(t,this.currentText)&&this.updateSubTitle(t)}}},{key:"_onCoreSeiintime",value:function(e){try{var t=e.time/1e3;this._log("_onCoreSeiintime sei",t,this.seiTime,this.lastSeiTime),this.seiTime=t,this.lastSeiTime=this.player?this.player.currentTime:0}catch(r){}}},{key:"resize",value:function(e,t){var r,n=this,i=this.config,s=i.baseSizeX,o=i.baseSizeY,a=i.minMobileSize,l=i.minSize,c=i.fitVideo,u=i.offsetBottom,h=this._videoMeta.scale;this._videoMeta.lwidth=e,this._videoMeta.lheight=t;var f=0;t/e*100>=h?(f=parseInt(h*e,10)/100,r=e):(f=t,r=parseInt(t/h*100,10)),this._videoMeta.vWidth=r,this._videoMeta.vHeight=f;var d=0,p=0;h>120?(d=o,p=parseInt(d*f/1080,10)):(d=s,p=parseInt(d*r/1920,10));var v=K?a:l,g={fontSize:p=p<v?v:p>d?d:p},m=parseInt((t-f)/2,10),y=parseInt((e-r)/2,10),_=parseInt(f*u,10)/100;this._videoMeta.vBottom=m,this._videoMeta.vLeft=y,this._videoMeta.marginBottom=_,c&&(g.bottom=m+_,g.left=g.right=y),Object.keys(g).map((function(e){n.root.style[e]="".concat(g[e],"px")})),this.emit(X,{vLeft:y,vBottom:m,marginBottom:_,vWidth:r,vHeight:f,fontSize:p,scale:h})}},{key:"__startResize",value:function(e){var t=this,r=e.getBoundingClientRect(),n=this._videoMeta,i=r.width,s=r.height;if(this._iId&&(clearTimeout(this._iId),this._iId=null),i>0&&s>0&&(i!==n.lwidth||s!==n.lheight))this._iC=0,this.resize(i,s);else{if(this._iC>=5)return void(this._iC=0);this._iC++,this._iId=setTimeout((function(){t.__startResize(e)}),50)}}},{key:"__removeByTime",value:function(e,t){for(var r=[],n=0;n<e.length;n++)(!t||e[n].end<t)&&r.push(n);0!==r.length&&(e.splice(r[0],r.length),this.config.domRender&&this.__remove(r))}},{key:"__remove",value:function(e){var t=this;if(e&&!(e.length<1)){this._log(">>>>_renderByWords__remove",e);for(var r=this.innerRoot.children,n=[],i=0;i<r.length;i++){var s=Number(r[i].getAttribute("data-index"));e.includes(s)&&n.push(r[i])}n.map((function(e){t.innerRoot.removeChild(e)}))}}},{key:"__render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this._log("__render",t.length,this.config.domRender);var r=this.config,n=r.renderMode,i=r.domRender;t.length>0&&i&&t.forEach((function(t){var r="text-track-".concat(e.config.line);t.text.forEach((function(i,s){s>0&&(r+=" text-track-deputy");var o={"data-start":t.start,"data-end":t.end,"data-index":t.index},a=z("xg-text-track-span","",o,r);if(e.innerRoot.appendChild(a),"step"===n){var l=z("xg-text-track-span","",o,"".concat(r," text-track-space"));e.innerRoot.appendChild(l),l.innerHTML=i,setTimeout((function(){e._renderByWords(a,s,t.start,t.end,i)}),600)}else a.innerHTML=i}))}))}},{key:"_renderByWords",value:function(e,t,r,n,i){var s=document.createTextNode("");e.appendChild(s);var o=function(e){for(var t=e.split(""),r=[],n=!1,i=0;i<t.length;i++){var s=t[i];if(H(s))if(n){var o=r.length-1;r[o]="".concat(r[o]).concat(s)}else r.push(s),n=!0;else if(s.match(/^[ ]*$/)||V(s)||/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(s)){n=!1;var a=r.length-1;r[a]="".concat(r[a]).concat(s)}else n=!1,r.push(s)}return r}(i),a=this._getPlayerCurrentTime(),l=parseInt(1e3*(n-a),10);if(!(a>=n)){r>=a&&(a=r),l>300&&(l-=50);var c={dom:s,ids:t,wordList:o,interval:l/o.length,start:a,end:n,duration:l,lastTime:0};this._log(">>>>_renderByWords",l,c);for(var u=this._curRenderTask,h=-1,f=0;f<u.length;f++)if(u[f].ids===t){h=f;break}h>-1&&u.slice(h,1),u.push(c),this.startRender(-1)}}},{key:"stopRender",value:function(){this._renderIntervalId&&window.cancelAnimationFrame(this._renderIntervalId)}},{key:"show",value:function(){var e,t;this.config.domRender&&(e=this.root,t="text-track-hide",e&&(e.classList?t.split(/\s+/g).forEach((function(t){e.classList.remove(t)})):N(e,t)&&t.split(/\s+/g).forEach((function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===r(e.className)?e.setAttribute("class",e.getAttribute("class").replace(n," ")):e.className=e.className.replace(n," ")}))))}},{key:"hide",value:function(){this.config.domRender&&(L(this.root,"text-track-hide"),this.innerRoot.innerHTML="")}},{key:"emit",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"emit",this)).call.apply(r,[this,e,t].concat(i))}},{key:"on",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"on",this)).call.apply(r,[this,e,t].concat(i))}},{key:"once",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"once",this)).call.apply(r,[this,e,t].concat(i))}},{key:"off",value:function(e,t){for(var r,n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];(r=d(a(f.prototype),"off",this)).call.apply(r,[this,e,t].concat(i))}},{key:"offAll",value:function(){d(a(f.prototype),"removeAllListeners",this).call(this)}},{key:"marginBottom",get:function(){var e=this._videoMeta,t=e.bottom,r=e.marginBottom;return this.config.fitVideo?t+r:r}}]),f}(g);return Z})); | ||
//# sourceMappingURL=index.min.js.map |
@@ -215,3 +215,3 @@ import { inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, possibleConstructorReturn as _possibleConstructorReturn, objectSpread2 as _objectSpread2, get as _get, getPrototypeOf as _getPrototypeOf } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
get: function get() { | ||
return "3.0.20-rc.5"; | ||
return "3.0.20-rc.6"; | ||
} | ||
@@ -218,0 +218,0 @@ }, { |
{ | ||
"name": "xgplayer-subtitles", | ||
"version": "3.0.20-rc.5", | ||
"version": "3.0.20-rc.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.min.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package