UNPKG

@tarojs/components

Version:

Taro 组件库。

29 lines • 437 kB
var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,a,n,s;return s={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(e){return function(t){return l([e,t])}}function l(s){if(i)throw new TypeError("Generator is already executing.");while(r)try{if(i=1,a&&(n=s[0]&2?a["return"]:s[0]?a["throw"]||((n=a["return"])&&n.call(a),0):a.next)&&!(n=n.call(a,s[1])).done)return n;if(a=0,n)s=[s[0]&2,n.value];switch(s[0]){case 0:case 1:n=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;a=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(n=r.trys,n=n.length>0&&n[n.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!n||s[1]>n[0]&&s[1]<n[3])){r.label=s[1];break}if(s[0]===6&&r.label<n[1]){r.label=n[1];n=s;break}if(n&&r.label<n[2]){r.label=n[2];r.ops.push(s);break}if(n[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];a=0}finally{i=n=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t){for(var r=0,i=t.length,a=e.length;r<i;r++,a++)e[a]=t[r];return e};import{r as registerInstance,h,H as Host,g as getElement,c as createEvent}from"./index-5bd7cbab.js";import{a as createCommonjsModule,b as commonjsGlobal,g as getDefaultExportFromCjs,c as classnames}from"./index-cd1a2d33.js";import{t as throttle}from"./index-cad8203e.js";var formatTime=function(e){if(!e)return"";var t=Math.round(e%60);var r=Math.round((e-t)/60);return(r<10?"0"+r:r)+":"+(t<10?"0"+t:t)};var calcDist=function(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))};var normalizeNumber=function(e){return Math.max(-1,Math.min(e,1))};var scene="default";var screenFn=function(){var e;var t=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]];var r=["webkitEnterFullscreen","webkitExitFullscreen","webkitCurrentFullScreenElement","webkitSupportsFullscreen","fullscreenchange","fullscreenerror"];var i=0;var a=t.length;var n={};for(;i<a;i++){e=t[i];if(e&&e[1]in document){for(i=0;i<e.length;i++){n[t[0][i]]=e[i]}return n}}if(!n[t[0][0]]){scene="iOS";for(i=0;i<r.length;i++){n[t[0][i]]=r[i]}}return n}();var isHls=function(e){return/\.(m3u8)($|\?)/i.test(e)};var __awaiter$2=undefined&&undefined.__awaiter||function(e,t,r,i){function a(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,n){function s(e){try{l(i.next(e))}catch(e){n(e)}}function o(e){try{l(i["throw"](e))}catch(e){n(e)}}function l(e){e.done?r(e.value):a(e.value).then(s,o)}l((i=i.apply(e,t||[])).next())}))};var VideoControl=function(){function e(e){var t=this;registerInstance(this,e);this.visible=false;this.isDraggingProgressBall=false;this.percentage=0;this.progressDimensions={left:0,width:0};this.calcPercentage=function(e){var r=e-t.progressDimensions.left;r=Math.max(r,0);r=Math.min(r,t.progressDimensions.width);return r/t.progressDimensions.width};this.onDragProgressBallStart=function(){t.isDraggingProgressBall=true;t.hideControlsTimer&&clearTimeout(t.hideControlsTimer)};this.onClickProgress=function(e){e.stopPropagation();var r=t.calcPercentage(e.pageX);t.seekFunc(r*t.duration);t.toggleVisibility(true)}}e.prototype.onDocumentTouchMove=function(e){if(!this.isDraggingProgressBall)return;var t=e.touches[0].pageX;this.percentage=this.calcPercentage(t);this.setProgressBall(this.percentage);this.setCurrentTime(this.percentage*this.duration)};e.prototype.onDocumentTouchEnd=function(){if(!this.isDraggingProgressBall)return;this.isDraggingProgressBall=false;this.seekFunc(this.percentage*this.duration);this.toggleVisibility(true)};e.prototype.setProgressBall=function(e){return __awaiter$2(this,void 0,void 0,(function(){return __generator(this,(function(t){if(this.progressBallRef){this.progressBallRef.style.left=e*100+"%"}return[2]}))}))};e.prototype.toggleVisibility=function(e){return __awaiter$2(this,void 0,void 0,(function(){var t;var r=this;return __generator(this,(function(i){t=e===undefined?!this.visible:e;if(t){this.hideControlsTimer&&clearTimeout(this.hideControlsTimer);if(this.isPlaying){this.hideControlsTimer=setTimeout((function(){r.toggleVisibility(false)}),2e3)}this.el.style.visibility="visible"}else{this.el.style.visibility="hidden"}this.visible=!!t;return[2]}))}))};e.prototype.getIsDraggingProgressBall=function(){return __awaiter$2(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.isDraggingProgressBall]}))}))};e.prototype.setCurrentTime=function(e){return __awaiter$2(this,void 0,void 0,(function(){return __generator(this,(function(t){this.currentTimeRef.innerHTML=formatTime(e);return[2]}))}))};e.prototype.render=function(){var e=this;var t=this,r=t.controls,i=t.currentTime,a=t.duration,n=t.isPlaying,s=t.pauseFunc,o=t.playFunc,l=t.showPlayBtn,u=t.showProgress;var f=formatTime(a);var c;if(!l){c=null}else if(n){c=h("div",{class:"taro-video-control-button taro-video-control-button-pause",onClick:s})}else{c=h("div",{class:"taro-video-control-button taro-video-control-button-play",onClick:o})}return h(Host,{class:"taro-video-bar taro-video-bar-full"},r&&h("div",{class:"taro-video-controls"},c,u&&h("div",{class:"taro-video-current-time",ref:function(t){return e.currentTimeRef=t}},formatTime(i)),u&&h("div",{class:"taro-video-progress-container",onClick:this.onClickProgress},h("div",{class:"taro-video-progress",ref:function(t){if(!t)return;var r=t.getBoundingClientRect();e.progressDimensions.left=r.left;e.progressDimensions.width=r.width}},h("div",{class:"taro-video-progress-buffered",style:{width:"100%"}}),h("div",{class:"taro-video-ball",ref:function(t){return e.progressBallRef=t},onTouchStart:this.onDragProgressBallStart,style:{left:(f?this.currentTime/a*100:0)+"%"}},h("div",{class:"taro-video-inner"})))),u&&h("div",{class:"taro-video-duration"},f)),h("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();var hls=createCommonjsModule((function(e,t){typeof window!=="undefined"&&function t(r,i){e.exports=i()}(commonjsGlobal,(function(){return function(e){var t={};function r(i){if(t[i]){return t[i].exports}var a=t[i]={i:i,l:false,exports:{}};e[i].call(a.exports,a,a.exports,r);a.l=true;return a.exports}r.m=e;r.c=t;r.d=function(e,t,i){if(!r.o(e,t)){Object.defineProperty(e,t,{enumerable:true,get:i})}};r.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})};r.t=function(e,t){if(t&1)e=r(e);if(t&8)return e;if(t&4&&typeof e==="object"&&e&&e.__esModule)return e;var i=Object.create(null);r.r(i);Object.defineProperty(i,"default",{enumerable:true,value:e});if(t&2&&typeof e!="string")for(var a in e)r.d(i,a,function(t){return e[t]}.bind(null,a));return i};r.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};r.d(t,"a",t);return t};r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};r.p="/dist/";return r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js": /*!*********************************************!*\ !*** ./node_modules/eventemitter3/index.js ***! \*********************************************/ /*! no static exports found */function(e,t,r){var i=Object.prototype.hasOwnProperty,a="~";function n(){}if(Object.create){n.prototype=Object.create(null);if(!(new n).__proto__)a=false}function s(e,t,r){this.fn=e;this.context=t;this.once=r||false}function o(e,t,r,i,n){if(typeof r!=="function"){throw new TypeError("The listener must be a function")}var o=new s(r,i||e,n),l=a?a+t:t;if(!e._events[l])e._events[l]=o,e._eventsCount++;else if(!e._events[l].fn)e._events[l].push(o);else e._events[l]=[e._events[l],o];return e}function l(e,t){if(--e._eventsCount===0)e._events=new n;else delete e._events[t]}function u(){this._events=new n;this._eventsCount=0}u.prototype.eventNames=function e(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events){if(i.call(r,n))t.push(a?n.slice(1):n)}if(Object.getOwnPropertySymbols){return t.concat(Object.getOwnPropertySymbols(r))}return t};u.prototype.listeners=function e(t){var r=a?a+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,o=new Array(s);n<s;n++){o[n]=i[n].fn}return o};u.prototype.listenerCount=function e(t){var r=a?a+t:t,i=this._events[r];if(!i)return 0;if(i.fn)return 1;return i.length};u.prototype.emit=function e(t,r,i,n,s,o){var l=a?a+t:t;if(!this._events[l])return false;var u=this._events[l],f=arguments.length,c,d;if(u.fn){if(u.once)this.removeListener(t,u.fn,undefined,true);switch(f){case 1:return u.fn.call(u.context),true;case 2:return u.fn.call(u.context,r),true;case 3:return u.fn.call(u.context,r,i),true;case 4:return u.fn.call(u.context,r,i,n),true;case 5:return u.fn.call(u.context,r,i,n,s),true;case 6:return u.fn.call(u.context,r,i,n,s,o),true}for(d=1,c=new Array(f-1);d<f;d++){c[d-1]=arguments[d]}u.fn.apply(u.context,c)}else{var h=u.length,v;for(d=0;d<h;d++){if(u[d].once)this.removeListener(t,u[d].fn,undefined,true);switch(f){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,r);break;case 3:u[d].fn.call(u[d].context,r,i);break;case 4:u[d].fn.call(u[d].context,r,i,n);break;default:if(!c)for(v=1,c=new Array(f-1);v<f;v++){c[v-1]=arguments[v]}u[d].fn.apply(u[d].context,c)}}}return true};u.prototype.on=function e(t,r,i){return o(this,t,r,i,false)};u.prototype.once=function e(t,r,i){return o(this,t,r,i,true)};u.prototype.removeListener=function e(t,r,i,n){var s=a?a+t:t;if(!this._events[s])return this;if(!r){l(this,s);return this}var o=this._events[s];if(o.fn){if(o.fn===r&&(!n||o.once)&&(!i||o.context===i)){l(this,s)}}else{for(var u=0,f=[],c=o.length;u<c;u++){if(o[u].fn!==r||n&&!o[u].once||i&&o[u].context!==i){f.push(o[u])}}if(f.length)this._events[s]=f.length===1?f[0]:f;else l(this,s)}return this};u.prototype.removeAllListeners=function e(t){var r;if(t){r=a?a+t:t;if(this._events[r])l(this,r)}else{this._events=new n;this._eventsCount=0}return this};u.prototype.off=u.prototype.removeListener;u.prototype.addListener=u.prototype.on;u.prefixed=a;u.EventEmitter=u;{e.exports=u}},"./node_modules/url-toolkit/src/url-toolkit.js": /*!*****************************************************!*\ !*** ./node_modules/url-toolkit/src/url-toolkit.js ***! \*****************************************************/ /*! no static exports found */function(e,t,r){(function(t){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/;var i=/^([^\/?#]*)([^]*)$/;var a=/(?:\/|^)\.(?=\/)/g;var n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var s={buildAbsoluteURL:function(e,t,r){r=r||{};e=e.trim();t=t.trim();if(!t){if(!r.alwaysNormalize){return e}var a=s.parseURL(e);if(!a){throw new Error("Error trying to parse base URL.")}a.path=s.normalizePath(a.path);return s.buildURLFromParts(a)}var n=s.parseURL(t);if(!n){throw new Error("Error trying to parse relative URL.")}if(n.scheme){if(!r.alwaysNormalize){return t}n.path=s.normalizePath(n.path);return s.buildURLFromParts(n)}var o=s.parseURL(e);if(!o){throw new Error("Error trying to parse base URL.")}if(!o.netLoc&&o.path&&o.path[0]!=="/"){var l=i.exec(o.path);o.netLoc=l[1];o.path=l[2]}if(o.netLoc&&!o.path){o.path="/"}var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc){u.netLoc=o.netLoc;if(n.path[0]!=="/"){if(!n.path){u.path=o.path;if(!n.params){u.params=o.params;if(!n.query){u.query=o.query}}}else{var f=o.path;var c=f.substring(0,f.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(c)}}}if(u.path===null){u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path}return s.buildURLFromParts(u)},parseURL:function(e){var t=r.exec(e);if(!t){return null}return{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}},normalizePath:function(e){e=e.split("").reverse().join("").replace(a,"");while(e.length!==(e=e.replace(n,"")).length){}return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=s})()},"./node_modules/webworkify-webpack/index.js": /*!**************************************************!*\ !*** ./node_modules/webworkify-webpack/index.js ***! \**************************************************/ /*! no static exports found */function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:false,exports:{}};e[i].call(a.exports,a,a.exports,r);a.l=true;return a.exports}r.m=e;r.c=t;r.i=function(e){return e};r.d=function(e,t,i){if(!r.o(e,t)){Object.defineProperty(e,t,{configurable:false,enumerable:true,get:i})}};r.r=function(e){Object.defineProperty(e,"__esModule",{value:true})};r.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};r.d(t,"a",t);return t};r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};r.p="/";r.oe=function(e){console.error(e);throw e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var a="[\\.|\\-|\\+|\\w|/|@]+";var n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+a+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e){return!isNaN(1*e)}function l(e,t,i){var l={};l[i]=[];var u=t.toString();var f=u.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!f)return l;var c=f[1];var d=new RegExp("(\\\\n|\\W)"+s(c)+n,"g");var h;while(h=d.exec(u)){if(h[3]==="dll-reference")continue;l[i].push(h[3])}d=new RegExp("\\("+s(c)+'\\("(dll-reference\\s('+a+'))"\\)\\)'+n,"g");while(h=d.exec(u)){if(!e[h[2]]){l[i].push(h[1]);e[h[2]]=r(h[1]).m}l[h[2]]=l[h[2]]||[];l[h[2]].push(h[4])}var v=Object.keys(l);for(var g=0;g<v.length;g++){for(var p=0;p<l[v[g]].length;p++){if(o(l[v[g]][p])){l[v[g]][p]=1*l[v[g]][p]}}}return l}function u(e){var t=Object.keys(e);return t.reduce((function(t,r){return t||e[r].length>0}),false)}function f(e,t){var r={main:[t]};var i={main:[]};var a={main:{}};while(u(r)){var n=Object.keys(r);for(var s=0;s<n.length;s++){var o=n[s];var f=r[o];var c=f.pop();a[o]=a[o]||{};if(a[o][c]||!e[o][c])continue;a[o][c]=true;i[o]=i[o]||[];i[o].push(c);var d=l(e,e[o][c],o);var h=Object.keys(d);for(var v=0;v<h.length;v++){r[h[v]]=r[h[v]]||[];r[h[v]]=r[h[v]].concat(d[h[v]])}}}return i}e.exports=function(e,t){t=t||{};var a={main:r.m};var n=t.all?{main:Object.keys(a.main)}:f(a,e);var s="";Object.keys(n).filter((function(e){return e!=="main"})).forEach((function(e){var t=0;while(n[e][t]){t++}n[e].push(t);a[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })";s=s+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map((function(t){return""+JSON.stringify(t)+": "+a[e][t].toString()})).join(",")+"});\n"}));s=s+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map((function(e){return""+JSON.stringify(e)+": "+a.main[e].toString()})).join(",")+"}))(self);";var o=new window.Blob([s],{type:"text/javascript"});if(t.bare){return o}var l=window.URL||window.webkitURL||window.mozURL||window.msURL;var u=l.createObjectURL(o);var c=new window.Worker(u);c.objectURL=u;return c}},"./src/config.ts": /*!***********************!*\ !*** ./src/config.ts ***! \***********************/ /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(e,t,r){r.r(t);r.d(t,"hlsDefaultConfig",(function(){return A}));r.d(t,"mergeConfig",(function(){return D}));r.d(t,"enableStreamingMode",(function(){return k}));var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts");var a=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts");var n=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts");var s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts");var o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts");var l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts");var u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts");var f=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts");var c=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts");var d=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts");var h=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts");var v=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts");var g=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts");var p=r(/*! ./utils/cues */"./src/utils/cues.ts");var m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");var y=r(/*! ./utils/logger */"./src/utils/logger.ts");function E(){E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(Object.prototype.hasOwnProperty.call(r,i)){e[i]=r[i]}}}return e};return E.apply(this,arguments)}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);if(t){i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}r.push.apply(r,i)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};if(t%2){T(Object(r),true).forEach((function(t){S(e,t,r[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{T(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}}return e}function S(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}var A=b(b({autoStartLoad:true,startPosition:-1,defaultAudioCodec:undefined,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:undefined,liveMaxLatencyDuration:undefined,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,enableSoftwareAES:true,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:undefined,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:v["default"],fLoader:undefined,pLoader:undefined,xhrSetup:undefined,licenseXhrSetup:undefined,licenseResponseCallback:undefined,abrController:i["default"],bufferController:l["default"],capLevelController:f["default"],fpsController:c["default"],stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:undefined,drmSystemOptions:{},requestMediaKeySystemAccessFunc:m["requestMediaKeySystemAccess"],testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:undefined},L()),{},{subtitleStreamController:s["SubtitleStreamController"],subtitleTrackController:o["default"],timelineController:u["TimelineController"],audioStreamController:a["default"],audioTrackController:n["default"],emeController:d["default"],cmcdController:h["default"]});function L(){return{cueHandler:p["default"],enableCEA708Captions:true,enableWebVTT:true,enableIMSC1:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function D(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration)){throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration")}if(t.liveMaxLatencyDurationCount!==undefined&&(t.liveSyncDurationCount===undefined||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount)){throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"')}if(t.liveMaxLatencyDuration!==undefined&&(t.liveSyncDuration===undefined||t.liveMaxLatencyDuration<=t.liveSyncDuration)){throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"')}return E({},e,t)}function k(e){var t=e.loader;if(t!==g["default"]&&t!==v["default"]){y["logger"].log("[config]: Custom loader detected, cannot enable progressive streaming");e.progressive=false}else{var r=Object(g["fetchSupported"])();if(r){e.loader=g["default"];e.progressive=true;e.enableSoftwareAES=true;y["logger"].log("[config]: Progressive streaming enabled, using FetchLoader")}}}},"./src/controller/abr-controller.ts": /*!******************************************!*\ !*** ./src/controller/abr-controller.ts ***! \******************************************/ /*! exports provided: default */function(e,t,r){r.r(t);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var a=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var o=r(/*! ../errors */"./src/errors.ts");var l=r(/*! ../types/loader */"./src/types/loader.ts");var u=r(/*! ../utils/logger */"./src/utils/logger.ts");function f(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||false;i.configurable=true;if("value"in i)i.writable=true;Object.defineProperty(e,i.key,i)}}function c(e,t,r){if(t)f(e.prototype,t);if(r)f(e,r);return e}var d=function(){function e(e){this.hls=void 0;this.lastLoadedFragLevel=0;this._nextAutoLevel=-1;this.timer=void 0;this.onCheck=this._abandonRulesCheck.bind(this);this.fragCurrent=null;this.partCurrent=null;this.bitrateTestDelay=0;this.bwEstimator=void 0;this.hls=e;var t=e.config;this.bwEstimator=new a["default"](t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate);this.registerListeners()}var t=e.prototype;t.registerListeners=function e(){var t=this.hls;t.on(n["Events"].FRAG_LOADING,this.onFragLoading,this);t.on(n["Events"].FRAG_LOADED,this.onFragLoaded,this);t.on(n["Events"].FRAG_BUFFERED,this.onFragBuffered,this);t.on(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.on(n["Events"].ERROR,this.onError,this)};t.unregisterListeners=function e(){var t=this.hls;t.off(n["Events"].FRAG_LOADING,this.onFragLoading,this);t.off(n["Events"].FRAG_LOADED,this.onFragLoaded,this);t.off(n["Events"].FRAG_BUFFERED,this.onFragBuffered,this);t.off(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.off(n["Events"].ERROR,this.onError,this)};t.destroy=function e(){this.unregisterListeners();this.clearTimer();this.hls=this.onCheck=null;this.fragCurrent=this.partCurrent=null};t.onFragLoading=function e(t,r){var i=r.frag;if(i.type===l["PlaylistLevelType"].MAIN){if(!this.timer){var a;this.fragCurrent=i;this.partCurrent=(a=r.part)!=null?a:null;this.timer=self.setInterval(this.onCheck,100)}}};t.onLevelLoaded=function e(t,r){var i=this.hls.config;if(r.details.live){this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive)}else{this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}};t._abandonRulesCheck=function e(){var t=this.fragCurrent,r=this.partCurrent,a=this.hls;var o=a.autoLevelEnabled,l=a.config,f=a.media;if(!t||!f){return}var c=r?r.stats:t.stats;var d=r?r.duration:t.duration;if(c.aborted){u["logger"].warn("frag loader destroy or aborted, disarm abandonRules");this.clearTimer();this._nextAutoLevel=-1;return}if(!o||f.paused||!f.playbackRate||!f.readyState){return}var h=performance.now()-c.loading.start;var v=Math.abs(f.playbackRate);if(h<=500*d/v){return}var g=a.levels,p=a.minAutoLevel;var m=g[t.level];var y=c.total||Math.max(c.loaded,Math.round(d*m.maxBitrate/8));var E=Math.max(1,c.bwEstimate?c.bwEstimate/8:c.loaded*1e3/h);var T=(y-c.loaded)/E;var b=f.currentTime;var S=(s["BufferHelper"].bufferInfo(f,b,l.maxBufferHole).end-b)/v;if(S>=2*d/v||T<=S){return}var A=Number.POSITIVE_INFINITY;var L;for(L=t.level-1;L>p;L--){var D=g[L].maxBitrate;A=d*D/(8*.8*E);if(A<S){break}}if(A>=T){return}var k=this.bwEstimator.getEstimate();u["logger"].warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+L+"\n Current BW estimate: "+(Object(i["isFiniteNumber"])(k)?(k/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+T.toFixed(3)+" s\n Estimated load time for the next fragment: "+A.toFixed(3)+" s\n Time to underbuffer: "+S.toFixed(3)+" s");a.nextLoadLevel=L;this.bwEstimator.sample(h,c.loaded);this.clearTimer();if(t.loader){this.fragCurrent=this.partCurrent=null;t.loader.abort()}a.trigger(n["Events"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:c})};t.onFragLoaded=function e(t,r){var a=r.frag,s=r.part;if(a.type===l["PlaylistLevelType"].MAIN&&Object(i["isFiniteNumber"])(a.sn)){var o=s?s.stats:a.stats;var u=s?s.duration:a.duration;this.clearTimer();this.lastLoadedFragLevel=a.level;this._nextAutoLevel=-1;if(this.hls.config.abrMaxWithRealBitrate){var f=this.hls.levels[a.level];var c=(f.loaded?f.loaded.bytes:0)+o.loaded;var d=(f.loaded?f.loaded.duration:0)+u;f.loaded={bytes:c,duration:d};f.realBitrate=Math.round(8*c/d)}if(a.bitrateTest){var h={stats:o,frag:a,part:s,id:a.type};this.onFragBuffered(n["Events"].FRAG_BUFFERED,h);a.bitrateTest=false}}};t.onFragBuffered=function e(t,r){var i=r.frag,a=r.part;var n=a?a.stats:i.stats;if(n.aborted){return}if(i.type!==l["PlaylistLevelType"].MAIN||i.sn==="initSegment"){return}var s=n.parsing.end-n.loading.start;this.bwEstimator.sample(s,n.loaded);n.bwEstimate=this.bwEstimator.getEstimate();if(i.bitrateTest){this.bitrateTestDelay=s/1e3}else{this.bitrateTestDelay=0}};t.onError=function e(t,r){switch(r.details){case o["ErrorDetails"].FRAG_LOAD_ERROR:case o["ErrorDetails"].FRAG_LOAD_TIMEOUT:this.clearTimer();break}};t.clearTimer=function e(){self.clearInterval(this.timer);this.timer=undefined};t.getNextABRAutoLevel=function e(){var t=this.fragCurrent,r=this.partCurrent,i=this.hls;var a=i.maxAutoLevel,n=i.config,o=i.minAutoLevel,l=i.media;var f=r?r.duration:t?t.duration:0;var c=l?l.currentTime:0;var d=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1;var h=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate;var v=(s["BufferHelper"].bufferInfo(l,c,n.maxBufferHole).end-c)/d;var g=this.findBestLevel(h,o,a,v,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(g>=0){return g}u["logger"].trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=f?Math.min(f,n.maxStarvationDelay):n.maxStarvationDelay;var m=n.abrBandWidthFactor;var y=n.abrBandWidthUpFactor;if(!v){var E=this.bitrateTestDelay;if(E){var T=f?Math.min(f,n.maxLoadingDelay):n.maxLoadingDelay;p=T-E;u["logger"].trace("bitrate test took "+Math.round(1e3*E)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms");m=y=1}}g=this.findBestLevel(h,o,a,v+p,m,y);return Math.max(g,0)};t.findBestLevel=function e(t,r,i,a,n,s){var o;var l=this.fragCurrent,f=this.partCurrent,c=this.lastLoadedFragLevel;var d=this.hls.levels;var h=d[c];var v=!!(h!==null&&h!==void 0&&(o=h.details)!==null&&o!==void 0&&o.live);var g=h===null||h===void 0?void 0:h.codecSet;var p=f?f.duration:l?l.duration:0;for(var m=i;m>=r;m--){var y=d[m];if(!y||g&&y.codecSet!==g){continue}var E=y.details;var T=(f?E===null||E===void 0?void 0:E.partTarget:E===null||E===void 0?void 0:E.averagetargetduration)||p;var b=void 0;if(m<=c){b=n*t}else{b=s*t}var S=d[m].maxBitrate;var A=S*T/b;u["logger"].trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(b)+"/"+S+"/"+T+"/"+a+"/"+A);if(b>S&&(!A||v&&!this.bitrateTestDelay||A<a)){return m}}return-1};c(e,[{key:"nextAutoLevel",get:function e(){var t=this._nextAutoLevel;var r=this.bwEstimator;if(t!==-1&&(!r||!r.canEstimate())){return t}var i=this.getNextABRAutoLevel();if(t!==-1){i=Math.min(t,i)}return i},set:function e(t){this._nextAutoLevel=t}}]);return e}();t["default"]=d},"./src/controller/audio-stream-controller.ts": /*!***************************************************!*\ !*** ./src/controller/audio-stream-controller.ts ***! \***************************************************/ /*! exports provided: default */function(e,t,r){r.r(t);var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var a=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var l=r(/*! ../types/level */"./src/types/level.ts");var u=r(/*! ../types/loader */"./src/types/loader.ts");var f=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var c=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");var d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts");var h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var v=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var g=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var p=r(/*! ../errors */"./src/errors.ts");var m=r(/*! ../utils/logger */"./src/utils/logger.ts");function y(){y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(Object.prototype.hasOwnProperty.call(r,i)){e[i]=r[i]}}}return e};return y.apply(this,arguments)}function E(e,t){e.prototype=Object.create(t.prototype);e.prototype.constructor=e;T(e,t)}function T(e,t){T=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return T(e,t)}var b=100;var S=function(e){E(t,e);function t(t,r){var i;i=e.call(this,t,r,"[audio-stream-controller]")||this;i.videoBuffer=null;i.videoTrackCC=-1;i.waitingVideoCC=-1;i.audioSwitch=false;i.trackId=-1;i.waitingData=null;i.mainDetails=null;i.bufferFlushed=false;i._registerListeners();return i}var r=t.prototype;r.onHandlerDestroying=function e(){this._unregisterListeners();this.mainDetails=null};r._registerListeners=function e(){var t=this.hls;t.on(n["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);t.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.on(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.on(n["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);t.on(n["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);t.on(n["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.on(n["Events"].ERROR,this.onError,this);t.on(n["Events"].BUFFER_RESET,this.onBufferReset,this);t.on(n["Events"].BUFFER_CREATED,this.onBufferCreated,this);t.on(n["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);t.on(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.on(n["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function e(){var t=this.hls;t.off(n["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);t.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.off(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.off(n["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);t.off(n["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);t.off(n["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.off(n["Events"].ERROR,this.onError,this);t.off(n["Events"].BUFFER_RESET,this.onBufferReset,this);t.off(n["Events"].BUFFER_CREATED,this.onBufferCreated,this);t.off(n["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);t.off(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.off(n["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onInitPtsFound=function e(t,r){var i=r.frag,n=r.id,s=r.initPTS;if(n==="main"){var o=i.cc;this.initPTS[i.cc]=s;this.log("InitPTS for cc: "+o+" found from main: "+s);this.videoTrackCC=o;if(this.state===a["State"].WAITING_INIT_PTS){this.tick()}}};r.startLoad=function e(t){if(!this.levels){this.startPosition=t;this.state=a["State"].STOPPED;return}var r=this.lastCurrentTime;this.stopLoad();this.setInterval(b);this.fragLoadError=0;if(r>0&&t===-1){this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3));this.state=a["State"].IDLE}else{this.loadedmetadata=false;this.state=a["State"].WAITING_TRACK}this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t;this.tick()};r.doTick=function t(){switch(this.state){case a["State"].IDLE:this.doTickIdle();break;case a["State"].WAITING_TRACK:{var r;var i=this.levels,n=this.trackId;var o=i===null||i===void 0?void 0:(r=i[n])===null||r===void 0?void 0:r.details;if(o){if(this.waitForCdnTuneIn(o)){break}this.state=a["State"].WAITING_INIT_PTS}break}case a["State"].FRAG_LOADING_WAITING_RETRY:{var l;var u=performance.now();var f=this.retryDate;if(!f||u>=f||(l=this.media)!==null&&l!==void 0&&l.seeking){this.log("RetryDate reached, switch back to IDLE state");this.state=a["State"].IDLE}break}case a["State"].WAITING_INIT_PTS:{var c=this.waitingData;if(c){var d=c.frag,h=c.part,g=c.cache,p=c.complete;if(this.initPTS[d.cc]!==undefined){this.waitingData=null;this.waitingVideoCC=-1;this.state=a["State"].FRAG_LOADING;var y=g.flush();var E={frag:d,part:h,payload:y,networkDetails:null};this._handleFragmentLoadProgress(E);if(p){e.prototype._handleFragmentLoadComplete.call(this,E)}}else if(this.videoTrackCC!==this.waitingVideoCC){m["logger"].log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC);this.clearWaitingFragment()}else{var T=this.getLoadPosition();var b=s["BufferHelper"].bufferInfo(this.mediaBuffer,T,this.config.maxBufferHole);var S=Object(v["fragmentWithinToleranceTest"])(b.end,this.config.maxFragLookUpTolerance,d);if(S<0){m["logger"].log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+b.end+" is needed");this.clearWaitingFragment()}}}else{this.state=a["State"].IDLE}}}this.onTickEnd()};r.clearWaitingFragment=function e(){var t=this.waitingData;if(t){this.fragmentTracker.removeFragment(t.frag);this.waitingData=null;this.waitingVideoCC=-1;this.state=a["State"].IDLE}};r.onTickEnd=function e(){var t=this.media;if(!t||!t.readyState){return}var r=this.mediaBuffer?this.mediaBuffer:t;var i=r.buffered;if(!this.loadedmetadata&&i.length){this.loadedmetadata=true}this.lastCurrentTime=t.currentTime};r.doTickIdle=function e(){var t,r;var i=this.hls,s=this.levels,o=this.media,l=this.trackId;var c=i.config;if(!s||!s[l]){return}if(!o&&(this.startFragRequested||!c.startFragPrefetch)){return}var d=s[l];var h=d.details;if(!h||h.live&&this.levelLastLoaded!==l||this.waitForCdnTuneIn(h)){this.state=a["State"].WAITING_TRACK;return}if(this.bufferFlushed){this.bufferFlushed=false;this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,f["ElementaryStreamTypes"].AUDIO,u["PlaylistLevelType"].AUDIO)}var v=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u["PlaylistLevelType"].AUDIO);if(v===null){return}var g=v.len;var p=this.getMaxBufferLength();var m=this.audioSwitch;if(g>=p&&!m){return}if(!m&&this._streamEnded(v,h)){i.trigger(n["Events"].BUFFER_EOS,{type:"audio"});this.state=a["State"].ENDED;return}var y=h.fragments;var E=y[0].start;var T=v.end;if(m){var b=this.getLoadPosition();T=b;if(h.PTSKnown&&b<E){if(v.end>E||v.nextStart){this.log("Alt audio track ahead of main track, seek to start of alt audio track");o.currentTime=E+.05}}}var S=this.getNextFragment(T,h);if(!S){this.bufferFlushed=true;return}if(((t=S.decryptdata)===null||t===void 0?void 0:t.keyFormat)==="identity"&&!((r=S.decryptdata)!==null&&r!==void 0&&r.key)){this.loadKey(S,h)}else{this.loadFragment(S,h,T)}};r.getMaxBufferLength=function t(){var r=e.prototype.getMaxBufferLength.call(this);var i=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u["PlaylistLevelType"].MAIN);if(i===null){return r}return Math.max(r,i.len)};r.onMediaDetaching=function t(){this.videoBuffer=null;e.prototype.onMediaDetaching.call(this)};r.onAudioTracksUpdated=function e(t,r){var i=r.audioTracks;this.resetTransmuxer();this.levels=i.map((function(e){return new l["Level"](e)}))};r.onAudioTrackSwitching=function e(t,r){var i=!!r.url;this.trackId=r.id;var n=this.fragCurrent;if(n!==null&&n!==void 0&&n.loader){n.loader.abort()}this.fragCurrent=null;this.clearWaitingFragment();if(!i){this.resetTransmuxer()}else{this.setInterval(b)}if(i){this.audioSwitch=true;this.state=a["State"].IDLE}else{this.state=a["State"].STOPPED}this.tick()};r.onManifestLoading=function e(){this.mainDetails=null;this.fragmentTracker.removeAllFragments();this.startPosition=this.lastCurrentTime=0;this.bufferFlushed=false};r.onLevelLoaded=function e(t,r){this.mainDetails=r.details};r.onAudioTrackLoaded=function e(t,r){var i;var n=this.levels;var s=r.details,o=r.id;if(!n){this.warn("Audio tracks were reset while loading level "+o);return}this.log("Track "+o+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var l=n[o];var u=0;if(s.live||(i=l.details)!==null&&i!==void 0&&i.live){var f=this.mainDetails;if(!s.fragments[0]){s.deltaUpdateFailed=true}if(s.deltaUpdateFailed||!f){return}if(!l.details&&s.hasProgramDateTime&&f.hasProgramDateTime){Object(g["alignMediaPlaylistByPDT"])(s,f);u=s.fragments[0].start}else{u=this.alignPlaylists(s,l.details)}}l.details=s;this.levelLastLoaded=o;if(!this.startFragRequested&&(this.mainDetails||!s.live)){this.setStartPosition(l.details,u)}if(this.state===a["State"].WAITING_TRACK&&!this.waitForCdnTuneIn(s)){this.state=a["State"].IDLE}this.tick()};r._handleFragmentLoadProgress=function e(t){var r;var i=t.frag,n=t.part,s=t.payload;var o=this.config,l=this.trackId,f=this.levels;if(!f){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered");return}var v=f[l];console.assert(v,"Audio track is defined on fragment load progress");var g=v.details;console.assert(g,"Audio track details are defined on fragment load progress");var p=o.defaultAudioCodec||v.audioCodec||"mp4a.40.2";var y=this.transmuxer;if(!y){y=this.transmuxer=new d["default"](this.hls,u["PlaylistLevelType"].AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))}var E=this.initPTS[i.cc];var T=(r=i.initSegment)===null||r===void 0?void 0:r.data;if(E!==undefined){var b=false;var S=n?n.index:-1;var A=S!==-1;var L=new h["ChunkMetadata"](i.level,i.sn,i.stats.chunkCount,s.byteLength,S,A);y.push(s,T,p,"",i,n,g.totalduration,b,L,E)}else{m["logger"].log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+g.startSN+" ,"+g.endSN+"],track "+l);var D=this.waitingData=this.waitingData||{frag:i,part:n,cache:new c["default"],complete:false},k=D.cache;k.push(new Uint8Array(s));this.waitingVideoCC=this.videoTrackCC;this.state=a["State"].WAITING_INIT_PTS}};r._handleFragmentLoadComplete=function t(r){if(this.waitingData){this.waitingData.complete=true;return}e.prototype._handleFragmentLoadComplete.call(this,r)};r.onBufferReset=function e(){this.mediaBuffer=this.videoBuffer=null;this.loadedmetadata=false};r.onBufferCreated=function e(t,r){var i=r.tracks.audio;if(i){this.mediaBuffer=i.buffer}if(r.tracks.video){this.videoBuffer=r.tracks.video.buffer}};r.onFragBuffered=function e(t,r){var i=r.frag,a=r.part;if(i.type!==u["PlaylistLevelType"].AUDIO){return}if(this.fragContextChanged(i)){this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}if(i.sn!=="initSegment"){this.fragPrevious=i;if(this.audioSwitch){this.audioSwitch=false;this.hls.trigger(n["Events"].AUDIO_TRACK_SWITCHED,{id:this.trackId})}}this.fragBufferedComplete(i,a)};r.onError=function t(r,i){switch(i.details){case p["ErrorDetails"].FRAG_LOAD_ERROR:case p["ErrorDetails"].FRAG_LOAD_TIMEOUT:case p["ErrorDetails"].KEY_LOAD_ERROR:case p["ErrorDetails"].KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u["PlaylistLevelType"].AUDIO,i);break;case p["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR:case p["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:if(this.state!==a["State"].ERROR&&this.state!==a["State"].STOPPED){this.state=i.fatal?a["State"].ERROR:a["State"].IDLE;this.warn(i.details+" while loading frag, switching to "+this.state+" state")}break;case p["ErrorDetails"].BUFFER_FULL_ERROR:if(i.parent==="audio"&&(this.state===a["State"].PARSING||this.state===a["State"].PARSED)){var n=true;var s=this.getFwdBufferInfo(this.mediaBuffer,u["PlaylistLevelType"].AUDIO);if(s&&s.len>.5){n=!this.reduceMaxBufferLength(s.len)}if(n){this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer");this.fragCurrent=null;e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.resetLoadingState()}break}};r.onBufferFlushed=function e(t,r){var i=r.type;if(i===f["ElementaryStreamTypes"].AUDIO){this.bufferFlushed=true}};r._handleTransmuxComplete=function e(t){var r;var i="audio";var s=this.hls;var o=t.remuxResult,l=t.chunkMeta;var u=this.getCurrentContext(l);if(!u){this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered.");this.resetLiveStartWhenNotLoaded(l.level);return}var c=u.frag,d=u.part;var h=o.audio,v=o.text,g=o.id3,p=o.initSegment;if(this.fragContextChanged(c)){return}this.state=a["State"].PARSING;if(this.audioSwitch&&h){this.completeAudioSwitch()}if(p!==null&&p!==void 0&&p.tracks){this._bufferInitSegment(p.tracks,c,l);s.trigger(n["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:c,id:i,tracks:p.tracks})}if(h){var m=h.startPTS,E=h.endPTS,T=h.startDTS,b=h.endDTS;if(d){d.elementaryStreams[f["ElementaryStreamTypes"].AUDIO]={startPTS:m,endPTS:E,startDTS:T,endDTS:b}}c.setElementaryStreamInfo(f["ElementaryStreamTypes"].AUDIO,m,E,T,b);this.bufferFragmentData(h,c,d,l)}if(g!==null&&g!==void 0&&(r=g.samples)!==null&&r!==void 0&&r.length){var S=y({frag:c,id:i},g);s.trigger(n["Events"].FRAG_PARSING_METADATA,S)}if(v){var A=y({frag:c,id:i},v);s.trigger(n["Events"].FRAG_PARSING_USERDATA,A)}};r._bufferInitSegment=function e(t,r,i){if(this.state!==a["State"].PARSING){return}if(t.video){delete t.video}var s=t.audio;if(!s){return}s.levelCodec=s.codec;s.id="audio";this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]");this.hls.trigger(n["Events"].BUFFER_CODECS,t);var o=s.initSegment;if(o!==null&&o!==void 0&&o.byteLength){var l={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:o};this.hls.trigger(n["Events"].BUFFER_APPENDING,l)}this.tick()};r.loadFragment=function t(r,n,s){var l=this.fragmentTracker.getState(r);this.fragCurrent=r;if(this.audioSwitch||l===o["FragmentState"].NOT_LOADED||l===o["FragmentState"].PARTIAL){if(r.sn==="initSegment"){this._loadInitSegment(r)}else if(n.live&&!Object(i["isFiniteNumber"])(this.initPTS[r.cc])){this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId);this.state=a["State"].WAITING_INIT_PTS}else{this.startFragRequested=true;e.prototype.loadFragment.call(this,r,n,s)}}};r.completeAudioSwitch=function t(){var r=this.hls,i=this.media,a=this.trackId;if(i){this.log("Switching audio track : flushing all audio");e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.audioSwitch=false;r.trigger(n["Events"].AUDIO_TRACK_SWITCHED,{id:a})};return t}(a["default"]);t["default"]=S},"./src/controller/audio-track-controller.ts": /*!**************************************************!*\ !*** ./src/controller/audio-track-controller.ts ***! \**************************************************/ /*! exports provided: default */function(e,t,r){r.r(t);var i=r(/*! ../events */"./src/events.ts");var a=r(/*! ../errors */"./src/errors.ts");var n=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||false;i.configurable=true;if("value"in i)i.writable=true;Object.defineProperty(e,i.key,i)}}function l(e,t,r){if(t)o(e.prototype,t);if(r)o(e,r);return e}function u(e,t){e.prototype=Object.create(t.prototype);e.prototype.constructor=e;f(e,t)}function f(e,t){f=Object.setPrototypeOf||function e(t,r){t.__proto__=r;return t};return f(e,t)}var c=function(e){u(t,e);function t(t){var r;r=e.call(this,t,"[audio-track-controller]")||this;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.trackName="";r.selectDefaultTrack=true;r.registerListeners();return r}var r=t.prototype;r.registerListeners=function e(){var t=this.hls;t.on(i["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.on(i["Events"].MANIFEST_PARSED,this.onManifestParsed,this);t.on(i["Events"].LEVEL_LOADING,this.onLevelLoading,this);t.on(i["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);t.on(i["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.on(i["Events"].ERROR,this.onError,this)};r.unregisterListeners=function e(){var t=this.hls;t.off(i["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.off(i["Events"].MANIFEST_PARSED,this.onManifestParsed,this);t.off(i["Events"].LEVEL_LOADING,this.onLevelLoading,this);t.off(i["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);t.off(i["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.off(i["Events"].ERROR,this.onError,this)};r.destroy=function t(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;e.prototype.destroy.call(this)};r.onManifestLoading=function e(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.trackName="";this.selectDefaultTrack=true};r.onManifestParsed=function e(t,r){this.tracks=r.audioTracks||[]};r.onAudioTrackLoaded=function e(t,r){var i=r.id,a=r.details;var n=this.tracksInGroup[i];if(!n){this.warn("Invalid audio track id "+i);return}var s=n.details;n.details=r.details;this.log("audioTrack "+i+" loaded ["+a.startSN+"-"+a.endSN+"]");if(i===this.trackId){this.retryCount=0;this.playlistLoaded(i,r,s)}};r.onLevelLoading=function e(t,r){this.switchLevel(r.level)};r.onLevelSwitching=function e(t,r){this.switchLevel(r.level)};r.switchLevel=function e(t){var r=this.hls.levels[t];if(!(r!==null&&r!==void 0&&r.audioGroupIds)){return}var a=r.audioGroupIds[r.urlId];if(this.groupId!==a){this.groupId=a;var n=this.tracks.filter((function(e){return!a||e.groupId===a}));if(this.selectDefaultTrack&&!n.some((function(e){return e.default}))){this.selectDefaultTrack=false}this.tracksInGroup=n;var s={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+a+'" group-id');this.hls.trigger(i["Events"].AUDIO_TRACKS_UPDATED,s);this.selectInitialTrack()}};r.onError=function t(r,i){e.prototype.onError.call(this,r,i);if(i.fatal||!i.context){return}if(i.context.type===s["PlaylistContextType"].AUDIO_TRACK&&i.context.id===this.trackId&&i.context.groupId===this.groupId){this.retryLoadingOrFail(i)}};r.setAudioTrack=function e(t){var r=this.tracksInGroup;if(t<0||t>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var a=r[this.trackId];this.log("Now switching to audio-track index "+t);var n=r[t];var s=n.id,o=n.groupId,l=o===void 0?"":o,u=n.name,f=n.type,c=n.url;this.trackId=t;this.trackName=u;this.selectDefaultTrack=false;this.hls.trigger(i["Events"].AUDIO_TRACK_SWITCHING,{id:s,groupId:l,name:u,type:f,url:c});if(n.details&&!n.details.live){return}var d=this.switchParams(n.url,a===null||a===void 0?void 0:a.details);this.loadPlaylist(d)};r.selectInitialTrack=function e(){var t=this.tracksInGroup;console.assert(t.length,"Initial audio track should be selected when tracks are known");var r=this.trackName;var n=this.findTrackId(r)||this.findTrackId();if(n!==-1){this.setAudioTrack(n)}else{this.warn("No track found for running audio group-ID: "+this.groupId);this.hls.trigger(i["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR,fatal:true})}};r.findTrackId=function e(t){var r=this.tracksInGroup;for(var i=0;i<r.length;i++){var a=r[i];if(!this.selectDefaultTrack||a.default){if(!t||t===a.name){return a.id}}}return-1};r.loadPlaylist=function e(t){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var a=r.id;var n=r.groupId;var