From ce76e2dbdd2113a657377a1ad02957dbe3a206e1 Mon Sep 17 00:00:00 2001 From: Tooko <18x@loacg.com> Date: Wed, 30 May 2018 14:39:38 +0800 Subject: [PATCH] push to npm --- .DS_Store | Bin 6148 -> 10244 bytes .gitignore | 2 +- .webpack/prod.js | 4 +- dist/mplayer.css | 2 + dist/mplayer.css.map | 1 + dist/mplayer.js | 2 + dist/mplayer.js.map | 1 + package-lock.json | 8807 ++++++++++++++++++++++++++++++++++++++++++ package.json | 8 +- webpack.config.js | 6 +- 10 files changed, 8823 insertions(+), 10 deletions(-) create mode 100644 dist/mplayer.css create mode 100644 dist/mplayer.css.map create mode 100644 dist/mplayer.js create mode 100644 dist/mplayer.js.map create mode 100644 package-lock.json diff --git a/.DS_Store b/.DS_Store index 506f87b42a2f0614e8cbd179bc32f631b331200f..2742f3f00a7111edeecaa4b484640d40cf13a36c 100644 GIT binary patch literal 10244 zcmeI1Yitx%6vxkL3(QU6!uYN`ba?OQn{V+m})vLTI7oS@tosquZUjGu!eI zQzhafM&l#V1c*lcVn9huNR*hE_)cn6V&f~(82w`WWF(pxlYiWjLTXGkuSHW^`95 z=q@}kB-{Zb(t3L@16~F$&H!J#7eN9{u))b&zptXPs$az>0<(UxVSCVB=a0q)lcw#| z)qR8og+fi|#&EATyVXiL zQ8Q(vbKG}#o2i5~++t-?30r*6mZ;NDvEoF%n*Z?Oa9w@4IuvfGJ5n8@Mguh(m)9LR zq9|pR;WZum1`ZxNeA|)RkIUJkTS1^ywzK;abd;T9(jID+Q!IFFe2O1ur^sgN9qZY~ zUTxM8UHRrg$Fx%Rb|Y<*?bS+cntMmwN^MCSe7rkuB{KslyI1qYqse$C8Fh^2WU|vd zWY|59alqk6J8diNvo_+HoV5FjIXyDd{Q4+;19b)rVWvu2giu7@J!*Pt*PS z{K=vetwQO^#LQbWrgLyiyP~vYLAlO$C+Jc(Sqc7a3GJ++ijj(PUEjq=TGIyY6N)0b z7gg!3%jQ=cbsei~80)%)?xtp|GBjMz^liy#%t&epRfer-WP10I%%rx#?Oe5*={<34 zV1TA#`>@*Wjx_7~UVi3{QQO%(Xr$<>-lo%w*_G=zD#{K%+MGzxRaHc)c48l>kA0B`Q;W#`4r{M*78Qy}oVHDnh^YAHr317o^Z~?xDAK+J1 za1NH?Jk)U^*5Wd(!zNsd5p2d5+<;qfD|TWR?!h=3xF7p)5D(xXJdC&DUHAY#gb(8* zcmhx1bND=-!58r*JcqC28~84MfMfFd3dZHS$-Q3J;AeD@D_8dyS+Ms~a`m_0z}Edg za{Z*3Yt%RE%Gq-kR8-Z}H?D5Z-pjnZmn$Qo9VreWnsHHx+c!ap{C?~H01Hm0=53@o z!w4w>I=>AIoB83F46^K!`#7~}4MJtrf%UD<;fojv_XaifJl7zJ) zIoiZlDWp_w`j}oeZ|<74jA_7sX{z+D^ix6n>*{+7PQf{NlXQ0;K7`NVEBF?EM8p~B z6N(Gqd|ZHwunL#pQmnxh*ht!2iL0?4Z@_ifLHg^$ZP<-HxRdmk5c)GQjW%X*h;(=d z9>rsLH{Rpw@KHR8PvO&fs_V#8-RWG_4RxkdNh{SyeO#rCD3T(U7;u1oQT^b+03`F6 z@+|q~GNqUzED_U7-ux&7N%{tRVjPxT6gLP_h{G+k?<4>={ge=BY>0g@f=bX(izea&-3DQzl7K2M$_=} z2BK+w_@C3%O~aqDG;kTQ)HjQ<9A@U@biBlfD&)ga`jwZ+@)MZMHOo|D*(ic**@!m_(L(8?=fUPTtOYcCH3a!C3&su^eL88{2C5KG^I_uzfO(l6i}V(Cxt zGyEc0s^Uy67A&p6s|8DWJzFDKx)E=}&4Q(SaUVtnOK+uG<_MM^!+Y^Q!P1lX1U@NP z`YOKmmst9{SpSfu!Kpw}NzBO+$CD24ZEAcpBu*>zZhEx_Id0BxP$^gdSN(RSg75)yg1K)PISjq_=5U zN+i{Zqd`H^#l+ESLDK7pqpJi-ZzPVc7bM+I9Ni&EYLNE&k(1ORjt&cw-bv4M$NmOM zUCrfj)Ca>vrx>wG60VjwM`VNj#MeGax`|{Fbj&4-3I{1RO)<4ZQ;TylFM=~JH-ehp zHpMbfDCZmE@BiB;|NnoAWyPDWmw~C30W50kY-^!8kH2cjpFV%r9-_}a`tXhWjYum( wXeVCBlNGPysli{zix)1`H~yxD$3>{0+YxE$h_?Uy&j7!-{`c1ZQ+xgY8>Xyo^Z)<= delta 265 zcmZn(XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jG-bU^g=(-((&Ed&ZNKeFPdb zC91294GeS?bS=zlbrh=2&4FwaW3$>?4i0fuLtD>;+{&uzn%cUVlfMhdGtSyDogz9j3in4N<|kQpcf666LFt{~rREd0(qnP0^d1?e-1:0),i=1;i ";r.forEach(function(t){h+=t+", "}),h=h.substring(0,h.length-2),console.log(h)}}}},{key:"setLevel",value:function(t){this.level=t}},{key:"setType",value:function(t){this.type=t}},{key:"typeToName",value:function(t){var e;for(var r in s)if(t==s[r]){e=r;break}return e}}]),t}();e.default=new l("logger")},function(t,e,r){"use strict";function i(t){return f[t]||(f[t]=0),t+ ++f[t]}function n(t){return value-parseFloat(value)+1>=0}function a(t){return"object"===(void 0===t?"undefined":u(t))?"[object Array]"===Object.prototype.toString.call(t):t instanceof Array}function s(t){var e,r;return e=Math.floor(t/60),e<10&&(e="0"+e),r=Math.floor(t%60),r<10&&(r="0"+r),e+":"+r}function o(t,e){return t0&&void 0!==arguments[0]?arguments[0]:document;t.exitFullscreen?t.exitFullscreen():t.webkitCancelFullScreen?t.webkitCancelFullScreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},c=e.requestAnimationFrame=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}).bind(window),h=e.cancelAnimationFrame=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window),f={};e.default={Fullscreen:d,requestAnimationFrame:c,cancelAnimationFrame:h,formatTime:s,uniqueId:i,isNumber:n,seekToSecondsText:o,now:l}},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(){function t(t,e){for(var r=0;r "+e}function a(t){var e=self.console[t];return e?function(){for(var r=arguments.length,i=Array(r),a=0;a1?e-1:0),i=1;i0)return e.subarray(i,i+n)},t._readSize=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},t.getTimeStamp=function(e){for(var r=t.getID3Frames(e),i=0;i1&&void 0!==arguments[1]&&arguments[1],r=t.length,i=void 0,n=void 0,a=void 0,s="",o=0;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:s+=String.fromCharCode(i);break;case 12:case 13:n=t[o++],s+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=t[o++],a=t[o++],s+=String.fromCharCode((15&i)<<12|(63&n)<<6|(63&a)<<0)}}return s},t}(),a=n._utf8ArrayToStr;e.a=n},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t){var e=t.byteLength,r=e&&new DataView(t).getUint8(e-1);return r?t.slice(0,e-r):t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var l=function(){function t(e,r){i(this,t),this.subtle=e,this.aesIV=r}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}(),u=l,d=function(){function t(e,r){n(this,t),this.subtle=e,this.key=r}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}(),c=d,h=function(){function t(){a(this,t),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return t.prototype.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},t.prototype.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],c=o[3],h=new Uint32Array(256),f=0,p=0,v=0;for(v=0;v<256;v++)h[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var y=p^p<<1^p<<2^p<<3^p<<4;y=y>>>8^255&y^99,t[f]=y,e[y]=f;var g=h[f],m=h[g],b=h[m],E=257*h[y]^16843008*y;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*b^65537*m^257*g^16843008*f,l[y]=E<<24|E>>>8,u[y]=E<<16|E>>>16,d[y]=E<<8|E>>>24,c[y]=E,f?(f=g^h[h[h[b^g]]],p^=h[h[p]]):f=p=1}},t.prototype.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,n,s,o;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(a(r)){for(o=s;o-- >0;)if(r[o]===e||r[o].listener&&r[o].listener===e){n=o;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=r(0),a=r(1),s=Math.pow(2,32)-1,o=function(){function t(e,r){i(this,t),this.observer=e,this.remuxer=r}return t.prototype.resetTimeStamp=function(t){this.initPTS=t},t.prototype.resetInitSegment=function(e,r,i,n){if(e&&e.byteLength){var s=this.initData=t.parseInitSegment(e);null==r&&(r="mp4a.40.5"),null==i&&(i="avc1.42e01e");var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:n?e:null}:(s.audio&&(o.audio={container:"audio/mp4",codec:r,initSegment:n?e:null}),s.video&&(o.video={container:"video/mp4",codec:i,initSegment:n?e:null})),this.observer.trigger(a.a.FRAG_PARSING_INIT_SEGMENT,{tracks:o})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)},t.probe=function(e){return t.findBox({data:e,start:0,end:Math.min(e.length,16384)},["moof"]).length>0},t.bin2str=function(t){return String.fromCharCode.apply(null,t)},t.readUint16=function(t,e){t.data&&(e+=t.start,t=t.data);var r=t[e]<<8|t[e+1];return r<0?65536+r:r},t.readUint32=function(t,e){t.data&&(e+=t.start,t=t.data);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return r<0?4294967296+r:r},t.writeUint32=function(t,e,r){t.data&&(e+=t.start,t=t.data),t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r},t.findBox=function(e,r){var i=[],n=void 0,a=void 0,s=void 0,o=void 0,l=void 0,u=void 0,d=void 0;if(e.data?(u=e.start,o=e.end,e=e.data):(u=0,o=e.byteLength),!r.length)return null;for(n=u;n1?n+a:o,s===r[0]&&(1===r.length?i.push({data:e,start:n+8,end:d}):(l=t.findBox({data:e,start:n+8,end:d},r.slice(1)),l.length&&(i=i.concat(l)))),n=d;return i},t.parseSegmentIndex=function(e){var r=t.findBox(e,["moov"])[0],i=r?r.end:null,n=0,a=t.findBox(e,["sidx"]),s=void 0;if(!a||!a[0])return null;s=[],a=a[0];var o=a.data[0];n=0===o?8:16;var l=t.readUint32(a,n);n+=4;n+=0===o?8:16,n+=2;var u=a.end+0,d=t.readUint16(a,n);n+=2;for(var c=0;c>>31)return void console.warn("SIDX has hierarchical references (not supported)");var v=t.readUint32(a,h);h+=4,s.push({referenceSize:p,subsegmentDuration:v,info:{duration:v/l,start:u,end:u+p-1}}),u+=p,h+=4,n=h}return{earliestPresentationTime:0,timescale:l,version:o,referencesCount:d,references:s,moovEndOffset:i}},t.parseInitSegment=function(e){var r=[];return t.findBox(e,["moov","trak"]).forEach(function(e){var i=t.findBox(e,["tkhd"])[0];if(i){var a=i.data[i.start],s=0===a?12:20,o=t.readUint32(i,s),l=t.findBox(e,["mdia","mdhd"])[0];if(l){a=l.data[l.start],s=0===a?12:20;var u=t.readUint32(l,s),d=t.findBox(e,["mdia","hdlr"])[0];if(d){var c=t.bin2str(d.data.subarray(d.start+8,d.start+12)),h={soun:"audio",vide:"video"}[c];if(h){var f=t.findBox(e,["mdia","minf","stbl","stsd"]);if(f.length){f=f[0];var p=t.bin2str(f.data.subarray(f.start+12,f.start+16));n.b.log("MP4Demuxer:"+h+":"+p+" found")}r[o]={timescale:u,type:h},r[h]={timescale:u,id:o}}}}}}),r},t.getStartDTS=function(e,r){var i=void 0,n=void 0,a=void 0;return i=t.findBox(r,["moof","traf"]),n=[].concat.apply([],i.map(function(r){return t.findBox(r,["tfhd"]).map(function(i){var n=void 0,a=void 0;return n=t.readUint32(i,4),a=e[n].timescale||9e4,t.findBox(r,["tfdt"]).map(function(e){var r=void 0,i=void 0;return r=e.data[e.start],i=t.readUint32(e,4),1===r&&(i*=Math.pow(2,32),i+=t.readUint32(e,8)),i})[0]/a})})),a=Math.min.apply(null,n),isFinite(a)?a:0},t.offsetStartDTS=function(e,r,i){t.findBox(r,["moof","traf"]).map(function(r){return t.findBox(r,["tfhd"]).map(function(n){var a=t.readUint32(n,4),o=e[a].timescale||9e4;t.findBox(r,["tfdt"]).map(function(e){var r=e.data[e.start],n=t.readUint32(e,4);if(0===r)t.writeUint32(e,4,n-i*o);else{n*=Math.pow(2,32),n+=t.readUint32(e,8),n-=i*o,n=Math.max(n,0);var a=Math.floor(n/(s+1)),l=Math.floor(n%(s+1));t.writeUint32(e,4,a),t.writeUint32(e,8,l)}})})})},t.prototype.append=function(e,r,i,n){var s=this.initData;s||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),s=this.initData);var o=void 0,l=this.initPTS;if(void 0===l){var u=t.getStartDTS(s,e);this.initPTS=l=u-r,this.observer.trigger(a.a.INIT_PTS_FOUND,{initPTS:l})}t.offsetStartDTS(s,e,l),o=t.getStartDTS(s,e),this.remuxer.remux(s.audio,s.video,null,null,o,i,n,e)},t.prototype.destroy=function(){},t}();e.a=o},function(t,e,r){"use strict";function i(t,e,r,i){var n=void 0,a=void 0,s=void 0,o=void 0,l=void 0,u=navigator.userAgent.toLowerCase(),d=i,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return n=1+((192&e[r+2])>>>6),(a=(60&e[r+2])>>>2)>c.length-1?void t.trigger(Event.ERROR,{type:A.b.MEDIA_ERROR,details:A.a.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+a}):(o=(1&e[r+2])<<2,o|=(192&e[r+3])>>>6,_.b.log("manifest codec:"+i+",ADTS data:type:"+n+",sampleingIndex:"+a+"["+c[a]+"Hz],channelConfig:"+o),/firefox/i.test(u)?a>=6?(n=5,l=new Array(4),s=a-3):(n=2,l=new Array(2),s=a):-1!==u.indexOf("android")?(n=2,l=new Array(2),s=a):(n=5,l=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&a>=6?s=a-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(a>=6&&1===o||/vivaldi/i.test(u))||!i&&1===o)&&(n=2,l=new Array(2)),s=a)),l[0]=n<<3,l[0]|=(14&a)>>1,l[1]|=(1&a)<<7,l[1]|=o<<3,5===n&&(l[1]|=(14&s)>>1,l[2]=(1&s)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:c[a],channelCount:o,codec:"mp4a.40."+n,manifestCodec:d})}function n(t,e){return 255===t[e]&&240==(246&t[e+1])}function a(t,e){return 1&t[e+1]?7:9}function s(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function o(t,e){return!!(e+10&&e+o+l<=d)return u=r+i*n,{headerLength:o,frameLength:l,stamp:u}}function h(t,e,r,i,n){var a=d(t.samplerate),s=c(e,r,i,n,a);if(s){var o=s.stamp,l=s.headerLength,u=s.frameLength,h={unit:e.subarray(r+l,r+l+u),pts:o,dts:o};return t.samples.push(h),t.len+=u,{sample:h,length:u+l}}}function f(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function b(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var w=r(1),A=r(2),R=r(5),_=r(0),L=r(4),k=function(){function t(e,r,i){f(this,t),this.observer=e,this.config=i,this.remuxer=r}return t.prototype.resetInitSegment=function(t,e,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:e,duration:i,inputTimeScale:9e4}},t.prototype.resetTimeStamp=function(){},t.probe=function(t){if(!t)return!1;for(var e=L.a.getID3Data(t,0)||[],r=e.length,i=t.length;re.length)){var a=this.parseHeader(e,r);if(a&&r+a.frameLength<=e.length){var s=9e4*a.samplesPerFrame/a.sampleRate,o=i+n*s,l={unit:e.subarray(r,r+a.frameLength),pts:o,dts:o};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(l),t.len+=a.frameLength,{sample:l,length:a.frameLength}}}},parseHeader:function(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,n=t[e+2]>>4&15,a=t[e+2]>>2&3,s=t[e+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==a){var o=3===r?3-i:3===i?3:4,l=1e3*O.BitratesMap[14*o+n-1],u=3===r?0:2===r?1:2,d=O.SamplingRateMap[3*u+a],c=t[e+3]>>6==3?1:2,h=O.SamplesCoefficients[r][i],f=O.BytesInSlot[i],p=8*h*f;return{sampleRate:d,channelCount:c,frameLength:parseInt(h*l/d+s,10)*f,samplesPerFrame:p}}},isHeaderPattern:function(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])},isHeader:function(t,e){return!!(e+1t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},t.prototype.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&_.b.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0&&this.bitsAvailable?r<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},t.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},t.prototype.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},t.prototype.readBoolean=function(){return 1===this.readBits(1)},t.prototype.readUByte=function(){return this.readBits(8)},t.prototype.readUShort=function(){return this.readBits(16)},t.prototype.readUInt=function(){return this.readBits(32)},t.prototype.skipScalingList=function(t){var e=8,r=8,i=void 0,n=void 0;for(i=0;i=t.length)return void r();if(!(t[e].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(t,e,r,i),!i)return}}},t.prototype.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n<=t.length-16;n+=160,i+=16)r.set(t.subarray(n,n+16),i);return r},t.prototype.getAvcDecryptedUnit=function(t,e){e=new Uint8Array(e);for(var r=0,i=32;i<=t.length-16;i+=160,r+=16)t.set(e.subarray(r,r+16),i);return t},t.prototype.decryptAvcSample=function(t,e,r,i,n,a){var s=this.discardEPB(n.data),o=this.getAvcEncryptedData(s),l=this;this.decryptBuffer(o.buffer,function(o){n.data=l.getAvcDecryptedUnit(s,o),a||l.decryptAvcSamples(t,e,r+1,i)})},t.prototype.decryptAvcSamples=function(t,e,r,i){for(;;e++,r=0){if(e>=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var a=n[r];if(!(a.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(t,e,r,i,a,s),!s)return}}}},t}(),M=F,N={video:0,audio:1,id3:2,text:3},U=function(){function t(e,r,i,n){y(this,t),this.observer=e,this.config=i,this.typeSupported=n,this.remuxer=r,this.sampleAes=null}return t.prototype.setDecryptData=function(t){null!=t&&null!=t.key&&"SAMPLE-AES"===t.method?this.sampleAes=new M(this.observer,this.config,t,this.discardEPB):this.sampleAes=null},t.probe=function(e){var r=t._syncOffset(e);return!(r<0)&&(r&&_.b.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)},t._syncOffset=function(t){for(var e=Math.min(1e3,t.length-564),r=0;r>4>1){if((u=a+5+e[a+4])===a+188)continue}else u=a+4;switch(l){case y:o&&(E&&(d=k(E))&&void 0!==d.pts&&D(d,!1),E={data:[],size:0}),E&&(E.data.push(e.subarray(u,a+188)),E.size+=a+188-u);break;case g:o&&(T&&(d=k(T))&&void 0!==d.pts&&(p.isAAC?I(d):O(d)),T={data:[],size:0}),T&&(T.data.push(e.subarray(u,a+188)),T.size+=a+188-u);break;case m:o&&(S&&(d=k(S))&&void 0!==d.pts&&x(d),S={data:[],size:0}),S&&(S.data.push(e.subarray(u,a+188)),S.size+=a+188-u);break;case 0:o&&(u+=e[u]+1),b=this._pmtId=R(e,u);break;case b:o&&(u+=e[u]+1);var C=L(e,u,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);y=C.avc,y>0&&(f.pid=y),g=C.audio,g>0&&(p.pid=g,p.isAAC=C.isAAC),m=C.id3,m>0&&(v.pid=m),c&&!h&&(_.b.log("reparse from beginning"),c=!1,a=P-188),h=this.pmtParsed=!0;break;case 17:case 8191:break;default:c=!0}}else this.observer.trigger(w.a.ERROR,{type:A.b.MEDIA_ERROR,details:A.a.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E&&(d=k(E))&&void 0!==d.pts?(D(d,!0),f.pesData=null):f.pesData=E,T&&(d=k(T))&&void 0!==d.pts?(p.isAAC?I(d):O(d),p.pesData=null):(T&&T.size&&_.b.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=T),S&&(d=k(S))&&void 0!==d.pts?(x(d),v.pesData=null):v.pesData=S,null==this.sampleAes?this.remuxer.remux(p,f,v,this._txtTrack,r,i,n):this.decryptAndRemux(p,f,v,this._txtTrack,r,i,n)},t.prototype.decryptAndRemux=function(t,e,r,i,n,a,s){if(t.samples&&t.isAAC){var o=this;this.sampleAes.decryptAacSamples(t.samples,0,function(){o.decryptAndRemuxAvc(t,e,r,i,n,a,s)})}else this.decryptAndRemuxAvc(t,e,r,i,n,a,s)},t.prototype.decryptAndRemuxAvc=function(t,e,r,i,n,a,s){if(e.samples){var o=this;this.sampleAes.decryptAvcSamples(e.samples,0,0,function(){o.remuxer.remux(t,e,r,i,n,a,s)})}else this.remuxer.remux(t,e,r,i,n,a,s)},t.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t.prototype._parsePAT=function(t,e){return(31&t[e+10])<<8|t[e+11]},t.prototype._parsePMT=function(t,e,r,i){var n=void 0,a=void 0,s=void 0,o=void 0,l={audio:-1,avc:-1,id3:-1,isAAC:!0};for(n=(15&t[e+1])<<8|t[e+2],a=e+3+n-4,s=(15&t[e+10])<<8|t[e+11],e+=12+s;e1;){var c=new Uint8Array(d[0].length+d[1].length);c.set(d[0]),c.set(d[1],d[0].length),d[0]=c,d.splice(1,1)}if(r=d[0],1===(r[0]<<16)+(r[1]<<8)+r[2]){if((n=(r[4]<<8)+r[5])&&n>t.size-6)return null;i=r[7],192&i&&(o=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,o>4294967295&&(o-=8589934592),64&i?(l=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,l>4294967295&&(l-=8589934592),o-l>54e5&&(_.b.warn(Math.round((o-l)/9e4)+"s delta between PTS and DTS, align them"),o=l)):l=o),a=r[8],u=a+9,t.size-=u,s=new Uint8Array(t.size);for(var h=0,f=d.length;hp){u-=p;continue}r=r.subarray(u),p-=u,u=0}s.set(r,e),e+=p}return n&&(n-=a+3),{data:s,pts:o,dts:l,len:n}}return null},t.prototype.pushAccesUnit=function(t,e){if(t.units.length&&t.frame){var r=e.samples,i=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===t.key||e.sps&&(i||this.contiguous)?(t.id=i,r.push(t)):e.dropped++}t.debug.length&&_.b.log(t.pts+"/"+t.dts+":"+t.debug)},t.prototype._parseAVCPES=function(t,e){var r=this,i=this._avcTrack,n=this._parseAVCNALu(t.data),a=void 0,s=this.avcSample,o=void 0,l=!1,u=void 0,d=this.pushAccesUnit.bind(this),c=function(t,e,r,i){return{key:t,pts:e,dts:r,units:[],debug:i}};t.data=null,s&&n.length&&!i.audFound&&(d(s,i),s=this.avcSample=c(!1,t.pts,t.dts,"")),n.forEach(function(e){switch(e.type){case 1:o=!0,s||(s=r.avcSample=c(!0,t.pts,t.dts,"")),s.frame=!0;var n=e.data;if(l&&n.length>4){var h=new C(n).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(s.key=!0)}break;case 5:o=!0,s||(s=r.avcSample=c(!0,t.pts,t.dts,"")),s.key=!0,s.frame=!0;break;case 6:o=!0,a=new C(r.discardEPB(e.data)),a.readUByte();for(var f=0,p=0,v=!1,y=0;!v&&a.bytesAvailable>1;){f=0;do{y=a.readUByte(),f+=y}while(255===y);p=0;do{y=a.readUByte(),p+=y}while(255===y);if(4===f&&0!==a.bytesAvailable){v=!0;if(181===a.readUByte()){if(49===a.readUShort()){if(1195456820===a.readUInt()){if(3===a.readUByte()){var g=a.readUByte(),m=a.readUByte(),b=31&g,E=[g,m];for(u=0;u0){if(e.pts>=t[r-1].pts)t.push(e);else for(var i=r-1;i>=0;i--)if(e.pts=0)u={data:t.subarray(c,e-s-1),type:h},l.push(u);else{var f=this._getLastNalUnit();if(f&&(o&&e<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),(n=e-s-1)>0)){var p=new Uint8Array(f.data.byteLength+n);p.set(f.data,0),p.set(t.subarray(0,n),f.data.byteLength),f.data=p}}e=0&&s>=0&&(u={data:t.subarray(c,r),type:h,state:s},l.push(u)),0===l.length){var v=this._getLastNalUnit();if(v){var y=new Uint8Array(v.data.byteLength+t.byteLength);y.set(v.data,0),y.set(t,v.data.byteLength),v.data=y}}return a.naluState=s,l},t.prototype.discardEPB=function(t){for(var e=t.byteLength,r=[],i=1,n=void 0,a=void 0;i1&&(_.b.log("AAC: align PTS for overlapping frames by "+Math.round((m-i)/90)),i=m)}for(;c>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(t,4),i=0,r=8;i>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(q+1)),n=Math.floor(r%(q+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,a)},t.sdtp=function(e){var r=e.samples||[],i=new Uint8Array(4+r.length),n=void 0,a=void 0;for(a=0;a>>8&255),r.push(255&s),r=r.concat(Array.prototype.slice.call(a));for(n=0;n>>8&255),i.push(255&s),i=i.concat(Array.prototype.slice.call(a));var o=t.box(t.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|e.sps.length].concat(r).concat([e.pps.length]).concat(i))),l=e.width,u=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,n=e.width,a=e.height,s=Math.floor(i/(q+1)),o=Math.floor(i%(q+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),n=e.id,a=Math.floor(r/(q+1)),s=Math.floor(r%(q+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i=e.samples||[],n=i.length,a=12+16*n,s=new Uint8Array(a),o=void 0,l=void 0,u=void 0,d=void 0,c=void 0,h=void 0;for(r+=8+a,s.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),o=0;o>>24&255,u>>>16&255,u>>>8&255,255&u,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*o);return t.box(t.types.trun,s)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=void 0;return i=new Uint8Array(t.FTYP.byteLength+r.byteLength),i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}(),W=V,z=function(){function t(e,r,i,n){E(this,t),this.observer=e,this.config=r,this.typeSupported=i;var a=navigator.userAgent;this.isSafari=n&&n.indexOf("Apple")>-1&&a&&!a.match("CriOS"),this.ISGenerated=!1}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(t){this._initPTS=this._initDTS=t},t.prototype.resetInitSegment=function(){this.ISGenerated=!1},t.prototype.remux=function(t,e,r,i,n,a,s){if(this.ISGenerated||this.generateIS(t,e,n),this.ISGenerated){var o=t.samples.length,l=e.samples.length,u=n,d=n;if(o&&l){var c=(t.samples[0].dts-e.samples[0].dts)/e.inputTimeScale;u+=Math.max(0,c),d+=Math.max(0,-c)}if(o){t.timescale||(_.b.warn("regenerate InitSegment as audio detected"),this.generateIS(t,e,n));var h=this.remuxAudio(t,u,a,s);if(l){var f=void 0;h&&(f=h.endPTS-h.startPTS),e.timescale||(_.b.warn("regenerate InitSegment as video detected"),this.generateIS(t,e,n)),this.remuxVideo(e,d,a,f,s)}}else if(l){var p=this.remuxVideo(e,d,a,0,s);p&&t.codec&&this.remuxEmptyAudio(t,u,a,p)}}r.samples.length&&this.remuxID3(r,n),i.samples.length&&this.remuxText(i,n),this.observer.trigger(w.a.FRAG_PARSED)},t.prototype.generateIS=function(t,e,r){var i=this.observer,n=t.samples,a=e.samples,s=this.typeSupported,o="audio/mp4",l={},u={tracks:l},d=void 0===this._initPTS,c=void 0,h=void 0;if(d&&(c=h=1/0),t.config&&n.length&&(t.timescale=t.samplerate,_.b.log("audio sampling rate : "+t.samplerate),t.isAAC||(s.mpeg?(o="audio/mpeg",t.codec=""):s.mp3&&(t.codec="mp3")),l.audio={container:o,codec:t.codec,initSegment:!t.isAAC&&s.mpeg?new Uint8Array:W.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(c=h=n[0].pts-t.inputTimeScale*r)),e.sps&&e.pps&&a.length){var f=e.inputTimeScale;e.timescale=f,l.video={container:"video/mp4",codec:e.codec,initSegment:W.initSegment([e]),metadata:{width:e.width,height:e.height}},d&&(c=Math.min(c,a[0].pts-f*r),h=Math.min(h,a[0].dts-f*r),this.observer.trigger(w.a.INIT_PTS_FOUND,{initPTS:c}))}Object.keys(l).length?(i.trigger(w.a.FRAG_PARSING_INIT_SEGMENT,u),this.ISGenerated=!0,d&&(this._initPTS=c,this._initDTS=h)):i.trigger(w.a.ERROR,{type:A.b.MEDIA_ERROR,details:A.a.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.prototype.remuxVideo=function(t,e,r,i,n){var a=8,s=t.timescale,o=void 0,l=void 0,u=void 0,d=void 0,c=void 0,h=void 0,f=void 0,p=t.samples,v=[],y=p.length,g=this._PTSNormalize,m=this._initDTS,b=this.nextAvcDts,E=this.isSafari;if(0!==y){E&&(r|=p.length&&b&&(n&&Math.abs(e-b/s)<.1||Math.abs(p[0].pts-b-m)1?_.b.log("AVC:"+L+" ms hole between fragments detected,filling it"):L<-1&&_.b.log("AVC:"+-L+" ms overlapping between fragments detected"),c=b,p[0].dts=c,d=Math.max(d-L,b),p[0].pts=d,_.b.log("Video/PTS/DTS adjusted: "+Math.round(d/90)+"/"+Math.round(c/90)+",delta:"+L+" ms")),c,R=p[p.length-1],f=Math.max(R.dts,0),h=Math.max(R.pts,0,f),E&&(o=Math.round((f-c)/(p.length-1)));for(var k=0,D=0,I=0;I0?U-1:U].dts;if(X.stretchShortVideoTrack){var $=X.maxBufferHole,J=Math.floor($*s),Z=(i?d+i*s:this.nextAudioPts)-B.pts;Z>J?(o=Z-Q,o<0&&(o=Q),_.b.log("It is approximately "+Z/90+" ms to the next segment; using duration "+o/90+" ms for the last video frame.")):o=Q}else o=Q}H=Math.round(B.pts-B.dts)}v.push({size:K,duration:o,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:B.key?2:1,isNonSync:B.key?0:1}})}this.nextAvcDts=f+o;var tt=t.dropped;if(t.len=0,t.nbNalu=0,t.dropped=0,v.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var et=v[0].flags;et.dependsOn=2,et.isNonSync=0}t.samples=v,u=W.moof(t.sequenceNumber++,c,t),t.samples=[];var rt={data1:u,data2:l,startPTS:d/s,endPTS:(h+o)/s,startDTS:c/s,endDTS:this.nextAvcDts/s,type:"video",hasAudio:!1,hasVideo:!0,nb:v.length,dropped:tt};return this.observer.trigger(w.a.FRAG_PARSING_DATA,rt),rt}},t.prototype.remuxAudio=function(t,e,r,i){var n=t.inputTimeScale,a=t.timescale,s=n/a,o=t.isAAC?1024:1152,l=o*s,u=this._PTSNormalize,d=this._initDTS,c=!t.isAAC&&this.typeSupported.mpeg,h=void 0,f=void 0,p=void 0,v=void 0,y=void 0,g=void 0,m=void 0,b=t.samples,E=[],T=this.nextAudioPts;if(r|=b.length&&T&&(i&&Math.abs(e-T/n)<.1||Math.abs(b[0].pts-T-d)<20*l),b.forEach(function(t){t.pts=t.dts=u(t.pts-d,e*n)}),b=b.filter(function(t){return t.pts>=0}),0!==b.length){if(r||(T=i?e*n:b[0].pts),t.isAAC)for(var S=this.config.maxAudioFramesDrift,R=0,L=T;R=S*l&&O<1e4&&L){var x=Math.round(k/l);_.b.warn("Injecting "+x+" audio frame @ "+(L/n).toFixed(3)+"s due to "+Math.round(1e3*k/n)+" ms gap.");for(var P=0;P0&&G<1e4)K=Math.round((B-T)/l),_.b.log(G+" ms hole between AAC samples detected,filling it"),K>0&&(p=j.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),p||(p=U.subarray()),t.len+=K*p.length);else if(G<-12){_.b.log("drop overlapping AAC sample, expected/parsed/delta:"+(T/n).toFixed(3)+"s/"+(B/n).toFixed(3)+"s/"+-G+"ms"),t.len-=U.byteLength;continue}B=T}if(g=B,!(t.len>0))return;var H=c?t.len:t.len+8;h=c?0:8;try{v=new Uint8Array(H)}catch(t){return void this.observer.trigger(w.a.ERROR,{type:A.b.MUX_ERROR,details:A.a.REMUX_ALLOC_ERROR,fatal:!1,bytes:H,reason:"fail allocating audio mdat "+H})}if(!c){new DataView(v.buffer).setUint32(0,H),v.set(W.types.mdat,4)}for(var q=0;q=2&&(z=E[Y-2].duration,f.duration=z),Y){this.nextAudioPts=T=m+s*z,t.len=0,t.samples=E,y=c?new Uint8Array:W.moof(t.sequenceNumber++,g/s,t),t.samples=[];var X=g/n,Q=T/n,$={data1:y,data2:v,startPTS:X,endPTS:Q,startDTS:X,endDTS:Q,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.observer.trigger(w.a.FRAG_PARSING_DATA,$),$}return null}},t.prototype.remuxEmptyAudio=function(t,e,r,i){var n=t.inputTimeScale,a=t.samplerate?t.samplerate:n,s=n/a,o=this.nextAudioPts,l=(void 0!==o?o:i.startDTS*n)+this._initDTS,u=i.endDTS*n+this._initDTS,d=1024*s,c=Math.ceil((u-l)/d),h=j.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(_.b.warn("remux empty Audio"),!h)return void _.b.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var f=[],p=0;p4294967296;)t+=r;return t},t}(),Y=z,X=function(){function t(e){T(this,t),this.observer=e}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(){},t.prototype.resetInitSegment=function(){},t.prototype.remux=function(t,e,r,i,n,a,s,o){var l=this.observer,u="";t&&(u+="audio"),e&&(u+="video"),l.trigger(w.a.FRAG_PARSING_DATA,{data1:o,startPTS:n,startDTS:n,type:u,hasAudio:!!t,hasVideo:!!e,nb:1,dropped:0}),l.trigger(w.a.FRAG_PARSED)},t}(),Q=X,$=function(){function t(e,r,i,n){S(this,t),this.observer=e,this.typeSupported=r,this.config=i,this.vendor=n}return t.prototype.destroy=function(){var t=this.demuxer;t&&t.destroy()},t.prototype.push=function(t,e,r,i,n,a,s,o,l,u,d,c){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){var h=this.decrypter;null==h&&(h=this.decrypter=new R.a(this.observer,this.config));var f=this,p=void 0;try{p=performance.now()}catch(t){p=Date.now()}h.decrypt(t,e.key.buffer,e.iv.buffer,function(t){var h=void 0;try{h=performance.now()}catch(t){h=Date.now()}f.observer.trigger(w.a.FRAG_DECRYPTED,{stats:{tstart:p,tdecrypt:h}}),f.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,n,a,s,o,l,u,d,c)})}else this.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,n,a,s,o,l,u,d,c)},t.prototype.pushDecrypted=function(t,e,r,i,n,a,s,o,l,u,d,c){var h=this.demuxer;if(!h||(s||o)&&!this.probe(t)){for(var f=this.observer,p=this.typeSupported,v=this.config,y=[{demux:B,remux:Y},{demux:I.a,remux:Q},{demux:D,remux:Y},{demux:K,remux:Y}],g=0,m=y.length;ge?i.start+i.duration:Math.max(i.start-n.duration,0):r>e?(i.duration=a-i.start,i.duration<0&&Vt.b.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-a,n.duration<0&&Vt.b.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"))}function R(t,e,r,i,n,a){var s=r;if(!isNaN(e.startPTS)){var o=Math.abs(e.startPTS-r);isNaN(e.deltaPTS)?e.deltaPTS=o:e.deltaPTS=Math.max(o,e.deltaPTS),s=Math.max(r,e.startPTS),r=Math.min(r,e.startPTS),i=Math.max(i,e.endPTS),n=Math.min(n,e.startDTS),a=Math.max(a,e.endDTS)}var l=r-e.start;e.start=e.startPTS=r,e.maxStartPTS=s,e.endPTS=i,e.startDTS=n,e.endDTS=a,e.duration=i-r;var u=e.sn;if(!t||ut.endSN)return 0;var d=void 0,c=void 0,h=void 0;for(d=u-t.startSN,c=t.fragments,c[d]=e,h=d;h>0;h--)A(c,h,h-1);for(h=d;h=0&&ne?-1:0})}function D(t,e,r){var i=!1;return e&&e.details&&r&&(r.endCC>r.startCC||t&&t.cc0;)t.removeCue(t.cues[0])}function q(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function V(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function W(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function z(){var t=b(),e=window.SourceBuffer||window.WebKitSourceBuffer,r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!i}function Y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function X(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Q(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function J(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function Z(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function et(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function rt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function nt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function at(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function st(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function ot(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function lt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ut(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function dt(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function ct(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function ht(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ft(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function pt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function vt(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new Sr,this.regionList=[]}function yt(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+(0|i)/1e3}var r=t.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?e(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?e(r[1],r[2],0,r[4]):e(0,r[1],r[2],r[4]):null}function gt(){this.values=Object.create(null)}function mt(t,e,r,i){var n=i?t.split(i):[t];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length){var o=s[0],l=s[1];e(o,l)}}}function bt(t,e,r){function i(){var e=yt(t);if(null===e)throw new Error("Malformed timestamp: "+a);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function n(){t=t.replace(/^\s+/,"")}var a=t;if(n(),e.startTime=i(),n(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+a);t=t.substr(3),n(),e.endTime=i(),n(),function(t,e){var i=new gt;mt(t,function(t,e){switch(t){case"region":for(var n=r.length-1;n>=0;n--)if(r[n].id===e){i.set(t,r[n].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":var a=e.split(","),s=a[0];i.integer(t,s),i.percent(t,s)&&i.set("snapToLines",!1),i.alt(t,s,["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",Ar,"end"]);break;case"position":a=e.split(","),i.percent(t,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",Ar,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",Ar,"end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===wr.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",Ar);var a=i.get("position","auto");"auto"===a&&50===wr.position&&(a="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=a}(t,e)}function Et(t){return t.replace(//gi,"\n")}function Tt(t,e,r,i){for(var n=void 0,a=void 0,s=void 0,o=void 0,l=void 0,u=window.VTTCue||window.TextTrackCue,d=0;d=16?o--:o++,navigator.userAgent.match(/Firefox\//)?a.line=d+1:a.line=d>7?d-2:d+1,a.align="left",a.position=Math.max(0,Math.min(100,o/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),t.addCue(a)}}function St(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function wt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function At(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Rt(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function Lt(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function kt(t,e,r,i){return Math.min(e,i)-Math.max(t,r)}function Dt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function It(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function Ot(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function xt(t){for(var e=[],r=0;r1?r-1:0),a=1;a>8*(15-r)&255;return e},t.prototype.fragmentDecryptdataFromLevelkey=function(t,e){var r=t;return t&&t.method&&t.uri&&!t.iv&&(r=new Zt,r.method=t.method,r.baseuri=t.baseuri,r.reluri=t.reluri,r.iv=this.createInitializationVector(e)),r},te(t,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Ht.a.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(t){this._url=t}},{key:"programDateTime",get:function(){return!this._programDateTime&&this.rawProgramDateTime&&(this._programDateTime=new Date(Date.parse(this.rawProgramDateTime))),this._programDateTime}},{key:"byteRange",get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var t=[];if(this.rawByteRange){var e=this.rawByteRange.split("@",2);if(1===e.length){var r=this.lastByteRangeEndOffset;t[0]=r||0}else t[0]=parseInt(e[1]);t[1]=parseInt(e[0])+t[0],this._byteRange=t}return t}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata}}],[{key:"ElementaryStreamTypes",get:function(){return{AUDIO:"audio",VIDEO:"video"}}}]),t}(),re=ee,ie=/^(\d+)x(\d+)$/,ne=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,ae=function(){function t(e){s(this,t),"string"==typeof e&&(e=t.parseAttrList(e));for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}return t.prototype.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},t.prototype.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},t.prototype.decimalFloatingPoint=function(t){return parseFloat(this[t])},t.prototype.enumeratedString=function(t){return this[t]},t.prototype.decimalResolution=function(t){var e=ie.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e=void 0,r={};for(ne.lastIndex=0;null!==(e=ne.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}(),se=ae,oe={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}},le=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,ue=/#EXT-X-MEDIA:(.*)/g,de=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)(\S+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),ce=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)(.*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,he=function(){function t(){u(this,t)}return t.findGroup=function(t,e){if(!t)return null;for(var r=null,i=0;i2?(e=r.shift()+".",e+=parseInt(r.shift()).toString(16),e+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):e=t,e},t.resolve=function(t,e){return Ht.a.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(e,r){var i=[],n=void 0;for(le.lastIndex=0;null!=(n=le.exec(e));){var a={},s=a.attrs=new se(n[1]);a.url=t.resolve(n[2],r);var l=s.decimalResolution("RESOLUTION");l&&(a.width=l.width,a.height=l.height),a.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),a.name=s.NAME,function(t,e){["video","audio"].forEach(function(r){var i=t.filter(function(t){return o(t,r)});if(i.length){var n=i.filter(function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)});e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter(function(t){return-1===i.indexOf(t)})}}),e.unknownCodecs=t}([].concat((s.CODECS||"").split(/[ ,]+/)),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=t.convertAVC1ToAVCOTI(a.videoCodec)),i.push(a)}return i},t.parseMasterPlaylistMedia=function(e,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=void 0,s=[],o=0;for(ue.lastIndex=0;null!==(a=ue.exec(e));){var l={},u=new se(a[1]);if(u.TYPE===i){if(l.groupId=u["GROUP-ID"],l.name=u.NAME,l.type=i,l.default="YES"===u.DEFAULT,l.autoselect="YES"===u.AUTOSELECT,l.forced="YES"===u.FORCED,u.URI&&(l.url=t.resolve(u.URI,r)),l.lang=u.LANGUAGE,l.name||(l.name=l.lang),n.length){var d=t.findGroup(n,l.groupId);l.audioCodec=d?d.codec:n[0].codec}l.id=o++,s.push(l)}}return s},t.parseLevelPlaylist=function(t,e,r,i){var n=0,a=0,s={type:null,version:null,url:e,fragments:[],live:!0,startSN:0},o=new Zt,l=0,u=null,d=new re,c=void 0,h=void 0;for(de.lastIndex=0;null!==(c=de.exec(t));){var f=c[1];if(f){d.duration=parseFloat(f);var p=(" "+c[2]).slice(1);d.title=p||null,d.tagList.push(p?["INF",f,p]:["INF",f])}else if(c[3]){if(!isNaN(d.duration)){var v=n++;d.type=i,d.start=a,d.levelkey=o,d.sn=v,d.level=r,d.cc=l,d.baseurl=e,d.relurl=(" "+c[3]).slice(1),s.programDateTime&&(u?d.rawProgramDateTime?d.pdt=Date.parse(d.rawProgramDateTime):d.pdt=u.pdt+1e3*u.duration:d.pdt=Date.parse(s.programDateTime),d.endPdt=d.pdt+1e3*d.duration),s.fragments.push(d),u=d,a+=d.duration,d=new re}}else if(c[4]){if(d.rawByteRange=(" "+c[4]).slice(1),u){var y=u.byteRangeEndOffset;y&&(d.lastByteRangeEndOffset=y)}}else if(c[5])d.rawProgramDateTime=(" "+c[5]).slice(1),d.tagList.push(["PROGRAM-DATE-TIME",d.rawProgramDateTime]),void 0===s.programDateTime&&(s.programDateTime=new Date(new Date(Date.parse(c[5]))-1e3*a));else{for(c=c[0].match(ce),h=1;h=0&&(o.method=T,o.baseuri=e,o.reluri=S,o.key=null,o.iv=w));break;case"START":var A=g,R=new se(A),_=R.decimalFloatingPoint("TIME-OFFSET");isNaN(_)||(s.startTimeOffset=_);break;case"MAP":var L=new se(g);d.relurl=L.URI,d.rawByteRange=L.BYTERANGE,d.baseurl=e,d.level=r,d.type=i,d.sn="initSegment",s.initSegment=d,d=new re;break;default:Vt.b.warn("line parsed but not handled: "+c)}}}return d=u,d&&!d.relurl&&(s.fragments.pop(),a-=d.duration),s.totalduration=a,s.averagetargetduration=a/s.fragments.length,s.endSN=n-1,s.startCC=s.fragments[0]?s.fragments[0].cc:0,s.endCC=l,!s.initSegment&&s.fragments.length&&s.fragments.every(function(t){return t.relurl.endsWith(".mp4")})&&(Vt.b.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),d=new re,d.relurl=s.fragments[0].relurl,d.baseurl=e,d.level=r,d.type=i,d.sn="initSegment",s.initSegment=d,s.needSidxRanges=!0),s},t}(),fe=he,pe=function(){function t(t,e){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:null;if(r.isSidxRequest)return this._handleSidxRequest(t,r),void this._handlePlaylistLoaded(t,e,r,i);this.resetInternalLoader(r.type);var n=t.data;if(e.tload=performance.now(),0!==n.indexOf("#EXTM3U"))return void this._handleManifestParsingError(t,r,"no EXTM3U delimiter",i);n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(t,e,r,i):this._handleMasterPlaylist(t,e,r,i)},e.prototype.loaderror=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(e,r)},e.prototype.loadtimeout=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(e,r,!0)},e.prototype._handleMasterPlaylist=function(t,r,i,n){var a=this.hls,s=t.data,o=e.getResponseUrl(t,i),l=fe.parseMasterPlaylist(s,o);if(!l.length)return void this._handleManifestParsingError(t,i,"no level found in manifest",n);var u=l.map(function(t){return{id:t.attrs.AUDIO,codec:t.audioCodec}}),d=fe.parseMasterPlaylistMedia(s,o,"AUDIO",u),c=fe.parseMasterPlaylistMedia(s,o,"SUBTITLES");if(d.length){var h=!1;d.forEach(function(t){t.url||(h=!0)}),!1===h&&l[0].audioCodec&&!l[0].attrs.AUDIO&&(Vt.b.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main"}))}a.trigger(qt.a.MANIFEST_LOADED,{levels:l,audioTracks:d,subtitles:c,url:o,stats:r,networkDetails:n})},e.prototype._handleTrackOrLevelPlaylist=function(t,r,i,n){var a=this.hls,s=i.id,o=i.level,l=i.type,u=e.getResponseUrl(t,i),d=isNaN(o)?isNaN(s)?0:s:o,c=e.mapContextToLevelType(i),h=fe.parseLevelPlaylist(t.data,u,d,c);if(h.tload=r.tload,l===ve.MANIFEST){var f={url:u,details:h};a.trigger(qt.a.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:u,stats:r,networkDetails:n})}if(r.tparsed=performance.now(),h.needSidxRanges){var p=h.initSegment.url;return void this.load(p,{isSidxRequest:!0,type:l,level:o,levelDetails:h,id:s,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}i.levelDetails=h,this._handlePlaylistLoaded(t,r,i,n)},e.prototype._handleSidxRequest=function(t,e){var r=Qt.a.parseSegmentIndex(new Uint8Array(t.data));r.references.forEach(function(t,r){var i=t.info,n=e.levelDetails.fragments[r];0===n.byteRange.length&&(n.rawByteRange=String(1+i.end-i.start)+"@"+String(i.start))}),e.levelDetails.initSegment.rawByteRange=String(r.moovEndOffset)+"@0"},e.prototype._handleManifestParsingError=function(t,e,r,i){this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:jt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:t.url,reason:r,networkDetails:i})},e.prototype._handleNetworkError=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=void 0,n=void 0,a=this.getInternalLoader(t);switch(t.type){case ve.MANIFEST:i=r?jt.a.MANIFEST_LOAD_TIMEOUT:jt.a.MANIFEST_LOAD_ERROR,n=!0;break;case ve.LEVEL:i=r?jt.a.LEVEL_LOAD_TIMEOUT:jt.a.LEVEL_LOAD_ERROR,n=!1;break;case ve.AUDIO_TRACK:i=r?jt.a.AUDIO_TRACK_LOAD_TIMEOUT:jt.a.AUDIO_TRACK_LOAD_ERROR,n=!1;break;default:n=!1}a&&(a.abort(),this.resetInternalLoader(t.type)),this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:i,fatal:n,url:a.url,loader:a,context:t,networkDetails:e})},e.prototype._handlePlaylistLoaded=function(t,r,i,n){var a=i.type,s=i.level,o=i.id,l=i.levelDetails;if(!l.targetduration)return void this._handleManifestParsingError(t,i,"invalid target duration",n);if(e.canHaveQualityLevels(i.type))this.hls.trigger(qt.a.LEVEL_LOADED,{details:l,level:s||0,id:o||0,stats:r,networkDetails:n});else switch(a){case ve.AUDIO_TRACK:this.hls.trigger(qt.a.AUDIO_TRACK_LOADED,{details:l,id:o,stats:r,networkDetails:n});break;case ve.SUBTITLE_TRACK:this.hls.trigger(qt.a.SUBTITLE_TRACK_LOADED,{details:l,id:o,stats:r,networkDetails:n})}},pe(e,null,[{key:"ContextType",get:function(){return ve}},{key:"LevelType",get:function(){return ye}}]),e}(Xt),me=ge,be=function(t){function e(r){f(this,e);var i=p(this,t.call(this,r,qt.a.FRAG_LOADING));return i.loaders={},i}return v(e,t),e.prototype.destroy=function(){var e=this.loaders;for(var r in e){var i=e[r];i&&i.destroy()}this.loaders={},t.prototype.destroy.call(this)},e.prototype.onFragLoading=function(t){var e=t.frag,r=e.type,i=this.loaders,n=this.hls.config,a=n.fLoader,s=n.loader;e.loaded=0;var o=i[r];o&&(Vt.b.warn("abort previous fragment loader for type: "+r),o.abort()),o=i[r]=e.loader=n.fLoader?new a(n):new s(n);var l=void 0,u=void 0,d=void 0;l={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1};var c=e.byteRangeStartOffset,h=e.byteRangeEndOffset;isNaN(c)||isNaN(h)||(l.rangeStart=c,l.rangeEnd=h),u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:n.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},o.load(l,u,d)},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=t.data,a=r.frag;a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(qt.a.FRAG_LOADED,{payload:n,frag:a,stats:e,networkDetails:i})},e.prototype.loaderror=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:jt.a.FRAG_LOAD_ERROR,fatal:!1,frag:e.frag,response:t,networkDetails:r})},e.prototype.loadtimeout=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:jt.a.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e.frag,networkDetails:r})},e.prototype.loadprogress=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=e.frag;n.loaded=t.loaded,this.hls.trigger(qt.a.FRAG_LOAD_PROGRESS,{frag:n,stats:t,networkDetails:i})},e}(Xt),Ee=be,Te=function(t){function e(r){y(this,e);var i=g(this,t.call(this,r,qt.a.KEY_LOADING));return i.loaders={},i.decryptkey=null,i.decrypturl=null,i}return m(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},Xt.prototype.destroy.call(this)},e.prototype.onKeyLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],n=e.decryptdata,a=n.uri;if(a!==this.decrypturl||null===this.decryptkey){var s=this.hls.config;i&&(Vt.b.warn("abort previous key loader for type:"+r),i.abort()),e.loader=this.loaders[r]=new s.loader(s),this.decrypturl=a,this.decryptkey=null;var o=void 0,l=void 0,u=void 0;o={url:a,frag:e,responseType:"arraybuffer"},l={timeout:s.fragLoadingTimeOut,maxRetry:s.fragLoadingMaxRetry,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(o,l,u)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(qt.a.KEY_LOADED,{frag:e}))},e.prototype.loadsuccess=function(t,e,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(t.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(qt.a.KEY_LOADED,{frag:i})},e.prototype.loaderror=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:jt.a.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.prototype.loadtimeout=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(qt.a.ERROR,{type:jt.b.NETWORK_ERROR,details:jt.a.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}(Xt),Se=Te,we={search:function(t,e){for(var r=0,i=t.length-1,n=null,a=null;r<=i;){n=(r+i)/2|0,a=t[n];var s=e(a);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null}},Ae=we,Re={isBuffered:function(t,e){try{if(t)for(var r=t.buffered,i=0;i=r.start(i)&&e<=r.end(i))return!0}catch(t){}return!1},bufferInfo:function(t,e,r){try{if(t){var i=t.buffered,n=[],a=void 0;for(a=0;ad&&(i[u-1].end=t[l].end):i.push(t[l])}else i.push(t[l])}for(l=0,n=0,a=s=e;l=c&&e1?e-1:0),n=1;n1?e-1:0),n=1;n=n&&e<=a){i.push({startPTS:Math.max(t,r.start(o)),endPTS:Math.min(e,r.end(o))});break}if(tn)i.push({startPTS:Math.max(t,r.start(o)),endPTS:Math.min(e,r.end(o))}),s=!0;else if(e<=n)break}return{time:i,partial:s}},e.prototype.getFragmentKey=function(t){return t.type+"_"+t.level+"_"+t.sn},e.prototype.getPartialFragment=function(t){var e=this,r=void 0,i=void 0,n=void 0,a=null,s=0;return Object.keys(this.fragments).forEach(function(o){var l=e.fragments[o];e.isPartial(l)&&(i=l.body.startPTS-e.bufferPadding,n=l.body.endPTS+e.bufferPadding,t>=i&&t<=n&&(r=Math.min(t-i,n-t),s<=r&&(a=l.body,s=r)))}),a},e.prototype.getState=function(t){var e=this.getFragmentKey(t),r=this.fragments[e],i=Fe.NOT_LOADED;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?Fe.PARTIAL:Fe.OK:Fe.APPENDING),i},e.prototype.isPartial=function(t){return!0===t.buffered&&(void 0!==t.range.video&&!0===t.range.video.partial||void 0!==t.range.audio&&!0===t.range.audio.partial)},e.prototype.isTimeBuffered=function(t,e,r){for(var i=void 0,n=void 0,a=0;a=i&&e<=n)return!0;if(e<=i)return!1}return!1},e.prototype.onFragLoaded=function(t){var e=t.frag;if(!isNaN(e.sn)){var r=this.getFragmentKey(e),i={body:e,range:Object.create(null),buffered:!1};this.fragments[r]=i}},e.prototype.onBufferAppended=function(t){var e=this;this.timeRanges=t.timeRanges,Object.keys(this.timeRanges).forEach(function(t){var r=e.timeRanges[t];e.detectEvictedFragments(t,r)})},e.prototype.onFragBuffered=function(t){this.detectPartialFragments(t.frag)},e.prototype.hasFragment=function(t){var e=this.getFragmentKey(t);return void 0!==this.fragments[e]},e.prototype.removeFragment=function(t){var e=this.getFragmentKey(t);delete this.fragments[e]},e.prototype.removeAllFragments=function(){this.fragments=Object.create(null)},e}(Xt),Ne={toString:function(t){for(var e="",r=t.length,i=0;i1?i-1:0),a=1;a1&&setTimeout(this.tick.bind(this),0),this._tickCallCount=0)},e.prototype.doTick=function(){throw new Error("TaskLoop is abstract and `doLoop` must be implemented")},e}(Xt),Ge=Be,Ke=function(){function t(t,e){for(var r=0;r0&&-1===t&&(Vt.b.log("override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=He.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this.forceStartLoad=!0,this.state=He.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragmentTracker.removeFragment(t),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.clearInterval(),this.state=He.STOPPED,this.forceStartLoad=!1},e.prototype.doTick=function(){switch(this.state){case He.BUFFER_FLUSHING:this.fragLoadError=0;break;case He.IDLE:this._doTickIdle();break;case He.WAITING_LEVEL:var t=this.levels[this.level];t&&t.details&&(this.state=He.IDLE);break;case He.FRAG_LOADING_WAITING_RETRY:var e=performance.now(),r=this.retryDate;(!r||e>=r||this.media&&this.media.seeking)&&(Vt.b.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=He.IDLE);break;case He.ERROR:case He.STOPPED:case He.FRAG_LOADING:case He.PARSING:case He.PARSED:case He.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},e.prototype._doTickIdle=function(){var t=this.hls,e=t.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&e.startFragPrefetch)){var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var n=t.nextLoadLevel,a=this.levels[n];if(a){var s=a.bitrate,o=void 0;o=s?Math.max(8*e.maxBufferSize/s,e.maxBufferLength):e.maxBufferLength,o=Math.min(o,e.maxMaxBufferLength);var l=_e.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,e.maxBufferHole),u=l.len;if(!(u>=o)){Vt.b.trace("buffer length of "+u.toFixed(3)+" is below max of "+o.toFixed(3)+". checking for more payload ..."),this.level=t.nextLoadLevel=n;var d=a.details;if(void 0===d||!0===d.live&&this.levelLastLoaded!==n)return void(this.state=He.WAITING_LEVEL);var c=this.fragPrevious;if(!d.live&&c&&!c.backtracked&&c.sn===d.endSN&&!l.nextStart){if(Math.min(r.duration,c.start+c.duration)-Math.max(l.end,c.start)<=Math.max(.2,c.duration)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(qt.a.BUFFER_EOS,h),void(this.state=He.ENDED)}}this._fetchPayloadOrEos(i,l,d)}}}},e.prototype._fetchPayloadOrEos=function(t,e,r){var i=this.fragPrevious,n=this.level,a=r.fragments,s=a.length;if(0!==s){var o=a[0].start,l=a[s-1].start+a[s-1].duration,u=e.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var c=this.config.initialLiveManifestSize;if(sc&&(l.currentTime=c),this.nextLoadPosition=c}if(t.PTSKnown&&e>i&&l&&l.readyState)return null;if(this.startFragRequested&&!t.PTSKnown){if(n)if(t.programDateTime)u=this._findFragmentByPDT(a,n.endPdt+1);else{var h=n.sn+1;if(h>=t.startSN&&h<=t.endSN){var f=a[h-t.startSN];n.cc===f.cc&&(u=f,Vt.b.log("live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=Ae.search(a,function(t){return n.cc-t.cc}))&&Vt.b.log("live playlist, switching playlist, load frag with same CC: "+u.sn)}u||(u=a[Math.min(s-1,Math.round(s/2))],Vt.b.log("live playlist, switching playlist, unknown, load middle frag : "+u.sn))}return u},e.prototype._findFragmentByPDT=function(t,e){if(!t||void 0===e)return null;if(e=t[t.length-1].endPdt)return null;for(var r=0;rr&&t.start?-1:0};return ri-s&&(s=0),a=o&&!l(o)?o:Ae.search(e,l)),a},e.prototype._findFragment=function(t,e,r,i,n,a,s){var o=this.hls.config,l=void 0,u=void 0;if(u=no.maxBufferHole&&e.dropped&&d?(l=h,Vt.b.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(l=f,Vt.b.log("SN just loaded, load next one: "+l.sn))}else l=null;else l.backtracked&&(f&&f.backtracked?(Vt.b.warn("Already backtracked from fragment "+f.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+f.sn),l=f):(Vt.b.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,h?(l=h,l.backtracked=!0):d&&(l=null)))}return l},e.prototype._loadFragmentOrKey=function(t,e,r,i,n){if(t.decryptdata&&null!=t.decryptdata.uri&&null==t.decryptdata.key)Vt.b.log("Loading key for "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e),this.state=He.KEY_LOADING,this.hls.trigger(qt.a.KEY_LOADING,{frag:t});else{Vt.b.log("Loading "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e+", currentTime:"+i.toFixed(3)+",bufferEnd:"+n.toFixed(3));var a=this.fragmentTracker.getState(t);this.fragCurrent=t,this.startFragRequested=!0,isNaN(t.sn)||t.bitrateTest||(this.nextLoadPosition=t.start+t.duration),t.backtracked||a===Fe.NOT_LOADED?(t.autoLevel=this.hls.autoLevelEnabled,t.bitrateTest=this.bitrateTest,this.hls.trigger(qt.a.FRAG_LOADING,{frag:t}),this.demuxer||(this.demuxer=new Ce(this.hls,"main")),this.state=He.FRAG_LOADING):a===Fe.APPENDING&&this._reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t)}},e.prototype.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,me.LevelType.MAIN)},e.prototype.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.endPTS+.5):null},e.prototype._checkFragmentChanged=function(){var t=void 0,e=void 0,r=this.media;if(r&&r.readyState&&!1===r.seeking&&(e=r.currentTime,e>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),_e.isBuffered(r,e)?t=this.getBufferedFrag(e):_e.isBuffered(r,e+.1)&&(t=this.getBufferedFrag(e+.1)),t)){var i=t;if(i!==this.fragPlaying){this.hls.trigger(qt.a.FRAG_CHANGED,{frag:i});var n=i.level;this.fragPlaying&&this.fragPlaying.level===n||this.hls.trigger(qt.a.LEVEL_SWITCHED,{level:n}),this.fragPlaying=i}}},e.prototype.immediateLevelSwitch=function(){if(Vt.b.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var t=this.media,e=void 0;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.prototype.immediateLevelSwitchEnd=function(){var t=this.media;t&&t.buffered.length&&(this.immediateSwitch=!1,_e.isBuffered(t,t.currentTime)&&(t.currentTime-=1e-4),this.previouslyPaused||t.play())},e.prototype.nextLevelSwitch=function(){var t=this.media;if(t&&t.readyState){var e=void 0,r=void 0,i=void 0;if(r=this.getBufferedFrag(t.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),t.paused)e=0;else{var n=this.hls.nextLoadLevel,a=this.levels[n],s=this.fragLastKbps;e=s&&this.fragCurrent?this.fragCurrent.duration*a.bitrate/(1e3*s)+1:0}if((i=this.getBufferedFrag(t.currentTime+e))&&(i=this.followingBufferedFrag(i))){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},e.prototype.flushMainBuffer=function(t,e){this.state=He.BUFFER_FLUSHING;var r={startOffset:t,endOffset:e};this.altAudio&&(r.type="video"),this.hls.trigger(qt.a.BUFFER_FLUSHING,r)},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(Vt.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.levels;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.backtracked=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("seeked",this.onvseeked),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){var t=this.media,e=t?t.currentTime:void 0,r=this.config;isNaN(e)||Vt.b.log("media seeking to "+e.toFixed(3));var i=this.mediaBuffer?this.mediaBuffer:t,n=_e.bufferInfo(i,e,this.config.maxBufferHole);if(this.state===He.FRAG_LOADING){var a=this.fragCurrent;if(0===n.len&&a){var s=r.maxFragLookUpTolerance,o=a.start-s,l=a.start+a.duration+s;el?(a.loader&&(Vt.b.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),a.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=He.IDLE):Vt.b.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===He.ENDED&&(0===n.len&&(this.fragPrevious=0),this.state=He.IDLE);t&&(this.lastCurrentTime=e),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=e),this.tick()},e.prototype.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:void 0;isNaN(e)||Vt.b.log("media seeked to "+e.toFixed(3)),this.tick()},e.prototype.onMediaEnded=function(){Vt.b.log("media ended"),this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestLoading=function(){Vt.b.log("trigger BUFFER_RESET"),this.hls.trigger(qt.a.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestParsed=function(t){var e=!1,r=!1,i=void 0;t.levels.forEach(function(t){(i=t.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(e=!0),-1!==i.indexOf("mp4a.40.5")&&(r=!0))}),this.audioCodecSwitch=e&&r,this.audioCodecSwitch&&Vt.b.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1;var n=this.config;(n.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(n.startPosition)},e.prototype.onLevelLoaded=function(t){var e=t.details,r=t.level,i=this.levels[this.levelLastLoaded],n=this.levels[r],a=e.totalduration,s=0;if(Vt.b.log("level "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+a),e.live){var o=n.details;o&&e.fragments.length>0?(_(o,e),s=e.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,o),e.PTSKnown&&!isNaN(s)?Vt.b.log("live playlist sliding:"+s.toFixed(3)):(Vt.b.log("live playlist - outdated PTS, unknown sliding"),x(this.fragPrevious,i,e))):(Vt.b.log("live playlist - first load, unknown sliding"),e.PTSKnown=!1,x(this.fragPrevious,i,e))}else e.PTSKnown=!1;if(n.details=e,this.levelLastLoaded=r,this.hls.trigger(qt.a.LEVEL_UPDATED,{details:e,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var l=e.startTimeOffset;isNaN(l)?e.live?(this.startPosition=this.computeLivePosition(s,e),Vt.b.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(l<0&&(Vt.b.log("negative start time offset "+l+", count from end of last fragment"),l=s+a+l),Vt.b.log("start time offset found in playlist, adjust startPosition to "+l),this.startPosition=l),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===He.WAITING_LEVEL&&(this.state=He.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===He.KEY_LOADING&&(this.state=He.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===He.FRAG_LOADING&&e&&"main"===r.type&&r.level===e.level&&r.sn===e.sn){var i=t.stats,n=this.levels[e.level],a=n.details;if(Vt.b.log("Loaded "+e.sn+" of ["+a.startSN+" ,"+a.endSN+"],level "+e.level),this.bitrateTest=!1,this.stats=i,!0===r.bitrateTest&&this.hls.nextLoadLevel)this.state=He.IDLE,this.startFragRequested=!1,i.tparsed=i.tbuffered=performance.now(),this.hls.trigger(qt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=He.IDLE,i.tparsed=i.tbuffered=performance.now(),a.initSegment.data=t.payload,this.hls.trigger(qt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else{this.state=He.PARSING;var s=a.totalduration,o=e.level,l=e.sn,u=this.config.defaultAudioCodec||n.audioCodec;this.audioCodecSwap&&(Vt.b.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,Vt.b.log("Parsing "+l+" of ["+a.startSN+" ,"+a.endSN+"],level "+o+", cc "+e.cc);var d=this.demuxer;d||(d=this.demuxer=new Ce(this.hls,"main"));var c=this.media,h=c&&c.seeking,f=!h&&(a.PTSKnown||!a.live),p=a.initSegment?a.initSegment.data:[];d.push(t.payload,p,u,n.videoCodec,e,s,f,void 0)}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===He.PARSING){var i=t.tracks,n=void 0,a=void 0;if(i.audio&&this.altAudio&&delete i.audio,a=i.audio){var s=this.levels[this.level].audioCodec,o=navigator.userAgent.toLowerCase();s&&this.audioCodecSwap&&(Vt.b.log("swapping playlist audio codec"),s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===o.indexOf("firefox")&&(s="mp4a.40.5"),-1!==o.indexOf("android")&&"audio/mpeg"!==a.container&&(s="mp4a.40.2",Vt.b.log("Android: force audio codec to "+s)),a.levelCodec=s,a.id=t.id}a=i.video,a&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=t.id),this.hls.trigger(qt.a.BUFFER_CODECS,i);for(n in i){a=i[n],Vt.b.log("main track:"+n+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var l=a.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(qt.a.BUFFER_APPENDING,{type:n,data:l,parent:"main",content:"initSegment"}))}this.tick()}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"main"===t.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==t.type||!this.altAudio)&&this.state===He.PARSING){var n=this.levels[this.level],a=r;if(isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),!0===t.hasAudio&&a.addElementaryStream(re.ElementaryStreamTypes.AUDIO),!0===t.hasVideo&&a.addElementaryStream(re.ElementaryStreamTypes.VIDEO),Vt.b.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(a.dropped=t.dropped,a.dropped)if(a.backtracked)Vt.b.warn("Already backtracked on this fragment, appending with the gap");else{var s=n.details;if(!s||a.sn!==s.startSN)return Vt.b.warn("missing video frame(s), backtracking fragment"),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=He.IDLE,this.fragPrevious=a,void this.tick();Vt.b.warn("missing video frame(s) on first frag, appending with gap")}else a.backtracked=!1;var o=R(n.details,a,t.startPTS,t.endPTS,t.startDTS,t.endDTS),l=this.hls;l.trigger(qt.a.LEVEL_PTS_UPDATED,{details:n.details,level:this.level,drift:o,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(r){r&&r.length&&e.state===He.PARSING&&(e.appended=!0,e.pendingBuffering=!0,l.trigger(qt.a.BUFFER_APPENDING,{type:t.type,data:r,parent:"main",content:"data"}))}),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===He.PARSING&&(this.stats.tparsed=performance.now(),this.state=He.PARSED,this._checkAppendedParsed())},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url,r=t.id;if(!e){if(this.mediaBuffer!==this.media){Vt.b.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(Vt.b.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=He.IDLE}var n=this.hls;n.trigger(qt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),n.trigger(qt.a.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},e.prototype.onAudioTrackSwitched=function(t){var e=t.id,r=!!this.hls.audioTracks[e].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(Vt.b.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},e.prototype.onBufferCreated=function(t){var e=t.tracks,r=void 0,i=void 0,n=!1;for(var a in e){var s=e[a];"main"===s.id?(i=a,r=s,"video"===a&&(this.videoBuffer=e[a].buffer)):n=!0}n&&r?(Vt.b.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},e.prototype.onBufferAppended=function(t){if("main"===t.parent){var e=this.state;e!==He.PARSING&&e!==He.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==He.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent;if(t){var e=this.mediaBuffer?this.mediaBuffer:this.media;Vt.b.log("main buffered : "+Ue.toString(e.buffered)),this.fragPrevious=t;var r=this.stats;r.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(qt.a.FRAG_BUFFERED,{stats:r,frag:t,id:"main"}),this.state=He.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag||this.fragCurrent;if(!e||"main"===e.type){var r=!!this.media&&_e.isBuffered(this.media,this.media.currentTime)&&_e.isBuffered(this.media,this.media.currentTime+.5);switch(t.details){case jt.a.FRAG_LOAD_ERROR:case jt.a.FRAG_LOAD_TIMEOUT:case jt.a.KEY_LOAD_ERROR:case jt.a.KEY_LOAD_TIMEOUT:if(!t.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);Vt.b.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=He.FRAG_LOADING_WAITING_RETRY}else Vt.b.error("mediaController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=He.ERROR;break;case jt.a.LEVEL_LOAD_ERROR:case jt.a.LEVEL_LOAD_TIMEOUT:this.state!==He.ERROR&&(t.fatal?(this.state=He.ERROR,Vt.b.warn("streamController: "+t.details+",switch to "+this.state+" state ...")):t.levelRetry||this.state!==He.WAITING_LEVEL||(this.state=He.IDLE));break;case jt.a.BUFFER_FULL_ERROR:"main"!==t.parent||this.state!==He.PARSING&&this.state!==He.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=He.IDLE):(Vt.b.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},e.prototype._reduceMaxBufferLength=function(t){var e=this.config;return e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,Vt.b.warn("main:reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},e.prototype._checkBuffer=function(){var t=this.media,e=this.config;if(t&&t.readyState){var r=t.currentTime,i=this.mediaBuffer?this.mediaBuffer:t,n=i.buffered;if(!this.loadedmetadata&&n.length){this.loadedmetadata=!0;var a=t.seeking?r:this.startPosition;r!==a&&(Vt.b.log("target start position not buffered, seek to buffered.start(0) "+a+" from current time"+r+" "),t.currentTime=a)}else if(this.immediateSwitch)this.immediateLevelSwitchEnd();else{var s=_e.bufferInfo(t,r,e.maxBufferHole),o=!(t.paused&&t.readyState>1||t.ended||0===t.buffered.length),l=r!==this.lastCurrentTime;if(l)this.stallReported&&(Vt.b.warn("playback not stuck anymore @"+r+", after "+Math.round(performance.now()-this.stalled)+"ms"),this.stallReported=!1),this.stalled=void 0,this.nudgeRetry=0;else if(o){var u=performance.now(),d=this.hls;if(this.stalled){var c=u-this.stalled,h=s.len,f=this.nudgeRetry||0,p=this.fragmentTracker.getPartialFragment(r);if(null!==p)for(var v=0,y=0;y=v&&r.5&&c>1e3*e.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,Vt.b.warn("playback stalling in high buffer @"+r),d.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:jt.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:h})),this.stalled=void 0,this.nudgeRetry=++f,f"+t),this.hls.trigger(qt.a.STREAM_STATE_TRANSITION,{previousState:e,nextState:t})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getBufferedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;return t?this.followingBufferedFrag(this.getBufferedFrag(t.currentTime)):null}},{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(t){this._liveSyncPosition=t}}]),e}(Ge),qe=je,Ve=function(){function t(t,e){for(var r=0;r0){r=e[0].bitrate,e.sort(function(t,e){return t.bitrate-e.bitrate}),this._levels=e;for(var d=0;d0})}else this.hls.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:jt.a.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},e.prototype.setLevelInternal=function(t){var e=this._levels,r=this.hls;if(t>=0&&t1&&o.loadError0&&(e=t.urlId,this.hls.trigger(qt.a.LEVEL_LOADING,{url:t.url[e],level:this.currentLevelIndex,id:e}))},Ve(e,[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;e&&(t=Math.min(t,e.length-1),this.currentLevelIndex===t&&void 0!==e[t].details||this.setLevelInternal(t))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}]),e}(Xt),ze=We,Ye=r(4),Xe=function(t){function e(r){q(this,e);var i=V(this,t.call(this,r,qt.a.MEDIA_ATTACHED,qt.a.MEDIA_DETACHING,qt.a.FRAG_PARSING_METADATA));return i.id3Track=void 0,i.media=void 0,i}return W(e,t),e.prototype.destroy=function(){Xt.prototype.destroy.call(this)},e.prototype.onMediaAttached=function(t){this.media=t.media,this.media},e.prototype.onMediaDetaching=function(){j(this.id3Track),this.id3Track=void 0,this.media=void 0},e.prototype.getID3Track=function(t){for(var e=0;e=this.minWeight_},t.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.prototype.destroy=function(){},t}(),tr=Ze,er=function(){function t(t,e){for(var r=0;r500*r.duration/o){var l=t.levels,u=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/s),d=l[r.level],c=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,h=a.total?a.total:Math.max(a.loaded,Math.round(r.duration*c/8)),f=e.currentTime,p=(h-a.loaded)/u,v=(_e.bufferInfo(e,f,t.config.maxBufferHole).end-f)/o;if(v<2*r.duration/o&&p>v){var y=void 0,g=void 0;for(g=r.level-1;g>n;g--){var m=l[g].realBitrate?Math.max(l[g].realBitrate,l[g].bitrate):l[g].bitrate;if((y=r.duration*m/(6.4*u))=i;u--){var d=l[u],c=d.details,h=c?c.totalduration/c.fragments.length:e,f=!!c&&c.live,p=void 0;p=u<=t?s*r:o*r;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,y=v*h/p;if(Vt.b.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+v+"/"+h+"/"+a+"/"+y),p>v&&(!y||f&&!this.bitrateTestDelay||y=0)return h;Vt.b.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var f=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,v=i.abrBandWidthUpFactor;if(0===c){var y=this.bitrateTestDelay;if(y){f=(o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay)-y,Vt.b.trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),p=v=1}}return h=this._findBestLevel(s,o,d,n,e,c+f,p,v,r),Math.max(h,0)}}]),e}(Xt),ir=rr,nr=b(),ar=function(t){function e(r){Z(this,e);var i=tt(this,t.call(this,r,qt.a.MEDIA_ATTACHING,qt.a.MEDIA_DETACHING,qt.a.MANIFEST_PARSED,qt.a.BUFFER_RESET,qt.a.BUFFER_APPENDING,qt.a.BUFFER_CODECS,qt.a.BUFFER_EOS,qt.a.BUFFER_FLUSHING,qt.a.LEVEL_PTS_UPDATED,qt.a.LEVEL_UPDATED));return i._msDuration=null,i._levelDuration=null,i._live=null,i._objectUrl=null,i.onsbue=i.onSBUpdateEnd.bind(i),i.onsbe=i.onSBUpdateError.bind(i),i.pendingTracks={},i.tracks={},i}return et(e,t),e.prototype.destroy=function(){Xt.prototype.destroy.call(this)},e.prototype.onLevelPtsUpdated=function(t){var e=t.type,r=this.tracks.audio;if("audio"===e&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(Math.abs(i.timestampOffset-t.start)>.1){var n=i.updating;try{i.abort()}catch(t){n=!0,Vt.b.warn("can not abort audio buffer: "+t)}n?this.audioTimestampOffset=t.start:(Vt.b.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+t.start),i.timestampOffset=t.start)}}},e.prototype.onManifestParsed=function(t){var e=t.audio,r=t.video||t.levels.length&&t.audio,i=0;t.altAudio&&(e||r)&&(i=(e?1:0)+(r?1:0),Vt.b.log(i+" sourceBuffer(s) expected")),this.sourceBufferNb=i},e.prototype.onMediaAttaching=function(t){var e=this.media=t.media;if(e){var r=this.mediaSource=new nr;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),e.src=URL.createObjectURL(r),this._objectUrl=e.src}},e.prototype.onMediaDetaching=function(){Vt.b.log("media source detaching");var t=this.mediaSource;if(t){if("open"===t.readyState)try{t.endOfStream()}catch(t){Vt.b.warn("onMediaDetaching:"+t.message+" while calling endOfStream")}t.removeEventListener("sourceopen",this.onmso),t.removeEventListener("sourceended",this.onmse),t.removeEventListener("sourceclose",this.onmsc),this.media&&(URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):Vt.b.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(qt.a.MEDIA_DETACHED)},e.prototype.onMediaSourceOpen=function(){Vt.b.log("media source opened"),this.hls.trigger(qt.a.MEDIA_ATTACHED,{media:this.media});var t=this.mediaSource;t&&t.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},e.prototype.checkPendingTracks=function(){var t=this.pendingTracks,e=Object.keys(t).length;e&&(this.sourceBufferNb<=e||0===this.sourceBufferNb)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},e.prototype.onMediaSourceClose=function(){Vt.b.log("media source closed")},e.prototype.onMediaSourceEnded=function(){Vt.b.log("media source ended")},e.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var t=this.sourceBuffer.audio;Vt.b.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+this.audioTimestampOffset),t.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var e=this.parent,r=this.segments.reduce(function(t,r){return r.parent===e?t+1:t},0),i={},n=this.sourceBuffer;for(var a in n)i[a]=n[a].buffered;this.hls.trigger(qt.a.BUFFER_APPENDED,{parent:e,pending:r,timeRanges:i}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()},e.prototype.onSBUpdateError=function(t){Vt.b.error("sourceBuffer error:",t),this.hls.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:jt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferReset=function(){var t=this.sourceBuffer;for(var e in t){var r=t[e];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(t){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},e.prototype.onBufferCodecs=function(t){if(0===Object.keys(this.sourceBuffer).length){for(var e in t)this.pendingTracks[e]=t[e];var r=this.mediaSource;r&&"open"===r.readyState&&this.checkPendingTracks()}},e.prototype.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;for(var i in t)if(!e[i]){var n=t[i],a=n.levelCodec||n.codec,s=n.container+";codecs="+a;Vt.b.log("creating sourceBuffer("+s+")");try{var o=e[i]=r.addSourceBuffer(s);o.addEventListener("updateend",this.onsbue),o.addEventListener("error",this.onsbe),this.tracks[i]={codec:a,container:n.container},n.buffer=o}catch(t){Vt.b.error("error while trying to add sourceBuffer:"+t.message),this.hls.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:jt.a.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:t,mimeType:s})}}this.hls.trigger(qt.a.BUFFER_CREATED,{tracks:t})},e.prototype.onBufferAppending=function(t){this._needsFlush||(this.segments?this.segments.push(t):this.segments=[t],this.doAppending())},e.prototype.onBufferAppendFail=function(t){Vt.b.error("sourceBuffer error:",t.event),this.hls.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:jt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferEos=function(t){var e=this.sourceBuffer,r=t.type;for(var i in e)r&&i!==r||e[i].ended||(e[i].ended=!0,Vt.b.log(i+" sourceBuffer now EOS"));this.checkEos()},e.prototype.checkEos=function(){var t=this.sourceBuffer,e=this.mediaSource;if(!e||"open"!==e.readyState)return void(this._needsEos=!1);for(var r in t){var i=t[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}Vt.b.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{e.endOfStream()}catch(t){Vt.b.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},e.prototype.onBufferFlushing=function(t){this.flushRange.push({start:t.startOffset,end:t.endOffset,type:t.type}),this.flushBufferCounter=0,this.doFlush()},e.prototype.onLevelUpdated=function(t){var e=t.details;e.fragments.length>0&&(this._levelDuration=e.totalduration+e.fragments[0].start,this._live=e.live,this.updateMediaElementDuration())},e.prototype.updateMediaElementDuration=function(){var t=this.hls.config,e=void 0;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer)if(!0===this.sourceBuffer[r].updating)return;e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(Vt.b.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||e===1/0||isNaN(e))&&(Vt.b.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},e.prototype.doFlush=function(){for(;this.flushRange.length;){var t=this.flushRange[0];if(!this.flushBuffer(t.start,t.end,t.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var e=0,r=this.sourceBuffer;try{for(var i in r)e+=r[i].buffered.length}catch(t){Vt.b.error("error while accessing sourceBuffer.buffered")}this.appended=e,this.hls.trigger(qt.a.BUFFER_FLUSHED)}},e.prototype.doAppending=function(){var t=this.hls,e=this.sourceBuffer,r=this.segments;if(Object.keys(e).length){if(this.media.error)return this.segments=[],void Vt.b.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var i=r.shift();try{var n=i.type,a=e[n];a?a.updating?r.unshift(i):(a.ended=!1,this.parent=i.parent,a.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(e){Vt.b.error("error while trying to append buffer:"+e.message),r.unshift(i);var s={type:jt.b.MEDIA_ERROR,parent:i.parent};22!==e.code?(this.appendError?this.appendError++:this.appendError=1,s.details=jt.a.BUFFER_APPEND_ERROR,this.appendError>t.config.appendErrorMaxRetry?(Vt.b.log("fail "+t.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],s.fatal=!0,t.trigger(qt.a.ERROR,s)):(s.fatal=!1,t.trigger(qt.a.ERROR,s))):(this.segments=[],s.details=jt.a.BUFFER_FULL_ERROR,s.fatal=!1,t.trigger(qt.a.ERROR,s))}}}},e.prototype.flushBuffer=function(t,e,r){var i=void 0,n=void 0,a=void 0,s=void 0,o=void 0,l=void 0,u=this.sourceBuffer;if(Object.keys(u).length){if(Vt.b.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+t+"/"+e),this.flushBufferCounter.5)return this.flushBufferCounter++,Vt.b.log("flush "+d+" ["+o+","+l+"], of ["+a+","+s+"], pos:"+this.media.currentTime),i.remove(o,l),!1}catch(t){Vt.b.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else Vt.b.warn("abort flushing too many retries");Vt.b.log("buffer flushed")}return!0},e}(Xt),sr=ar,or=function(){function t(t,e){for(var r=0;rthis.autoLevelCapping&&e.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.prototype.getMaxLevel=function(t){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,n){return e.isLevelAllowed(n,r.restrictedLevels)&&n<=t});return e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},e.isLevelAllowed=function(t){return-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(t)},e.getMaxLevelByMediaSize=function(t,e,r){if(!t||t&&!t.length)return-1;for(var i=t.length-1,n=0;n=e||a.height>=r)&&function(t,e){return!e||(t.width!==e.width||t.height!==e.height)}(a,t[n+1])){i=n;break}}return i},or(e,[{key:"mediaWidth",get:function(){var t=void 0,r=this.media;return r&&(t=r.width||r.clientWidth||r.offsetWidth,t*=e.contentScaleFactor),t}},{key:"mediaHeight",get:function(){var t=void 0,r=this.media;return r&&(t=r.height||r.clientHeight||r.offsetHeight,t*=e.contentScaleFactor),t}}],[{key:"contentScaleFactor",get:function(){var t=1;try{t=window.devicePixelRatio}catch(t){}return t}}]),e}(Xt),ur=lr,dr=function(t){function e(r){return at(this,e),st(this,t.call(this,r,qt.a.MEDIA_ATTACHING))}return ot(e,t),e.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},e.prototype.onMediaAttaching=function(t){var e=this.hls.config;if(e.capLevelOnFPSDrop){"function"==typeof(this.video=t.media instanceof HTMLVideoElement?t.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}},e.prototype.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(qt.a.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;Vt.b.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(qt.a.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.prototype.checkFPSInterval=function(){var t=this.video;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},e}(Xt),cr=dr,hr=function(){function t(e){lt(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return t.prototype.destroy=function(){this.abort(),this.loader=null},t.prototype.abort=function(){var t=this.loader;t&&4!==t.readyState&&(this.stats.aborted=!0,t.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.prototype.load=function(t,e,r){this.context=t,this.config=e,this.callbacks=r,this.stats={trequest:performance.now(),retry:0},this.retryDelay=e.retryDelay,this.loadInternal()},t.prototype.loadInternal=function(){var t=void 0,e=this.context;t=this.loader=new XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(t,e.url)}catch(r){t.open("GET",e.url,!0),i(t,e.url)}t.readyState||t.open("GET",e.url,!0)}catch(r){return void this.callbacks.onError({code:t.status,text:r.message},e,t)}e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),t.send()},t.prototype.readystatechange=function(t){var e=t.currentTarget,r=e.readyState,i=this.stats,n=this.context,a=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(performance.now(),i.trequest)),4===r){var s=e.status;if(s>=200&&s<300){i.tload=Math.max(i.tfirst,performance.now());var o=void 0,l=void 0;"arraybuffer"===n.responseType?(o=e.response,l=o.byteLength):(o=e.responseText,l=o.length),i.loaded=i.total=l;var u={url:e.responseURL,data:o};this.callbacks.onSuccess(u,i,n,e)}else i.retry>=a.maxRetry||s>=400&&s<499?(Vt.b.error(s+" while loading "+n.url),this.callbacks.onError({code:s,text:e.statusText},n,e)):(Vt.b.warn(s+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),a.timeout)},t.prototype.loadtimeout=function(){Vt.b.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.prototype.loadprogress=function(t){var e=t.currentTarget,r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,e)},t}(),fr=hr,pr=function(){function t(t,e){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){this.updateTrack(this.trackId)},e.prototype.onError=function(t){t.fatal&&t.type===jt.b.NETWORK_ERROR&&this.cleanTimer()},e.prototype.onManifestLoading=function(){this.tracks=[],this.trackId=-1},e.prototype.onManifestParsed=function(t){var e=this,r=t.audioTracks||[],i=!1;this.tracks=r,this.hls.trigger(qt.a.AUDIO_TRACKS_UPDATED,{audioTracks:r});var n=0;r.forEach(function(t){if(t.default&&!i)return e.audioTrack=n,void(i=!0);n++}),!1===i&&r.length&&(Vt.b.log("no default audio track defined, use first audio track as default"),this.audioTrack=0)},e.prototype.onAudioTrackLoaded=function(t){t.id=0&&t=0&&t0&&-1===t?(Vt.b.log("audio:override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=mr.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:t,this.state=mr.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=t,this.state=mr.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragmentTracker.removeFragment(t),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=mr.STOPPED},e.prototype.doTick=function(){var t=void 0,e=void 0,r=void 0,i=this.hls,n=i.config;switch(this.state){case mr.ERROR:case mr.PAUSED:case mr.BUFFER_FLUSHING:break;case mr.STARTING:this.state=mr.WAITING_TRACK,this.loadedmetadata=!1;break;case mr.IDLE:var a=this.tracks;if(!a)break;if(!this.media&&(this.startFragRequested||!n.startFragPrefetch))break;if(this.loadedmetadata)t=this.media.currentTime;else if(void 0===(t=this.nextLoadPosition))break;var s=this.mediaBuffer?this.mediaBuffer:this.media,o=this.videoBuffer?this.videoBuffer:this.media,l=_e.bufferInfo(s,t,n.maxBufferHole),u=_e.bufferInfo(o,t,n.maxBufferHole),d=l.len,c=l.end,h=this.fragPrevious,f=Math.min(n.maxBufferLength,n.maxMaxBufferLength),p=Math.max(f,u.len),v=this.audioSwitch,y=this.trackId;if((db||l.nextStart))return;Vt.b.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=b+.05}if(r.initSegment&&!r.initSegment.data)T=r.initSegment;else if(c<=b){if(T=g[0],null!==this.videoTrackCC&&T.cc!==this.videoTrackCC&&(T=k(g,this.videoTrackCC)),r.live&&T.loadIdx&&T.loadIdx===this.fragLoadIdx){var S=l.nextStart?l.nextStart:b;return Vt.b.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(S+.05)),void(this.media.currentTime=S+.05)}}else{var w=void 0,A=n.maxFragLookUpTolerance,R=h?g[h.sn-g[0].sn+1]:void 0,_=function(t){var e=Math.min(A,t.duration);return t.start+t.duration-e<=c?1:t.start-e>c&&t.start?-1:0};cE-A&&(A=0),w=R&&!_(R)?R:Ae.search(g,_)):w=g[m-1],w&&(T=w,b=w.start,h&&T.level===h.level&&T.sn===h.sn&&(T.sn=D||I)&&(Vt.b.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=mr.IDLE);break;case mr.WAITING_INIT_PTS:var O=this.videoTrackCC;if(void 0===this.initPTS[O])break;var x=this.waitingFragment;if(x){var P=x.frag.cc;O!==P?(e=this.tracks[this.trackId],e.details&&e.details.live&&(Vt.b.warn("Waiting fragment CC ("+P+") does not match video track CC ("+O+")"),this.waitingFragment=null,this.state=mr.IDLE)):(this.state=mr.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=mr.IDLE;break;case mr.STOPPED:case mr.FRAG_LOADING:case mr.PARSING:case mr.PARSED:case mr.ENDED:}},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(Vt.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){this.state===mr.ENDED&&(this.state=mr.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),this.tick()},e.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.prototype.onAudioTracksUpdated=function(t){Vt.b.log("audio tracks updated"),this.tracks=t.audioTracks},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url;this.trackId=t.id,this.fragCurrent=null,this.state=mr.PAUSED,this.waitingFragment=null,e?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),e&&(this.audioSwitch=!0,this.state=mr.IDLE),this.tick()},e.prototype.onAudioTrackLoaded=function(t){var e=t.details,r=t.id,i=this.tracks[r],n=e.totalduration,a=0;if(Vt.b.log("track "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+n),e.live){var s=i.details;s&&e.fragments.length>0?(_(s,e),a=e.fragments[0].start,e.PTSKnown?Vt.b.log("live audio playlist sliding:"+a.toFixed(3)):Vt.b.log("live audio playlist - outdated PTS, unknown sliding")):(e.PTSKnown=!1,Vt.b.log("live audio playlist - first load, unknown sliding"))}else e.PTSKnown=!1;if(i.details=e,!this.startFragRequested){if(-1===this.startPosition){var o=e.startTimeOffset;isNaN(o)?this.startPosition=0:(Vt.b.log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o)}this.nextLoadPosition=this.startPosition}this.state===mr.WAITING_TRACK&&(this.state=mr.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===mr.KEY_LOADING&&(this.state=mr.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===mr.FRAG_LOADING&&e&&"audio"===r.type&&r.level===e.level&&r.sn===e.sn){var i=this.tracks[this.trackId],n=i.details,a=n.totalduration,s=e.level,o=e.sn,l=e.cc,u=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",d=this.stats=t.stats;if("initSegment"===o)this.state=mr.IDLE,d.tparsed=d.tbuffered=performance.now(),n.initSegment.data=t.payload,this.hls.trigger(qt.a.FRAG_BUFFERED,{stats:d,frag:e,id:"audio"}),this.tick();else{this.state=mr.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new Ce(this.hls,"audio"));var c=this.initPTS[l],h=n.initSegment?n.initSegment.data:[];if(n.initSegment||void 0!==c){this.pendingBuffering=!0,Vt.b.log("Demuxing "+o+" of ["+n.startSN+" ,"+n.endSN+"],track "+s);this.demuxer.push(t.payload,h,u,null,e,a,!1,c)}else Vt.b.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+o+" of ["+n.startSN+" ,"+n.endSN+"],track "+s),this.waitingFragment=t,this.state=mr.WAITING_INIT_PTS}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===mr.PARSING){var i=t.tracks,n=void 0;if(i.video&&delete i.video,n=i.audio){n.levelCodec=n.codec,n.id=t.id,this.hls.trigger(qt.a.BUFFER_CODECS,i),Vt.b.log("audio track:audio,container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var a=n.initSegment;if(a){var s={type:"audio",data:a,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[s]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(qt.a.BUFFER_APPENDING,s))}this.tick()}}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"audio"===t.id&&"audio"===t.type&&i.sn===r.sn&&i.level===r.level&&this.state===mr.PARSING){var n=this.trackId,a=this.tracks[n],s=this.hls;isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),r.addElementaryStream(re.ElementaryStreamTypes.AUDIO),Vt.b.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),R(a.details,r,t.startPTS,t.endPTS);var o=this.audioSwitch,l=this.media,u=!1;if(o&&l)if(l.readyState){var d=l.currentTime;Vt.b.log("switching audio track : currentTime:"+d),d>=t.startPTS&&(Vt.b.log("switching audio track : flushing all audio"),this.state=mr.BUFFER_FLUSHING,s.trigger(qt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),u=!0,this.audioSwitch=!1,s.trigger(qt.a.AUDIO_TRACK_SWITCHED,{id:n}))}else this.audioSwitch=!1,s.trigger(qt.a.AUDIO_TRACK_SWITCHED,{id:n});var c=this.pendingData;if(!c)return console.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void s.trigger(qt.a.ERROR,{type:jt.b.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&c.push({type:t.type,data:e,parent:"audio",content:"data"})}),!u&&c.length&&(c.forEach(function(t){e.state===mr.PARSING&&(e.pendingBuffering=!0,e.hls.trigger(qt.a.BUFFER_APPENDING,t))}),this.pendingData=[],this.appended=!0)),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===mr.PARSING&&(this.stats.tparsed=performance.now(),this.state=mr.PARSED,this._checkAppendedParsed())},e.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.prototype.onBufferCreated=function(t){var e=t.tracks.audio;e&&(this.mediaBuffer=e.buffer,this.loadedmetadata=!0),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},e.prototype.onBufferAppended=function(t){if("audio"===t.parent){var e=this.state;e!==mr.PARSING&&e!==mr.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==mr.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent,e=this.stats,r=this.hls;if(t){this.fragPrevious=t,e.tbuffered=performance.now(),r.trigger(qt.a.FRAG_BUFFERED,{stats:e,frag:t,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;Vt.b.log("audio buffered : "+Ue.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(qt.a.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=mr.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag;if(!e||"audio"===e.type)switch(t.details){case jt.a.FRAG_LOAD_ERROR:case jt.a.FRAG_LOAD_TIMEOUT:if(!t.fatal){var r=this.fragLoadError;r?r++:r=1;var i=this.config;if(r<=i.fragLoadingMaxRetry){this.fragLoadError=r;var n=Math.min(Math.pow(2,r-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);Vt.b.warn("audioStreamController: frag loading failed, retry in "+n+" ms"),this.retryDate=performance.now()+n,this.state=mr.FRAG_LOADING_WAITING_RETRY}else Vt.b.error("audioStreamController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=mr.ERROR}break;case jt.a.AUDIO_TRACK_LOAD_ERROR:case jt.a.AUDIO_TRACK_LOAD_TIMEOUT:case jt.a.KEY_LOAD_ERROR:case jt.a.KEY_LOAD_TIMEOUT:this.state!==mr.ERROR&&(this.state=t.fatal?mr.ERROR:mr.IDLE,Vt.b.warn("audioStreamController: "+t.details+" while loading frag,switch to "+this.state+" state ..."));break;case jt.a.BUFFER_FULL_ERROR:if("audio"===t.parent&&(this.state===mr.PARSING||this.state===mr.PARSED)){var a=this.mediaBuffer,s=this.media.currentTime;if(a&&_e.isBuffered(a,s)&&_e.isBuffered(a,s+.5)){var o=this.config;o.maxMaxBufferLength>=o.maxBufferLength&&(o.maxMaxBufferLength/=2,Vt.b.warn("audio:reduce max buffer length to "+o.maxMaxBufferLength+"s")),this.state=mr.IDLE}else Vt.b.warn("buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=mr.BUFFER_FLUSHING,this.hls.trigger(qt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},e.prototype.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(Vt.b.log("appending pending audio data on Buffer Flushed"),e.forEach(function(e){t.hls.trigger(qt.a.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=mr.PARSED):(this.state=mr.IDLE,this.fragPrevious=null,this.tick())},gr(e,[{key:"state",set:function(t){if(this.state!==t){var e=this.state;this._state=t,Vt.b.log("audio stream:"+e+"->"+t)}},get:function(){return this._state}}]),e}(Ge),Er=br,Tr=function(){function t(t){return"string"==typeof t&&(!!a[t.toLowerCase()]&&t.toLowerCase())}function e(t){return"string"==typeof t&&(!!s[t.toLowerCase()]&&t.toLowerCase())}function r(t){for(var e=1;e100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},u,{get:function(){return T},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");T=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},u,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},u,{get:function(){return w},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");w=r,this.hasBeenReset=!0}})),o.displayState=void 0,l)return o}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var n="auto",a={"":!0,lr:!0,rl:!0},s={start:!0,middle:!0,end:!0,left:!0,right:!0};return i.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},i}(),Sr=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};gt.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,r){for(var i=0;i=0&&e<=100)&&(this.set(t,e),!0)}};var wr=new Tr(0,0,0),Ar="middle"===wr.align?"middle":"center";vt.prototype={parse:function(t){function e(){var t=r.buffer,e=0;for(t=Et(t);e=r&&console.log(this.time+" ["+t+"] "+e)}},Mr=function(t){for(var e=[],r=0;rDr&&(Fr.log("ERROR","Too large cursor position "+this.pos),this.pos=Dr)},t.prototype.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var e=Lr(t);if(this.pos>=Dr)return void Fr.log("ERROR","Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)},t.prototype.clearFromPos=function(t){var e=void 0;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},t.prototype.getTextAndFormat=function(){return this.rows},t}(),Kr=function(){function t(e,r){St(this,t),this.chNr=e,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new Gr,this.nonDisplayedMemory=new Gr,this.lastOutputScreen=new Gr,this.currRollUpRow=this.displayedMemory.rows[kr-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return t.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[kr-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},t.prototype.getHandler=function(){return this.outputFilter},t.prototype.setHandler=function(t){this.outputFilter=t},t.prototype.setPAC=function(t){this.writeScreen.setPAC(t)},t.prototype.setBkgData=function(t){this.writeScreen.setBkgData(t)},t.prototype.setMode=function(t){t!==this.mode&&(this.mode=t,Fr.log("INFO","MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},t.prototype.insertChars=function(t){for(var e=0;e=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[r]}Fr.log("INFO","MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},t.prototype.outputDataUpdate=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=Fr.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),!0===t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},t.prototype.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),Hr=function(){function t(e,r,i){St(this,t),this.field=e||1,this.outputs=[r,i],this.channels=[new Kr(1,r),new Kr(2,i)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return t.prototype.getHandler=function(t){return this.channels[t].getHandler()},t.prototype.setHandler=function(t,e){this.channels[t].setHandler(e)},t.prototype.addData=function(t,e){var r=void 0,i=void 0,n=void 0,a=!1;this.lastTime=t,Fr.setTime(t);for(var s=0;s ("+Mr([i,n])+")"),r=this.parseCmd(i,n),r||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(a=this.parseChars(i,n)))if(this.currChNr&&this.currChNr>=0){var o=this.channels[this.currChNr-1];o.insertChars(a)}else Fr.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:a?this.dataCounters.char+=2:(this.dataCounters.other+=2,Fr.log("WARNING","Couldn't parse cleaned data "+Mr([i,n])+" orig: "+Mr([e[s],e[s+1]])))}else this.dataCounters.padding+=2},t.prototype.parseCmd=function(t,e){var r=null,i=(20===t||28===t)&&e>=32&&e<=47,n=(23===t||31===t)&&e>=33&&e<=35;if(!i&&!n)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,Fr.log("DEBUG","Repeated command ("+Mr([t,e])+") is dropped"),!0;r=20===t||23===t?1:2;var a=this.channels[r-1];return 20===t||28===t?32===e?a.ccRCL():33===e?a.ccBS():34===e?a.ccAOF():35===e?a.ccAON():36===e?a.ccDER():37===e?a.ccRU(2):38===e?a.ccRU(3):39===e?a.ccRU(4):40===e?a.ccFON():41===e?a.ccRDC():42===e?a.ccTR():43===e?a.ccRTD():44===e?a.ccEDM():45===e?a.ccCR():46===e?a.ccENM():47===e&&a.ccEOC():a.ccTO(e-32),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.parseMidrow=function(t,e){var r=null;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currChNr)return Fr.log("ERROR","Mismatch channel in midrow parsing"),!1;return this.channels[r-1].ccMIDROW(e),Fr.log("DEBUG","MIDROW ("+Mr([t,e])+")"),!0}return!1},t.prototype.parsePAC=function(t,e){var r=null,i=null,n=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,a=(16===t||24===t)&&e>=64&&e<=95;if(!n&&!a)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=t<=23?1:2,i=e>=64&&e<=95?1===r?Ir[t]:xr[t]:1===r?Or[t]:Pr[t];var s=this.interpretPAC(i,e);return this.channels[r-1].setPAC(s),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.interpretPAC=function(t,e){var r=e,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.prototype.parseChars=function(t,e){var r=null,i=null,n=null;if(t>=25?(r=2,n=t-8):(r=1,n=t),n>=17&&n<=19){var a=e;a=17===n?e+80:18===n?e+112:e+144,Fr.log("INFO","Special char '"+Lr(a)+"' in channel "+r),i=[a]}else t>=32&&t<=127&&(i=0===e?[t]:[t,e]);if(i){var s=Mr(i);Fr.log("DEBUG","Char codes = "+s.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.prototype.parseBackgroundAttributes=function(t,e){var r=void 0,i=void 0,n=void 0,a=void 0,s=(16===t||24===t)&&e>=32&&e<=47,o=(23===t||31===t)&&e>=45&&e<=47;return!(!s&&!o)&&(r={},16===t||24===t?(i=Math.floor((e-32)/2),r.background=Cr[i],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0)),n=t<24?1:2,a=this.channels[n-1],a.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)},t.prototype.reset=function(){for(var t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.track)},t}(),Vr=qr,Wr=function(t,e,r){return t.substr(r||0,e.length)===e},zr=function(t){var e=parseInt(t.substr(-3)),r=parseInt(t.substr(-6,2)),i=parseInt(t.substr(-9,2)),n=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;return isNaN(e)||isNaN(r)||isNaN(i)||isNaN(n)?-1:(e+=1e3*r,e+=6e4*i,e+=36e5*n)},Yr=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()},Xr=function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;n&&n.new;)t.ccOffset+=i.start-n.start,i.new=!1,i=n,n=t[i.prevCC];t.presentationOffset=r},Qr={parse:function(t,e,r,i,n,a){var s=/\r\n|\n\r|\n|\r/g,o=Object(Ye.b)(new Uint8Array(t)).trim().replace(s,"\n").split("\n"),l="00:00.000",u=0,d=0,c=0,h=[],f=void 0,p=!0,v=new Rr;v.oncue=function(t){var e=r[i],n=r.ccOffset;e&&e.new&&(void 0!==d?n=r.ccOffset=e.start:Xr(r,i,c)),c&&(n=c+r.ccOffset-r.presentationOffset),t.startTime+=n-d,t.endTime+=n-d,t.id=Yr(t.startTime.toString())+Yr(t.endTime.toString())+Yr(t.text),t.text=decodeURIComponent(encodeURIComponent(t.text)),t.endTime>0&&h.push(t)},v.onparsingerror=function(t){f=t},v.onflush=function(){if(f&&a)return void a(f);n(h)},o.forEach(function(t){if(p){if(Wr(t,"X-TIMESTAMP-MAP=")){p=!1,t.substr(16).split(",").forEach(function(t){Wr(t,"LOCAL:")?l=t.substr(6):Wr(t,"MPEGTS:")&&(u=parseInt(t.substr(7)))});try{e=e<0?e+8589934592:e,u-=e,d=zr(l)/1e3,c=u/9e4,-1===d&&(f=new Error("Malformed X-TIMESTAMP-MAP: "+t))}catch(e){f=new Error("Malformed X-TIMESTAMP-MAP: "+t)}return}""===t&&(p=!1)}v.parse(t+"\n")}),v.flush()}},$r=Qr,Jr=function(t){function e(r){At(this,e);var i=Rt(this,t.call(this,r,qt.a.MEDIA_ATTACHING,qt.a.MEDIA_DETACHING,qt.a.FRAG_PARSING_USERDATA,qt.a.FRAG_DECRYPTED,qt.a.MANIFEST_LOADING,qt.a.MANIFEST_LOADED,qt.a.FRAG_LOADED,qt.a.LEVEL_SWITCHING,qt.a.INIT_PTS_FOUND));if(i.hls=r,i.config=r.config,i.enabled=!0,i.Cues=r.config.cueHandler,i.textTracks=[],i.tracks=[],i.unparsedVttFrags=[],i.initPTS=void 0,i.cueRanges=[],i.config.enableCEA708Captions){var n=new Vr(i,1),a=new Vr(i,2);i.cea608Parser=new jr(0,n,a)}return i}return _t(e,t),e.prototype.addCues=function(t,e,r,i){for(var n=this.cueRanges,a=!1,s=n.length;s--;){var o=n[s],l=kt(o[0],o[1],e,r);if(l>=0&&(o[0]=Math.min(o[0],e),o[1]=Math.max(o[1],r),a=!0,l/(r-e)>.5))return}a||n.push([e,r]),this.Cues.newCue(this[t],e,r,i)},e.prototype.onInitPtsFound=function(t){var e=this;void 0===this.initPTS&&(this.initPTS=t.initPTS),this.unparsedVttFrags.length&&(this.unparsedVttFrags.forEach(function(t){e.onFragLoaded(t)}),this.unparsedVttFrags=[])},e.prototype.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r=this.tracks.length)){this.timer&&(clearInterval(this.timer),this.timer=null);var e=xt(this.media.textTracks);if(-1!==this.trackId&&(e[this.trackId].mode="disabled"),this.trackId=t,Vt.b.log("switching to subtitle track "+t),this.hls.trigger(qt.a.SUBTITLE_TRACK_SWITCH,{id:t}),-1!==t){var r=this.tracks[t];t-1&&this.vttFragQueues[this.currentTrackId].length){var t=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.fragCurrent=t,this.hls.trigger(qt.a.FRAG_LOADING,{frag:t}),this.state=ni.FRAG_LOADING}},e.prototype.onSubtitleFragProcessed=function(t){t.success&&this.vttFragSNsProcessed[t.frag.trackId].push(t.frag.sn),this.currentlyProcessing=null,this.state=ni.IDLE,this.nextFrag()},e.prototype.onMediaAttached=function(){this.state=ni.IDLE},e.prototype.onError=function(t){var e=t.frag;e&&"subtitle"!==e.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())},e.prototype.doTick=function(){var t=this;switch(this.state){case ni.IDLE:var e=this.tracks,r=this.currentTrackId,i=this.vttFragSNsProcessed[r],n=this.vttFragQueues[r],a=this.currentlyProcessing?this.currentlyProcessing.sn:-1,s=function(t){return i.indexOf(t.sn)>-1},o=function(t){return n.some(function(e){return e.sn===t.sn})};if(!e)break;var l;if(r0&&null!=r&&null!=r.key&&"AES-128"===r.method){var a=void 0;try{a=performance.now()}catch(t){a=Date.now()}this.decrypter.decrypt(t.payload,r.key.buffer,r.iv.buffer,function(t){var e=void 0;try{e=performance.now()}catch(t){e=Date.now()}n.trigger(qt.a.FRAG_DECRYPTED,{frag:i,payload:t,stats:{tstart:a,tdecrypt:e}})})}},e}(Ge),si=ai,oi=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};Bt(this,t);var i=t.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var n in i)n in r||(r[n]=i[n]);if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(r.liveMaxLatencyDuration<=r.liveSyncDuration||void 0===r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(Vt.a)(r.debug),this.config=r,this._autoLevelCapping=-1;var a=this.observer=new De.a;a.trigger=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:-1;Vt.b.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.prototype.stopLoad=function(){Vt.b.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},t.prototype.swapAudioCodec=function(){Vt.b.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.prototype.recoverMediaError=function(){Vt.b.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)},vi(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){Vt.b.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){Vt.b.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){Vt.b.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){Vt.b.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){Vt.b.log("set startLevel:"+t);var e=this;-1!==t&&(t=Math.max(t,e.minAutoLevel)),e.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){Vt.b.log("set autoLevelCapping:"+t),this._autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var t=this,e=t.levels,r=t.config.minAutoBitrate,i=e?e.length:0,n=0;nr)return n}return 0}},{key:"maxAutoLevel",get:function(){var t=this,e=t.levels,r=t.autoLevelCapping;return-1===r&&e&&e.length?e.length-1:r}},{key:"nextAutoLevel",get:function(){var t=this;return Math.min(Math.max(t.abrController.nextAutoLevel,t.minAutoLevel),t.maxAutoLevel)},set:function(t){var e=this;e.abrController.nextAutoLevel=Math.max(e.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}}]),t}();e.default=yi},function(t,e,r){function i(t){function e(i){if(r[i])return r[i].exports;var n=r[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},e.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e.oe=function(t){throw console.error(t),t};var i=e(e.s=ENTRY_MODULE);return i.default||i}function n(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function a(t,e,i){var a={};a[i]=[];var s=e.toString(),o=s.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return a;for(var d,c=o[1],h=new RegExp("(\\\\n|\\W)"+n(c)+u,"g");d=h.exec(s);)"dll-reference"!==d[3]&&a[i].push(d[3]);for(h=new RegExp("\\("+n(c)+'\\("(dll-reference\\s('+l+'))"\\)\\)'+u,"g");d=h.exec(s);)t[d[2]]||(a[i].push(d[1]),t[d[2]]=r(d[1]).m),a[d[2]]=a[d[2]]||[],a[d[2]].push(d[4]);return a}function s(t){return Object.keys(t).reduce(function(e,r){return e||t[r].length>0},!1)}function o(t,e){for(var r={main:[e]},i={main:[]},n={main:{}};s(r);)for(var o=Object.keys(r),l=0;l1?r-1:0),n=1;n1?r-1:0),n=1;n1){var o=arguments[1];void 0!==o&&(s=o?Number(o):0)!=s&&(s=0)}var l=Math.min(Math.max(s,0),i),u=l-a;if(u<0)return!1;for(var d=-1;++d0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var r=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=r+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":n(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=s})},function(t,e,r){function i(t,e,r){if(!t&&!e&&!r)throw new Error("Missing required arguments");if(!o.string(e))throw new TypeError("Second argument must be a String");if(!o.fn(r))throw new TypeError("Third argument must be a Function");if(o.node(t))return n(t,e,r);if(o.nodeList(t))return a(t,e,r);if(o.string(t))return s(t,e,r);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function n(t,e,r){return t.addEventListener(e,r),{destroy:function(){t.removeEventListener(e,r)}}}function a(t,e,r){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,r)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,r)})}}}function s(t,e,r){return l(document.body,t,e,r)}var o=r(6),l=r(5);t.exports=i},function(t,e){function r(){}r.prototype={on:function(t,e,r){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:r}),this},once:function(t,e,r){function i(){n.off(t,i),e.apply(r,arguments)}var n=this;return i._=e,this.on(t,i,r)},emit:function(t){var e=[].slice.call(arguments,1),r=((this.e||(this.e={}))[t]||[]).slice(),i=0,n=r.length;for(i;i0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===h(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,c.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return l("action",t)}},{key:"defaultTarget",value:function(t){var e=l("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return l("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,r=!!document.queryCommandSupported;return e.forEach(function(t){r=r&&!!document.queryCommandSupported(t)}),r}}]),e}(d.default);t.exports=p})},function(t,e){function r(t,e){for(;t&&t.nodeType!==i;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var n=Element.prototype;n.matches=n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}t.exports=r},function(t,e,r){function i(t,e,r,i,n){var s=a.apply(this,arguments);return t.addEventListener(r,s,n),{destroy:function(){t.removeEventListener(r,s,n)}}}function n(t,e,r,n,a){return"function"==typeof t.addEventListener?i.apply(null,arguments):"function"==typeof r?i.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return i(t,e,r,n,a)}))}function a(t,e,r,i){return function(r){r.delegateTarget=s(r.target,e),r.delegateTarget&&i.call(t,r)}}var s=r(4);t.exports=n},function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var r=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===r||"[object HTMLCollection]"===r)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e){function r(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var r=t.hasAttribute("readonly");r||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),r||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var i=window.getSelection(),n=document.createRange();n.selectNodeContents(t),i.removeAllRanges(),i.addRange(n),e=i.toString()}return e}t.exports=r}])})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={NativeDash:"dash",NativeHls:"hls",NativeFlv:"flv",HtmlMediaElement:"html5"};e.default=i},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e){t.exports=''},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=/mobile/i.test(window.navigator.userAgent),r={element:t.element||document.getElementsByClassName("mplayer")[0],type:t.type||"html5",preload:"auto",mobile:!1,hotkey:!1,autoplay:!1,loop:!1,blob:!1,volume:40,loggerType:t.loggerType||1};e&&(t.autoplay=!1,t.mobile=!0);for(var i in r)r.hasOwnProperty(i)&&!t.hasOwnProperty(i)&&(t[i]=r[i]);return t}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),n=function(t){return t&&t.__esModule?t:{default:t}}(i),a={build:function(t,e){return'\n
\n \n
\n
\n [x]\n
    \n
  • \n Player:\n MPlayer @build.20180511-r2\n
  • \n
  • \n Support Mode:\n Html5, Flv, Hls, M(PEG)-Dash\n
  • \n
  • \n Current Mode:\n default\n
  • \n
  • \n Video ID:\n v10001\n
  • \n
  • \n Viewport:\n 900x506\n
  • \n
  • \n Volume:\n 40\n
  • \n
  • \n Codecs:\n video/mp4;codecs="avc1.640028"\n
  • \n
  • \n Host:\n video-s1.shirasagi.moe\n
  • \n
  • \n Connection Speed:\n 479Kb/s\n
  • \n
  • \n Dropped frames:\n 0\n
  • \n
\n
\n \n
\n
    \n
\n
\n \n \x3c!--\n
\n
'+n.default.play+'
\n
\n --\x3e\n
\n
'+n.default.play+'
\n
\n \n
\n 10%\n
\n
\n '+n.default.play+'\n
\n
\n '+n.default.loading+'\n
\n \n
\n
\n
\n
00:00
\n \n
\n
\n
\n \n
\n
\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n
\n\n
\n
\n 00:00 / 00:00\n
\n
\n
\n \n \n \n
\n
    \n
  • 播放速度:1 倍
  • \n
  • 镜像模式:
  • \n
  • 方向热键:开启
  • \n
  • 洗脑循环:关闭
  • \n
\n \n
\n
\n \n \n
\n \n
\n
\n\n "}};e.default=a},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r0?r:0,r=r<1?r:1,t.bar.played.style.width=(100*r).toFixed(2)+"%",t.player.seek(r*t.video.duration)}};this.bar.played.addEventListener("mousedown",r),this.bar.load.addEventListener("mousedown",function(e){for(var r=e.offsetX,i=e.target;i!==t.bar.load;)r+=i.offsetLeft,i=i.parentNode;var n=r/t.bar.load.offsetWidth;return n=n>0?n:0,n=n<1?n:1,t.bar.played.style.width=(100*n).toFixed(2)+"%",t.player.seek(parseFloat(n)*t.video.duration),e.preventDefault(),!1}),this.bar.load.addEventListener("mousemove",function(e){if(t.video.duration&&!(t.video.duration<=0)){var r=(e.clientX-t.bar.load.getBoundingClientRect().left)/t.bar.load.offsetWidth;r=r>0?r:0,r=r<1?r:1;var i=(0,s.formatTime)(parseFloat(r)*t.video.duration);t.bar.timerLabel.style.left=100*r+"%",t.bar.timerLabel.innerText=i,t.bar.hover.style.width=100*r+"%"}}),this.updateLoadBar=function(){var e=t.video.currentTime/t.video.duration,r=t.video.buffered.length?t.video.buffered.end(t.video.buffered.length-1)/t.video.duration:0,i=(100*e).toFixed(2)+"%",n=(100*r).toFixed(2)+"%";t.bar.loaded.style.width=n,t.bar.played.style.width=i},this.events.push(this.updateLoadBar)}},{key:"initVolumeBar",value:function(){var t=this;this.volumeBar={},this.volumeBar.bar=this.element.querySelector(".volume-bar"),this.volumeBar.inner=this.element.querySelector(".volume-bar-inner"),this.volumeBar.min=this.volumeBar.bar.offsetLeft,this.volumeBar.max=this.volumeBar.min+this.volumeBar.offsetWidth,this.setVolume=function(e){e=e>100?100:e,e=e<0?0:e,e=parseInt(e),l.default.debug("Volume change to "+e),0===parseInt(e)?(t.video.muted=!0,t.button.volume.innerHTML=d.default.mute,t.volumeBar.inner.style.width="0%"):(t.video.muted=!1,t.video.volume=(e/100).toFixed(2),t.volumeBar.inner.style.width=e+"%",e>0&&e<30?t.button.volume.innerHTML=d.default.volume1:e<=60?t.button.volume.innerHTML=d.default.volume2:e>=60&&(t.button.volume.innerHTML=d.default.volume3)),t.player.notice.showAutoHide("音量 "+e),t.player.infoPanel.setVolumeText(e)},this.getVolume=function(){return t.video.volume};var e=function(e){var r=t.volumeBar.bar.getBoundingClientRect().left,i=(e.clientX-r)/t.volumeBar.bar.offsetWidth*100;t.setVolume(i)},r=function(r){return e(r),t.element.addEventListener("mousemove",i),t.element.addEventListener("mouseup",n),r.preventDefault(),r.stopPropagation(),!1},i=function(t){e(t)},n=function e(r){t.element.removeEventListener("mousemove",i),t.element.removeEventListener("mouseup",e)};this.volumeBar.inner.addEventListener("mousedown",r),this.volumeBar.bar.addEventListener("mousedown",function(t){e(t)})}},{key:"initPlayTimer",value:function(){var t=this;this.timer={},this.timer.current=this.element.querySelector(".play-time .play-current"),this.timer.duration=this.element.querySelector(".play-time .play-duration"),this.updateTimer=function(){t.timer.current.innerText=(0,s.formatTime)(t.video.currentTime),t.timer.duration.innerText=(0,s.formatTime)(t.video.duration)},this.events.push(this.updateTimer)}},{key:"initSettingGroup",value:function(){var t=this;this.settings={};var e=this.element.querySelector(".setting-group");this.playSpeedBox=this.element.querySelector(".play-speed-box"),this.settings.playSpeed=e.querySelector(".play-speed"),this.settings.mirror=e.querySelector(".mirror"),this.settings.hotkey=e.querySelector(".hotkey"),this.settings.loop=e.querySelector(".loop");var r=function(t){for(var e=t.getElementsByTagName("li"),r=0;r3&&r()},300)}),this.player.video.addEventListener("canplay",r)}},{key:"autoHide",value:function(){var t=this;this.show(),clearTimeout(this.autoHideControls),this.autoHideControls=setTimeout(function(){t.video.played.length&&t.status!=c.PAUSE&&t.hide()},3e3)}},{key:"show",value:function(){this.player.element.classList.remove("player-hide-control")}},{key:"hide",value:function(){this.player.element.classList.add("player-hide-control"),this.button.setting.checked=!1}},{key:"_mirror",value:function(){this.mirror?(this.video.style.transform="scaleX(1)",this.settings.mirror.querySelector(".text").innerText="关",this.player.notice.showAutoHide("镜像 关")):(this.video.style.transform="scaleX(-1)",this.settings.mirror.querySelector(".text").innerText="开",this.player.notice.showAutoHide("镜像 开")),this.mirror=!this.mirror}},{key:"_loop",value:function(){this.video.loop?(this.video.loop=!1,this.settings.loop.querySelector(".text").innerText="关闭",this.player.notice.showAutoHide("循环播放 关")):(this.video.loop=!0,this.settings.loop.querySelector(".text").innerText="开启",this.player.notice.showAutoHide("循环播放 开"))}}]),t}();e.default=h},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r