13 lines
257 KiB
JavaScript
13 lines
257 KiB
JavaScript
|
typeof window!="undefined"&&function(R,T){typeof exports=="object"&&typeof module=="object"?module.exports=T():typeof define=="function"&&define.amd?define([],T):typeof exports=="object"?exports.Hls=T():R.Hls=T()}(this,function(){return function(w){var R={};function T(_){if(R[_])return R[_].exports;var A=R[_]={i:_,l:!1,exports:{}};return w[_].call(A.exports,A,A.exports,T),A.l=!0,A.exports}return T.m=w,T.c=R,T.d=function(_,A,m){T.o(_,A)||Object.defineProperty(_,A,{enumerable:!0,get:m})},T.r=function(_){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})},T.t=function(_,A){if(A&1&&(_=T(_)),A&8||A&4&&typeof _=="object"&&_&&_.__esModule)return _;var m=Object.create(null);if(T.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:_}),A&2&&typeof _!="string")for(var y in _)T.d(m,y,function(f){return _[f]}.bind(null,y));return m},T.n=function(_){var A=_&&_.__esModule?function(){return _.default}:function(){return _};return T.d(A,"a",A),A},T.o=function(_,A){return Object.prototype.hasOwnProperty.call(_,A)},T.p="/dist/",T(T.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(w,R,T){"use strict";var _=Object.prototype.hasOwnProperty,A="~";function m(){}Object.create&&(m.prototype=Object.create(null),new m().__proto__||(A=!1));function y(c,a,o){this.fn=c,this.context=a,this.once=o||!1}function f(c,a,o,r,i){if(typeof o!="function")throw new TypeError("The listener must be a function");var t=new y(o,r||c,i),e=A?A+a:a;return c._events[e]?c._events[e].fn?c._events[e]=[c._events[e],t]:c._events[e].push(t):(c._events[e]=t,c._eventsCount++),c}function u(c,a){--c._eventsCount==0?c._events=new m:delete c._events[a]}function p(){this._events=new m,this._eventsCount=0}p.prototype.eventNames=function(){var a=[],o,r;if(this._eventsCount===0)return a;for(r in o=this._events)_.call(o,r)&&a.push(A?r.slice(1):r);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(o)):a},p.prototype.listeners=function(a){var o=A?A+a:a,r=this._events[o];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,t=r.length,e=new Array(t);i<t;i++)e[i]=r[i].fn;return e},p.prototype.listenerCount=function(a){var o=A?A+a:a,r=this._events[o];return r?r.fn?1:r.length:0},p.prototype.emit=function(a,o,r,i,t,e){var n=A?A+a:a;if(!this._events[n])return!1;var d=this._events[n],g=arguments.length,v,s;if(d.fn){switch(d.once&&this.removeListener(a,d.fn,void 0,!0),g){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,o),!0;case 3:return d.fn.call(d.context,o,r),!0;case 4:return d.fn.call(d.context,o,r,i),!0;case 5:return d.fn.call(d.context,o,r,i,t),!0;case 6:return d.fn.call(d.context,o,r,i,t,e),!0}for(s=1,v=new Array(g-1);s<g;s++)v[s-1]=arguments[s];d.fn.apply(d.context,v)}else{var l=d.length,x;for(s=0;s<l;s++)switch(d[s].once&&this.removeListener(a,d[s].fn,void 0,!0),g){case 1:d[s].fn.call(d[s].context);break;case 2:d[s].fn.call(d[s].context,o);break;case 3:d[s].fn.call(d[s].context,o,r);break;case 4:d[s].fn.call(d[s].context,o,r,i);break;default:if(!v)for(x=1,v=new Array(g-1);x<g;x++)v[x-1]=arguments[x];d[s].fn.apply(d[s].context,v)}}return!0},p.prototype.on=function(a,o,r){return f(this,a,o,r,!1)},p.prototype.once=function(a,o,r){return f(this,a,o,r,!0)},p.prototype.removeListener=function(a,o,r,i){var t=A?A+a:a;if(!this._events[t])return this;if(!o)return u(this,t),this;var e=this._events[t];if(e.fn)e.fn===o&&(!i||e.once)&&(!r||e.context===r)&&u(this,t);else{for(var n=0,d=[],g=e.length;n<g;n++)(e[n].fn!==o||i&&!e[n].once||r&&e[n].context!==r)&&d.push(e[n]);d.length?this._events[t]=d.length===1?d[0]:d:u(this,t)}return this},p.prototype.removeAllListeners=function(a){var o;return a?(o=A?A+a:a,this._events[o]&&u(this,o)):(this._events=new m,this._eventsCount=0),this},p.prototype.off=p.prototype.removeListener,p.prototype.addListener=p.prototype.on,p.prefixed=A,p.EventEmitter=p,w.exports=p},"./node_modules/node-libs-browser/node_modules/events/events.js":function(w,R){function T(){this._events=this._events||{},this._maxLi
|
||
|
`}),t=t+"new (("+_.toString().replace("ENTRY_MODULE",JSON.stringify(a))+")({"+i.main.map(function(v){return""+JSON.stringify(v)+": "+r.main[v].toString()}).join(",")+"}))(self);";var e=new window.Blob([t],{type:"text/javascript"});if(o.bare)return e;var n=window.URL||window.webkitURL||window.mozURL||window.msURL,d=n.createObjectURL(e),g=new window.Worker(d);return g.objectURL=d,g}},"./src/config.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/controller/abr-controller.js"),A=T("./src/controller/buffer-controller.js"),m=T("./src/controller/cap-level-controller.js"),y=T("./src/controller/fps-controller.js"),f=T("./src/utils/xhr-loader.js"),u=T("./src/controller/audio-track-controller.js"),p=T("./src/controller/audio-stream-controller.js"),c=T("./src/utils/cues.js"),a=T("./src/controller/timeline-controller.js"),o=T("./src/controller/subtitle-track-controller.js"),r=T("./src/controller/subtitle-stream-controller.js"),i=T("./src/controller/eme-controller.js"),t=T("./src/utils/mediakeys-helper.js");R.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:Infinity,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:f.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:_.default,bufferController:A.default,capLevelController:m.default,fpsController:y.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,requestMediaKeySystemAccessFunc:t.requestMediaKeySystemAccess},R.hlsDefaultConfig.subtitleStreamController=r.SubtitleStreamController,R.hlsDefaultConfig.subtitleTrackController=o.default,R.hlsDefaultConfig.timelineController=a.default,R.hlsDefaultConfig.cueHandler=c,R.hlsDefaultConfig.enableCEA708Captions=!0,R.hlsDefaultConfig.enableWebVTT=!0,R.hlsDefaultConfig.captionsTextTrack1Label="English",R.hlsDefaultConfig.captionsTextTrack1LanguageCode="en",R.hlsDefaultConfig.captionsTextTrack2Label="Spanish",R.hlsDefaultConfig.captionsTextTrack2LanguageCode="es",R.hlsDefaultConfig.audioStreamController=p.default,R.hlsDefaultConfig.audioTrackController=u.default,R.hlsDefaultConfig.emeController=i.default},"./src/controller/abr-controller.js":function(w,R,T){"use strict";(function(_){var A=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,t){i.__proto__=t}||function(i,t){for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e])};return function(i,t){r(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}}();Object.defineProperty(R,"__esModule",{value:!0});var m=T("./src/events.js"),y=T("./src/event-handler.js"),f=T("./src/utils/buffer-helper.js"),u=T("./src/errors.js"),p=T("./src/utils/logger.js"),c=T("./src/utils/ewma-bandwidth-estimator.js"),a=window.performance,o=function(r){A(i,r);function i(t){var e=r.call(this,t,m.default.FRAG_LOADING,m.default.FRAG_LOADED,m.default.FRA
|
||
|
`)),x},v.prototype.getTextAndFormat=function(){return this.rows},v}(),d=function(){function v(s,l){this.chNr=s,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new n,this.nonDisplayedMemory=new n,this.lastOutputScreen=new n,this.currRollUpRow=this.displayedMemory.rows[m-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return v.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[m-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},v.prototype.getHandler=function(){return this.outputFilter},v.prototype.setHandler=function(s){this.outputFilter=s},v.prototype.setPAC=function(s){this.writeScreen.setPAC(s)},v.prototype.setBkgData=function(s){this.writeScreen.setBkgData(s)},v.prototype.setMode=function(s){s!==this.mode&&(this.mode=s,o.log("INFO","MODE="+s),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=s)},v.prototype.insertChars=function(s){for(var l=0;l<s.length;l++)this.writeScreen.insertChar(s[l]);var x=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";o.log("INFO",x+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(o.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},v.prototype.ccRCL=function(){o.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},v.prototype.ccBS=function(){o.log("INFO","BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},v.prototype.ccAOF=function(){},v.prototype.ccAON=function(){},v.prototype.ccDER=function(){o.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},v.prototype.ccRU=function(s){o.log("INFO","RU("+s+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(s)},v.prototype.ccFON=function(){o.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},v.prototype.ccRDC=function(){o.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},v.prototype.ccTR=function(){o.log("INFO","TR"),this.setMode("MODE_TEXT")},v.prototype.ccRTD=function(){o.log("INFO","RTD"),this.setMode("MODE_TEXT")},v.prototype.ccEDM=function(){o.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},v.prototype.ccCR=function(){o.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},v.prototype.ccENM=function(){o.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},v.prototype.ccEOC=function(){if(o.log("INFO","EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,this.writeScreen=this.nonDisplayedMemory,o.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},v.prototype.ccTO=function(s){o.log("INFO","TO("+s+") - Tab Offset"),this.writeScreen.moveCursor(s)},v.prototype.ccMIDROW=function(s){var l={flash:!1};if(l.underline=s%2==1,l.italics=s>=46,l.italics)l.foreground="white";else{var x=Math.floor(s/2)-16,h=["white","green","blue","cyan","red","yellow","magenta"];l.foreground=h[x]}o.log("INFO","MIDROW: "+JSON.stringify(l)),this.writeScreen.setPen(l)},v.prototype.outputDataUpdate=function(s){s===void 0&&(s=!1);var l=o.time;l!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=l:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,l,this.lastOutputScreen),s===!0&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),thi
|
||
|
`)}R.fixLineBreaks=o,m.prototype={parse:function(r){var i=this;r&&(i.buffer+=i.decoder.decode(r,{stream:!0}));function t(){var s=i.buffer,l=0;for(s=o(s);l<s.length&&s[l]!=="\r"&&s[l]!==`
|
||
|
`;)++l;var x=s.substr(0,l);return s[l]==="\r"&&++l,s[l]===`
|
||
|
`&&++l,i.buffer=s.substr(l),x}function e(s){u(s,function(l,x){switch(l){case"Region":break}},/:/)}try{var n=void 0;if(i.state==="INITIAL"){if(!/\r\n|\n/.test(i.buffer))return this;n=t();var d=n.match(/^()?WEBVTT([ \t].*)?$/);if(!d||!d[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var g=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(g?g=!1:n=t(),i.state){case"HEADER":/:/.test(n)?e(n):n||(i.state="ID");continue;case"NOTE":n||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){i.state="NOTE";break}if(!n)continue;if(i.cue=new _.default(0,0,""),i.state="CUE",n.indexOf("-->")===-1){i.cue.id=n;continue}case"CUE":try{a(n,i.cue,i.regionList)}catch(s){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var v=n.indexOf("-->")!==-1;if(!n||v&&(g=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+=`
|
||
|
`),i.cue.text+=n;continue;case"BADCUE":n||(i.state="ID");continue}}}catch(s){i.state==="CUETEXT"&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state=i.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var r=this;try{if(r.buffer+=r.decoder.decode(),(r.cue||r.state==="HEADER")&&(r.buffer+=`
|
||
|
|
||
|
`,r.parse()),r.state==="INITIAL")throw new Error("Malformed WebVTT signature.")}catch(i){throw i}return r.onflush&&r.onflush(),this}},R.default=m},"./src/utils/webvtt-parser.js":function(w,R,T){"use strict";(function(_){Object.defineProperty(R,"__esModule",{value:!0});var A=T("./src/utils/vttparser.js"),m=T("./src/demux/id3.js"),y=function(a,o,r){return a.substr(r||0,o.length)===o},f=function(a){var o=parseInt(a.substr(-3)),r=parseInt(a.substr(-6,2)),i=parseInt(a.substr(-9,2)),t=a.length>9?parseInt(a.substr(0,a.indexOf(":"))):0;return!_.isFinite(o)||!_.isFinite(r)||!_.isFinite(i)||!_.isFinite(t)?-1:(o+=1e3*r,o+=60*1e3*i,o+=60*60*1e3*t,o)},u=function(a){for(var o=5381,r=a.length;r;)o=o*33^a.charCodeAt(--r);return(o>>>0).toString()},p=function(a,o,r){var i=a[o],t=a[i.prevCC];if(!t||!t.new&&i.new){a.ccOffset=a.presentationOffset=i.start,i.new=!1;return}for(;t&&t.new;)a.ccOffset+=i.start-t.start,i.new=!1,i=t,t=a[i.prevCC];a.presentationOffset=r},c={parse:function(a,o,r,i,t,e){var n=/\r\n|\n\r|\n|\r/g,d=m.utf8ArrayToStr(new Uint8Array(a)).trim().replace(n,`
|
||
|
`).split(`
|
||
|
`),g="00:00.000",v=0,s=0,l=0,x=[],h,E=!0,S=new A.default;S.oncue=function(b){var I=r[i],L=r.ccOffset;I&&I.new&&(s!==void 0?L=r.ccOffset=I.start:p(r,i,l)),l&&(L=l-r.presentationOffset),b.startTime+=L-s,b.endTime+=L-s,b.id=u(b.startTime.toString())+u(b.endTime.toString())+u(b.text),b.text=decodeURIComponent(encodeURIComponent(b.text)),b.endTime>0&&x.push(b)},S.onparsingerror=function(b){h=b},S.onflush=function(){if(h&&e){e(h);return}t(x)},d.forEach(function(b){if(E)if(y(b,"X-TIMESTAMP-MAP=")){E=!1,b.substr(16).split(",").forEach(function(I){y(I,"LOCAL:")?g=I.substr(6):y(I,"MPEGTS:")&&(v=parseInt(I.substr(7)))});try{o+(r[i].start*9e4||0)<0&&(o+=8589934592),v-=o,s=f(g)/1e3,l=v/9e4,s===-1&&(h=new Error("Malformed X-TIMESTAMP-MAP: "+b))}catch(I){h=new Error("Malformed X-TIMESTAMP-MAP: "+b)}return}else b===""&&(E=!1);S.parse(b+`
|
||
|
`)}),S.flush()}};R.default=c}).call(this,T("./src/polyfills/number.js").Number)},"./src/utils/xhr-loader.js":function(w,R,T){"use strict";Object.defineProperty(R,"__esModule",{value:!0});var _=T("./src/utils/logger.js"),A=window.performance,m=window.XMLHttpRequest,y=function(){function f(u){u&&u.xhrSetup&&(this.xhrSetup=u.xhrSetup)}return f.prototype.destroy=function(){this.abort(),this.loader=null},f.prototype.abort=function(){var u=this.loader;u&&u.readyState!==4&&(this.stats.aborted=!0,u.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},f.prototype.load=function(u,p,c){this.context=u,this.config=p,this.callbacks=c,this.stats={trequest:A.now(),retry:0},this.retryDelay=p.retryDelay,this.loadInternal()},f.prototype.loadInternal=function(){var u,p=this.context;u=this.loader=new m;var c=this.stats;c.tfirst=0,c.loaded=0;var a=this.xhrSetup;try{if(a)try{a(u,p.url)}catch(o){u.open("GET",p.url,!0),a(u,p.url)}u.readyState||u.open("GET",p.url,!0)}catch(o){this.callbacks.onError({code:u.status,text:o.message},p,u);return}p.rangeEnd&&u.setRequestHeader("Range","bytes="+p.rangeStart+"-"+(p.rangeEnd-1)),u.onreadystatechange=this.readystatechange.bind(this),u.onprogress=this.loadprogress.bind(this),u.responseType=p.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),u.send()},f.prototype.readystatechange=function(u){var p=u.currentTarget,c=p.readyState,a=this.stats,o=this.context,r=this.config;if(!a.aborted&&c>=2)if(window.clearTimeout(this.requestTimeout),a.tfirst===0&&(a.tfirst=Math.max(A.now(),a.trequest)),c===4){var i=p.status;if(i>=200&&i<300){a.tload=Math.max(a.tfirst,A.now());var t=void 0,e=void 0;o.responseType==="arraybuffer"?(t=p.response,e=t.byteLength):(t=p.responseText,e=t.length),a.loaded=a.total=e;var n={url:p.responseURL,data:t};this.callbacks.onSuccess(n,a,o,p)}else a.retry>=r.maxRetry||i>=400&&i<499?(_.logger.error(i+" while loading "+o.url),this.callbacks.onError({code:i,text:p.statusText},o,p)):(_.logger.warn(i+" while loading "+o.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,r.maxRetryDelay),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),r.timeout)},f.prototype.loadtimeout=function(){_.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},f.prototype.loadprogress=function(u){var p=u.currentTarget,c=this.stats;c.loaded=u.loaded,u.lengthComputable&&(c.total=u.total);var a=this.callbacks.onProgress;a&&a(c,this.context,null,p)},f}();R.default=y}}).default});
|