/** * videojs-hlsjs-plugin * v1.0.15 * 2020-06-29 * www.streamroot.io * Copyright © 2018 **/ window.hlsSourceHandler=function(r){var i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}return a.m=r,a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,r){"use strict";var i=r(1);window.videojs&&(i.registerConfigPlugin(window.videojs),i.registerSourceHandler(window.videojs)),e.exports={register:i.registerSourceHandler}},function(e,t,r){"use strict";var C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I=r(2);function i(e){var t=this;e&&(t.srOptions_||(t.srOptions_={}),t.srOptions_.hlsjsConfig||(t.srOptions_.hlsjsConfig=e.hlsjsConfig),t.srOptions_.captionConfig||(t.srOptions_.captionConfig=e.captionConfig))}e.exports={registerSourceHandler:function(D){var e,O={};function r(r,n){n.name_="StreamrootHlsjs";var s,o=n.el(),i={},a=null,l=null,u=null,d=null,c=null,f=null,g=D(n.options_.playerId),h=g.qualityLevels&&g.qualityLevels();h&&g.hlsQualitySelector&&(n.hls={});var p=!1;function v(e){1===i[I.ErrorTypes.MEDIA_ERROR]?s.recoverMediaError():2===i[I.ErrorTypes.MEDIA_ERROR]?(s.swapAudioCodec(),s.recoverMediaError()):2>>8^255&v^99,m=h[t[e[f]=v]=f],y=h[m],E=h[y],T=257*h[v]^16843008*v;i[f]=T<<24|T>>>8,a[f]=T<<16|T>>>16,n[f]=T<<8|T>>>24,s[f]=T,T=16843009*E^65537*y^257*m^16843008*f,l[v]=T<<24|T>>>8,u[v]=T<<16|T>>>16,d[v]=T<<8|T>>>24,c[v]=T,f?(f=m^h[h[h[E^m]]],g^=h[h[g]]):f=g=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i>>5}function v(e,t){return!!(t+1>>6),c=(60&t[r+2])>>>2;if(!(u.length-1>>6,ee.logger.log("manifest codec:"+i+",ADTS data:type:"+d+",sampleingIndex:"+c+"["+u[c]+"Hz],channelConfig:"+n),a=/firefox/i.test(o)?6<=c?(d=5,s=new Array(4),c-3):(d=2,s=new Array(2),c):-1!==o.indexOf("android")?(d=2,s=new Array(2),c):(d=5,s=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=c?c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=c&&1==n||/vivaldi/i.test(o))||!i&&1==n)&&(d=2,s=new Array(2)),c)),s[0]=d<<3,s[0]|=(14&c)>>1,s[1]|=(1&c)<<7,s[1]|=n<<3,5===d&&(s[1]|=(14&a)>>1,s[2]=(1&a)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:u[c],channelCount:n,codec:"mp4a.40."+d,manifestCodec:l};e.trigger(J.default.ERROR,{type:Z.ErrorTypes.MEDIA_ERROR,details:Z.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(t,r,i,a),e.config=n.config,e.samplerate=n.samplerate,e.channelCount=n.channelCount,e.codec=n.codec,e.manifestCodec=n.manifestCodec,ee.logger.log("parsed codec:"+e.codec+",rate:"+n.samplerate+",nb channel:"+n.channelCount))}function y(e){return 9216e4/e}function E(e,t,r,i,a){var n=function(e,t,r,i,a){var n=e.length,s=d(e,t),o=c(e,t);if(0<(o-=s)&&t+s+o<=n)return{headerLength:s,frameLength:o,stamp:r+i*a}}(t,r,i,a,y(e.samplerate));if(n){var s=n.stamp,o=n.headerLength,l=n.frameLength,u={unit:t.subarray(r+o,r+o+l),pts:s,dts:s};return e.samples.push(u),{sample:u,length:l+o}}}var w=r("./src/demux/id3.js"),_=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(w.default.getID3Data(e,0)||[]).length,r=e.length;tt.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!=r&&0!=a&&15!=a&&3!=n){var o=3==r?3-i:3==i?3:4,l=1e3*T.BitratesMap[14*o+a-1],u=3==r?0:2==r?1:2,d=T.SamplingRateMap[3*u+n],c=e[t+3]>>6==3?1:2,h=T.SamplesCoefficients[r][i],f=T.BytesInSlot[i],g=8*h*f;return{sampleRate:d,channelCount:c,frameLength:parseInt(h*l/d+s,10)*f,samplesPerFrame:g}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e||(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return 32>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(t,r,i,a,n,s){var o=this.discardEPB(n.data),e=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(e.buffer,function(e){n.data=l.getAvcDecryptedUnit(o,e),s||l.decryptAvcSamples(t,r,i+1,a)})},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),s={video:1,audio:2,id3:3,text:4},A=function(){function C(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var e=C.prototype;return e.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new n(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},C.probe=function(e){var t=C._syncOffset(e);return!(t<0)&&(t&&ee.logger.warn("MPEG2-TS detected but first sync word found @ offset "+t+", junk ahead ?"),!0)},C._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r>4){if((o=a+5+e[a+4])===a+188)continue}else o=a+4;switch(s){case p:n&&(E&&(l=R(E))&&A(l,!1),E={data:[],size:0}),E&&(E.data.push(e.subarray(o,a+188)),E.size+=a+188-o);break;case v:n&&(T&&(l=R(T))&&(f.isAAC?k:w)(l),T={data:[],size:0}),T&&(T.data.push(e.subarray(o,a+188)),T.size+=a+188-o);break;case m:n&&(b&&(l=R(b))&&L(l),b={data:[],size:0}),b&&(b.data.push(e.subarray(o,a+188)),b.size+=a+188-o);break;case 0:n&&(o+=e[o]+1),y=this._pmtId=S(e,o);break;case y:n&&(o+=e[o]+1);var O=_(e,o,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(p=O.avc)&&(h.pid=p),0<(v=O.audio)&&(f.pid=v,f.isAAC=O.isAAC),0<(m=O.id3)&&(g.pid=m),d&&!c&&(ee.logger.log("reparse from beginning"),d=!1,a=D-188),c=this.pmtParsed=!0;break;case 17:case 8191:break;default:d=!0}}else this.observer.trigger(J.default.ERROR,{type:Z.ErrorTypes.MEDIA_ERROR,details:Z.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});E&&(l=R(E))?(A(l,!0),h.pesData=null):h.pesData=E,T&&(l=R(T))?((f.isAAC?k:w)(l),f.pesData=null):(T&&T.size&&ee.logger.log("last AAC PES packet truncated,might overlap between fragments"),f.pesData=T),b&&(l=R(b))?(L(l),g.pesData=null):g.pesData=b,null==this.sampleAes?this.remuxer.remux(f,h,g,this._txtTrack,t,r,i):this.decryptAndRemux(f,h,g,this._txtTrack,t,r,i)},e.decryptAndRemux=function(e,t,r,i,a,n,s){var o;e.samples&&e.isAAC?(o=this).sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}):this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},e.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){var o;t.samples?(o=this).sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,i,a,n,s)}):this.remuxer.remux(e,t,r,i,a,n,s)},e.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e._parsePMT=function(e,t,r,i){var a,n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);te.size-6)return null;if(192&(r=t[7])&&(4294967295<(s=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)&&(s-=8589934592),64&r?(4294967295<(o=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)&&(o-=8589934592),54e5=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.pts>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},h.mdia=function(e){return h.box(h.types.mdia,h.mdhd(e.timescale,e.duration),h.hdlr(e.type),h.minf(e))},h.mfhd=function(e){return h.box(h.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},h.minf=function(e){return"audio"===e.type?h.box(h.types.minf,h.box(h.types.smhd,h.SMHD),h.DINF,h.stbl(e)):h.box(h.types.minf,h.box(h.types.vmhd,h.VMHD),h.DINF,h.stbl(e))},h.moof=function(e,t,r){return h.box(h.types.moof,h.mfhd(e),h.traf(r,t))},h.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=h.trak(e[t]);return h.box.apply(null,[h.types.moov,h.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(h.mvex(e)))},h.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=h.trex(e[t]);return h.box.apply(null,[h.types.mvex].concat(r))},h.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+o)),i=Math.floor(t%(1+o)),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,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,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 h.box(h.types.mvhd,a)},h.sdtp=function(e){for(var t,r=e.samples||[],i=new Uint8Array(4+r.length),a=0;a>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(n=0;n>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var s=h.box(h.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(a))),o=e.width,l=e.height,u=e.pixelRatio[0],d=e.pixelRatio[1];return h.box(h.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,o>>8&255,255&o,l>>8&255,255&l,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]),s,h.box(h.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),h.box(h.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,d>>24,d>>16&255,d>>8&255,255&d])))},h.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},h.mp4a=function(e){var t=e.samplerate;return h.box(h.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,t>>8&255,255&t,0,0]),h.box(h.types.esds,h.esds(e)))},h.mp3=function(e){var t=e.samplerate;return h.box(h.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,t>>8&255,255&t,0,0]))},h.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?h.box(h.types.stsd,h.STSD,h.mp4a(e)):h.box(h.types.stsd,h.STSD,h.mp3(e)):h.box(h.types.stsd,h.STSD,h.avc1(e))},h.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,i=e.width,a=e.height,n=Math.floor(r/(1+o)),s=Math.floor(r%(1+o));return h.box(h.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s,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,i>>8&255,255&i,0,0,a>>8&255,255&a,0,0]))},h.traf=function(e,t){var r=h.sdtp(e),i=e.id,a=Math.floor(t/(1+o)),n=Math.floor(t%(1+o));return h.box(h.types.traf,h.box(h.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),h.box(h.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n])),h.trun(e,r.length+16+20+8+16+8+8),r)},h.trak=function(e){return e.duration=e.duration||4294967295,h.box(h.types.trak,h.tkhd(e),h.mdia(e))},h.trex=function(e){var t=e.id;return h.box(h.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},h.trun=function(e,t){var r,i,a,n,s,o,l=e.samples||[],u=l.length,d=12+16*u,c=new Uint8Array(d);for(t+=8+d,c.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r>>24&255,a>>>16&255,a>>>8&255,255&a,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,o>>>24&255,o>>>16&255,o>>>8&255,255&o],12+16*r);return h.box(h.types.trun,c)},h.initSegment=function(e){h.types||h.init();var t=h.moov(e),r=new Uint8Array(h.FTYP.byteLength+t.byteLength);return r.set(h.FTYP),r.set(t,h.FTYP.byteLength),r},h}();function l(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var a=e*t*r;return i?Math.round(a):a}function re(e,t){return void 0===t&&(t=!1),l(e,1e3,1/9e4,t)}function u(e,t){return void 0===t&&(t=1),l(e,9e4,1/t)}var S,Y=u(10),ie=u(.2),D=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r;var a=navigator.userAgent;this.isSafari=i&&-1>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(n);break;case 12:case 13:s=e[d++],u+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[d++],o=e[d++],u+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&o)<<0)}}return u},o}();var a=i._utf8ArrayToStr;t.default=i},"./src/demux/mp4demuxer.js":function(e,t,r){"use strict";r.r(t);var c=r("./src/utils/logger.js"),l=r("./src/events.js"),o=Math.pow(2,32)-1,i=function(){function p(e,t){this.observer=e,this.remuxer=t}var e=p.prototype;return e.resetTimeStamp=function(e){this.initPTS=e},e.resetInitSegment=function(e,t,r,i){var a,n;e&&e.byteLength?(null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e"),n={},(a=this.initData=p.parseInitSegment(e)).audio&&a.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:i?e:null}:(a.audio&&(n.audio={container:"audio/mp4",codec:t,initSegment:i?e:null}),a.video&&(n.video={container:"video/mp4",codec:r,initSegment:i?e:null})),this.observer.trigger(l.default.FRAG_PARSING_INIT_SEGMENT,{tracks:n})):(t&&(this.audioCodec=t),r&&(this.videoCodec=r))},p.probe=function(e){return 0>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},p.findBox=function(e,t){var r,i,a,n,s,o,l=[];if(e.data?(s=e.start,a=e.end,e=e.data):(s=0,a=e.byteLength),!t.length)return null;for(r=s;r>>31)return;var g=p.readUint32(n,c+=4);c+=4,t.push({referenceSize:f,subsegmentDuration:g,info:{duration:g/o,start:l,end:l+f-1}}),l+=f,a=c+=4}return{earliestPresentationTime:0,timescale:o,version:s,referencesCount:u,references:t,moovEndOffset:i}},p.parseInitSegment=function(e){var d=[];return p.findBox(e,["moov","trak"]).forEach(function(e){var t,r,i,a,n,s,o,l,u=p.findBox(e,["tkhd"])[0];u&&(t=u.data[u.start],r=p.readUint32(u,0===t?12:20),(i=p.findBox(e,["mdia","mdhd"])[0])&&(t=i.data[i.start],a=p.readUint32(i,0===t?12:20),!(n=p.findBox(e,["mdia","hdlr"])[0])||(s={soun:"audio",vide:"video"}[p.bin2str(n.data.subarray(n.start+8,n.start+12))])&&((o=p.findBox(e,["mdia","minf","stbl","stsd"])).length&&(o=o[0],l=p.bin2str(o.data.subarray(o.start+12,o.start+16)),c.logger.log("MP4Demuxer:"+s+":"+l+" found")),d[r]={timescale:a,type:s},d[s]={timescale:a,id:r})))}),d},p.getStartDTS=function(a,e){var t=p.findBox(e,["moof","traf"]),r=[].concat.apply([],t.map(function(i){return p.findBox(i,["tfhd"]).map(function(e){var t=p.readUint32(e,4),r=a[t].timescale||9e4;return p.findBox(i,["tfdt"]).map(function(e){var t=e.data[e.start],r=p.readUint32(e,4);return 1===t&&(r*=Math.pow(2,32),r+=p.readUint32(e,8)),r})[0]/r})})),i=Math.min.apply(null,r);return isFinite(i)?i:0},p.offsetStartDTS=function(i,e,s){p.findBox(e,["moof","traf"]).map(function(r){return p.findBox(r,["tfhd"]).map(function(e){var t=p.readUint32(e,4),n=i[t].timescale||9e4;p.findBox(r,["tfdt"]).map(function(e){var t,r,i=e.data[e.start],a=p.readUint32(e,4);0===i?p.writeUint32(e,4,a-s*n):(a*=Math.pow(2,32),a+=p.readUint32(e,8),a-=s*n,a=Math.max(a,0),t=Math.floor(a/(1+o)),r=Math.floor(a%(1+o)),p.writeUint32(e,4,t),p.writeUint32(e,8,r))})})})},e.append=function(e,t,r,i){var a=this.initData;a||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),a=this.initData);var n,s,o=this.initPTS;void 0===o&&(s=p.getStartDTS(a,e),this.initPTS=o=s-t,this.observer.trigger(l.default.INIT_PTS_FOUND,{initPTS:o})),p.offsetStartDTS(a,e,o),n=p.getStartDTS(a,e),this.remuxer.remux(a.audio,a.video,null,null,n,r,i,e)},e.destroy=function(){},p}();t.default=i},"./src/errors.ts":function(e,t,r){"use strict";var i,a,n,s;r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return n}),(a=i=i||{}).NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",(s=n=n||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException"},"./src/events.js":function(e,t,r){"use strict";r.r(t);t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":function(e,t,r){"use strict";r.r(t);var i={};r.r(i),r.d(i,"newCue",function(){return mt});var v,a,l,n,s=r("./node_modules/url-toolkit/src/url-toolkit.js"),h=r("./src/errors.ts"),F=r("./src/polyfills/number-isFinite.js"),M=r("./src/events.js"),N=r("./src/utils/logger.js"),o={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},u=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(1>8*(15-r)&255;return t},a.setDecryptDataFromLevelKey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new w(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},t=e,(r=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&N.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)),this._decryptdata):null;var e}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(F.isFiniteNumber)(this.programDateTime))return null;var e=Object(F.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&p(t.prototype,r),i&&p(t,i),e}();function m(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},e.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:t},e.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.enumeratedString=function(e){return this[e]},e.decimalResolution=function(e){var t=y.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},r.parseAttrList=function(e){var t,r={};for(E.lastIndex=0;null!==(t=E.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},r}(),T={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}};function b(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var S=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,_=/#EXT-X-MEDIA:(.*)/g,C=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),I=/(?:(?:#(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?/,x=/\.(mp4|m4s|m4v|m4a)$/i,R=function(){function d(){}return d.findGroup=function(e,t){for(var r=0;r=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){for(var i=e.buffered,a=[],n=0;nn&&(i[s-1].end=e[a].end):i.push(e[a])):i.push(e[a])}else i=e;for(var o,l=0,u=t,d=t,c=0;ce.endSN)return 0;for(u=h-e.startSN,(d=e.fragments)[u]=t,c=u;0i.length)return;for(var n=0;nr.startCC||e&&e.cci)return l}return null}function he(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=e?t[e.sn-t[0].sn+1]:null;return a&&!fe(r,i,a)?a:V.search(t,fe.bind(null,r,i))}function fe(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}var ge=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t,r=this.config,i=this.media,a=this.stalled,n=i.currentTime,s=i.seeking,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,n!==e)return this.moved=!0,void(null!==a&&(this.stallReported&&(t=self.performance.now()-a,N.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(t)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0));if((l||o)&&(this.stalled=null),!i.paused&&!i.ended&&0!==i.playbackRate&&i.buffered.length){var u=Y.bufferInfo(i,n,0),d=0r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(N.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,N.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(M.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s=n&&al&&l>h.currentTime&&(N.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+l.toFixed(3)),h.currentTime=l),this.nextLoadPosition=l),e.PTSKnown&&i=e.startSN&&u<=e.endSN&&(d=n[u-e.startSN],a.cc===d.cc&&(o=d,N.logger.log("live playlist, switching playlist, load frag with next SN: "+o.sn))),o||(o=V.search(n,function(e){return a.cc-e.cc}))&&N.logger.log("live playlist, switching playlist, load frag with same CC: "+o.sn))),o||(o=n[Math.min(s-1,Math.round(s/2))],N.logger.log("live playlist, switching playlist, unknown, load middle frag : "+o.sn))),o)},o._findFragment=function(e,t,r,i,a,n,s){var o,l,u,d,c,h,f=this.hls.config;return(o=an-f.maxFragLookUpTolerance?0:f.maxFragLookUpTolerance):i[r-1])&&(l=o.sn-s.startSN,u=t&&o.level===t.level,d=i[l-1],c=i[1+l],t&&o.sn===t.sn&&(u&&!o.backtracked?o.snf.maxBufferHole&&t.dropped&&l?(o=d,N.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):(o=c,N.logger.log("Re-loading fragment with SN: "+o.sn)):o=null:o.backtracked&&(c&&c.backtracked?(N.logger.warn("Already backtracked from fragment "+c.sn+", will not backtrack to fragment "+o.sn+". Loading fragment "+c.sn),o=c):(N.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),o.dropped=0,d?(o=d).backtracked=!0:l&&(o=null))))),o},o._loadKey=function(e){this.state=Te,this.hls.trigger(M.default.KEY_LOADING,{frag:e})},o._loadFragment=function(e){var t=this.fragmentTracker.getState(e);"initSegment"!==(this.fragCurrent=e).sn&&(this.startFragRequested=!0),Object(F.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===B||t===j?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(M.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new ee(this.hls,"main")),this.state=be):t===G&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},o.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,l.MAIN)},o.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},o._checkFragmentChanged=function(){var e,t,r,i,a=this.media;a&&a.readyState&&!1===a.seeking&&((i=a.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=i),Y.isBuffered(a,i)?e=this.getBufferedFrag(i):Y.isBuffered(a,i+.1)&&(e=this.getBufferedFrag(i+.1)),!e||(t=e)!==this.fragPlaying&&(this.hls.trigger(M.default.FRAG_CHANGED,{frag:t}),r=t.level,this.fragPlaying&&this.fragPlaying.level===r||this.hls.trigger(M.default.LEVEL_SWITCHED,{level:r}),this.fragPlaying=t))},o.immediateLevelSwitch=function(){var e,t;N.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,(e=this.media)?(t=e.paused,e.pause()):t=!0,this.previouslyPaused=t);var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},o.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,Y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},o.nextLevelSwitch=function(){var e,t,r,i,a,n,s,o=this.media;o&&o.readyState&&((s=this.getBufferedFrag(o.currentTime))&&1=e&&(t.maxMaxBufferLength/=2,N.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},o._checkBuffer=function(){var e,t=this.media;t&&0!==t.readyState&&(e=(this.mediaBuffer?this.mediaBuffer:t).buffered,!this.loadedmetadata&&e.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,e))},o.onFragLoadEmergencyAborted=function(){this.state=ye,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},o.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(f.VIDEO,e.buffered),this.state=ye,this.fragPrevious=null},o.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},o._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&0<=r&&(N.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},o._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(N.logger.log("swapping playlist audio codec"),t=t&&(-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},a=r,(n=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,N.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(M.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e}))},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&Ie(a.prototype,n),s&&Ie(a,s),r}(Ce);function Pe(e,t){for(var r=0;re[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var a=Math.floor((i+r)/2);if(te[a].endTime))return e[a];r=a+1}}return e[r].endTime-t=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function He(e,t){for(var r=0;r500*r.duration/o){var l=e.levels,u=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/s),d=l[r.level],c=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,h=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*c/8)),f=t.currentTime,g=(h-n.loaded)/u,p=(Y.bufferInfo(t,f,e.config.maxBufferHole).end-f)/o;if(p<2*r.duration/o&&ps.start(0)&&this.removeBufferRange(o,l,0,a)&&this.hls.trigger(M.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}else N.logger.error("flushLiveBackBuffer called without attaching media")}},a.onLevelUpdated=function(e){var t=e.details;0this._msDuration&&this._levelDuration>e||!Object(F.isFiniteNumber)(e))&&(N.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},a.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var a=r[i];a&&(t+=a.buffered.length)}}catch(e){N.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(M.default.BUFFER_FLUSHED)}},a.doAppending=function(){var t=this.config,r=this.hls,i=this.segments,e=this.sourceBuffer;if(Object.keys(e).length){if(!this.media||this.media.error)return this.segments=[],void N.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var a=i.shift();if(a)try{var n=e[a.type];if(!n)return void this._onSBUpdateEnd();if(n.updating)return void i.unshift(a);n.ended=!1,this.parent=a.parent,n.appendBuffer(a.data),this.appendError=0,this.appended++,this.appending=!0}catch(e){N.logger.error("error while trying to append buffer:"+e.message),i.unshift(a);var s={type:h.ErrorTypes.MEDIA_ERROR,parent:a.parent,details:"",fatal:!1};22===e.code?(this.segments=[],s.details=h.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,s.details=h.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.appendErrorMaxRetry&&(N.logger.log("fail "+t.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],s.fatal=!0)),r.trigger(M.default.ERROR,s)}}}},a.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),N.logger.log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return N.logger.warn("abort flushing too many retries"),!0;var n=i[r];if(n){if(n.ended=!1,n.updating)return N.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,n,e,t))return this.flushBufferCounter++,!1}return N.logger.log("buffer flushed"),!0},a.removeBufferRange=function(e,t,r,i){try{for(var a=0;athis.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},o.getMaxLevel=function(r){var i=this;if(!this.levels)return-1;var e=this.levels.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},o.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},o.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},a.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var i,a,n=e.length-1,s=0;s=t||o.height>=r)&&(i=o,!(a=e[s+1])||i.width!==a.width||i.height!==a.height)){n=s;break}}return n},i=a,s=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(n=[{key:"mediaWidth",get:function(){var e,t=this.media;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=a.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,t=this.media;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=a.contentScaleFactor),e}}])&&ze(i.prototype,n),s&&ze(i,s),a}(u);var Qe=window.performance,$e=function(t){var e,r;function i(e){return t.call(this,e,M.default.MEDIA_ATTACHING)||this}r=t,(e=i).prototype=Object.create(r.prototype),(e.prototype.constructor=e).__proto__=r;var a=i.prototype;return a.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},a.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},a.checkFPS=function(e,t,r){var i,a,n,s,o,l,u=Qe.now();t&&(this.lastTime&&(i=u-this.lastTime,a=r-this.lastDroppedFrames,n=t-this.lastDecodedFrames,s=1e3*a/i,(o=this.hls).trigger(M.default.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:r}),0o.config.fpsDroppedMonitoringThreshold*n&&(l=o.currentLevel,N.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),0=l)&&(--l,o.trigger(M.default.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:o.currentLevel}),o.autoLevelCapping=l,o.streamController.nextLevelSwitch()))),this.lastTime=u,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},a.checkFPSInterval=function(){var e,t=this.video;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},i}(u),Je=window,Ze=Je.performance,et=Je.XMLHttpRequest,tt=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Ze.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var t=this.context,r=this.loader=new et,e=this.stats;e.tfirst=0,e.loaded=0;var i=this.xhrSetup;try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),r.send()},t.readystatechange=function(e){var t,r,i,a,n=e.currentTarget,s=n.readyState,o=this.stats,l=this.context,u=this.config;o.aborted||2<=s&&(window.clearTimeout(this.requestTimeout),0===o.tfirst&&(o.tfirst=Math.max(Ze.now(),o.trequest)),4===s?200<=(t=n.status)&&t<300?(o.tload=Math.max(o.tfirst,Ze.now()),i="arraybuffer"===l.responseType?(r=n.response).byteLength:(r=n.responseText).length,o.loaded=o.total=i,a={url:n.responseURL,data:r},this.callbacks.onSuccess(a,o,l,n)):o.retry>=u.maxRetry||400<=t&&t<499?(N.logger.error(t+" while loading "+l.url),this.callbacks.onError({code:t,text:n.statusText},l,n)):(N.logger.warn(t+" while loading "+l.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,u.maxRetryDelay),o.retry++):this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),u.timeout))},t.loadtimeout=function(){N.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)},e}();function rt(e,t){for(var r=0;r=this.tracks.length?N.logger.warn("Invalid audio track id:",e.id):(N.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()&&(t=1e3*e.details.targetduration,this.setInterval(t)),!e.details.live&&this.hasInterval()&&this.clearInterval())},o.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},o.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},o.onError=function(e){e.type===h.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(N.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},o._setAudioTrack=function(e){var t,r,i,a;this._trackId===e&&this.tracks[this._trackId].details?N.logger.debug("Same id as current audio-track passed, and track details available -> no-op"):e<0||e>=this.tracks.length?N.logger.warn("Invalid id passed to audio-track controller"):(t=this.tracks[e],N.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e,r=t.url,i=t.type,a=t.id,this.hls.trigger(M.default.AUDIO_TRACK_SWITCHING,{id:a,type:i,url:r}),this._loadTrackDetailsIfNeeded(t))},o.doTick=function(){this._updateTrack(this._trackId)},o._selectAudioGroup=function(e){var t,r=this.hls.levels[e];r&&r.audioGroupIds&&(t=r.audioGroupIds[r.urlId],this.audioGroupId!==t&&(this.audioGroupId=t,this._selectInitialAudioTrack()))},o._selectInitialAudioTrack=function(){var e,t,r,i,a,n=this,s=this.tracks;s.length&&(e=this.tracks[this._trackId],t=null,e&&(t=e.name),this._selectDefaultTrack&&((r=s.filter(function(e){return e.default})).length?s=r:N.logger.warn("No default audio tracks defined")),i=!1,(a=function(){s.forEach(function(e){i||n.audioGroupId&&e.groupId!==n.audioGroupId||t&&t!==e.name||(n._setAudioTrack(e.id),i=!0)})})(),i||(t=null,a()),i||(N.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(M.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0})))},o._needsTrackLoading=function(e){var t=e.details,r=e.url;return!(t&&!t.live)&&!!r},o._loadTrackDetailsIfNeeded=function(e){var t,r;this._needsTrackLoading(e)&&(t=e.url,r=e.id,N.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(M.default.AUDIO_TRACK_LOADING,{url:t,id:r}))},o._updateTrack=function(e){var t;e<0||e>=this.tracks.length||(this.clearInterval(),this._trackId=e,N.logger.log("trying to update audio-track "+e),t=this.tracks[e],this._loadTrackDetailsIfNeeded(t))},o._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,a=t.groupId;N.logger.warn("Loading failed on audio track id: "+e+", group-id: "+a+', name/language: "'+r+'" / "'+i+'"');for(var n=e,s=0;sS||d.nextStart))return;N.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=S+.05}if(r.initSegment&&!r.initSegment.data)E=r.initSegment;else if(f<=S){if(E=T[0],null!==this.videoTrackCC&&E.cc!==this.videoTrackCC&&(i=T,a=this.videoTrackCC,E=V.search(i,function(e){return e.cca?-1:0})),r.live&&E.loadIdx&&E.loadIdx===this.fragLoadIdx){var R=d.nextStart?d.nextStart:S;return N.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(R+.05)),void(this.media.currentTime=R+.05)}}else{var A=s.maxFragLookUpTolerance,k=g?T[g.sn-T[0].sn+1]:void 0,w=function(e){var t=Math.min(A,e.duration);return e.start+e.duration-t<=f?1:e.start-t>f&&e.start?-1:0},L=f<_?(_-A=t.startPTS&&(N.logger.log("switching audio track : flushing all audio"),this.state=ke,s.trigger(M.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),d=!0,this.audioSwitch=!1,s.trigger(M.default.AUDIO_TRACK_SWITCHED,{id:a}))):(this.audioSwitch=!1,s.trigger(M.default.AUDIO_TRACK_SWITCHED,{id:a})));var c=this.pendingData;if(!c)return N.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void s.trigger(M.default.ERROR,{type:h.ErrorTypes.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"})}),!d&&c.length&&(c.forEach(function(e){r.state===Re&&(r.pendingBuffering=!0,r.hls.trigger(M.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}},o.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Re&&(this.stats.tparsed=st.now(),this.state=Ae,this._checkAppendedParsed())},o.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},o.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},o.onBufferAppended=function(e){var t;"audio"===e.parent&&((t=this.state)!==Re&&t!==Ae||(this.pendingBuffering=0=i.maxBufferLength&&(i.maxMaxBufferLength/=2,N.logger.warn("AudioStreamController: reduce max buffer length to "+i.maxMaxBufferLength+"s")),this.state=ye):(N.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=ke,this.hls.trigger(M.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})))}},o.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(N.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),e.forEach(function(e){t.hls.trigger(M.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=Ae):(this.state=ye,this.fragPrevious=null,this.tick())},a=r,(n=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,N.logger.log("audio stream:"+t+"->"+e))},get:function(){return this._state}}])&&at(a.prototype,n),s&&at(a,s),r}(Ce),lt=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var E={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function T(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function b(e){for(var t=1;t/gi,"\n")}ut.prototype={parse:function(e){var t,i=this;function r(){for(var e=0,t=pt(t=i.buffer);e>>0).toString()}var Ot={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e){this.verboseFilter[e];this.verboseLevel}},Ct=function(){function e(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;rbt&&(Ot.log("ERROR","Too large cursor position "+this.pos),this.pos=bt)},t.moveCursor=function(e){var t=this.pos+e;if(1=bt?Ot.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){for(var t=e;t ("+wt([n,s])+")"),(r=(r=(r=(r=this.parseCmd(n,s))||this.parseMidrow(n,s))||this.parsePAC(n,s))||this.parseBackgroundAttributes(n,s))||(i=this.parseChars(n,s))&&(this.currChNr&&0<=this.currChNr?this.channels[this.currChNr-1].insertChars(i):Ot.log("WARNING","No channel found yet. TEXT-MODE?")),r?this.dataCounters.cmd+=2:i?this.dataCounters.char+=2:(this.dataCounters.other+=2,Ot.log("WARNING","Couldn't parse cleaned data "+wt([n,s])+" orig: "+wt([t[a],t[a+1]])))):this.dataCounters.padding+=2}},t.parseCmd=function(e,t){var r=null;if(!((20===e||28===e)&&32<=t&&t<=47)&&!((23===e||31===e)&&33<=t&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,Ot.log("DEBUG","Repeated command ("+wt([e,t])+") is dropped"),!0;r=20===e||23===e?1:2;var i=this.channels[r-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.parseMidrow=function(e,t){var r=null;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currChNr?(Ot.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),Ot.log("DEBUG","MIDROW ("+wt([e,t])+")"),!0))},t.parsePAC=function(e,t){var r,i=null;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127)&&!((16===e||24===e)&&64<=t&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,!(this.lastCmdB=null);r=e<=23?1:2,i=64<=t&&t<=95?1==r?St[e]:Rt[e]:1==r?_t[e]:At[e];var a=this.interpretPAC(i,t);return this.channels[r-1].setPAC(a),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.interpretPAC=function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e},r=95e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),Ut={parse:function(e,t,i,a,r,n){var s,o=Object(Ne.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),l="00:00.000",u=0,d=0,c=0,h=[],f=!0,g=!1,p=new vt;p.oncue=function(e){var t=i[a],r=i.ccOffset;t&&t.new&&(void 0!==d?r=i.ccOffset=t.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;a&&a.new;)e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC];e.presentationOffset=r}(i,a,c)),c&&(r=c-i.presentationOffset),g&&(e.startTime+=r-d,e.endTime+=r-d),e.id=Dt(e.startTime.toString())+Dt(e.endTime.toString())+Dt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),0=s.length||i!==n||!o||this.stopped?this._clearReloadTimer():(N.logger.log("subtitle track "+i+" loaded"),a.live?(t=se(o.details,a,e.stats.trequest),N.logger.log("Reloading live subtitle playlist in "+t+"ms"),this.timer=setTimeout(function(){r._loadCurrentTrack()},t)):this._clearReloadTimer())},o.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},o.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},o._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},o._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(N.logger.log("Loading subtitle track "+e),r.trigger(M.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},o._toggleTrackModes=function(e){var t,r,i,a=this.media,n=this.subtitleDisplay,s=this.trackId;a&&(t=Kt(a.textTracks),-1===e?[].slice.call(t).forEach(function(e){e.mode="disabled"}):(r=t[s])&&(r.mode="disabled"),(i=t[e])&&(i.mode=n?"showing":"hidden"))},o._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(F.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,N.logger.log("Switching to subtitle track "+e),t.trigger(M.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},o._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Kt(this.media.textTracks),r=0;r=i[s].start&&n<=i[s].end){a=i[s];break}var o=t.start+t.duration;a?a.end=o:(a={start:n,end:o},i.push(a))}}},a.onMediaAttached=function(e){var t=e.media;(this.media=t).addEventListener("seeking",this._onMediaSeeking),this.state=ye},a.onMediaDetaching=function(){var t=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]}),this.media=null,this.state=ve)},a.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=ye)},a.onSubtitleTracksUpdated=function(e){var t=this;N.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})},a.onSubtitleTrackSwitch=function(e){var t;this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId?(t=this.tracks[this.currentTrackId])&&t.details&&this.setInterval(500):this.clearInterval()},a.onSubtitleTrackLoaded=function(e){var t=e.id,r=e.details,i=this.currentTrackId,a=this.tracks,n=a[i];t>=a.length||t!==i||!n||(r.live&&function(e,t,r){void 0===r&&(r=0);var i=-1;ne(e,t,function(e,t,r){t.start=e.start,i=r});var a=t.fragments;if(i<0)a.forEach(function(e){e.start+=r});else for(var n=i+1;n "+t)),s.apply(o.console,i)}:a}var u=function(e){if(o.console&&!0===e||"object"==typeof e){!function(t){for(var e=arguments.length,r=new Array(1