@tarojs/components
Version:
Taro 组件库。
29 lines • 438 kB
JavaScript
var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,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,n&&(a=s[0]&2?n["return"]:s[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;if(n=0,a)s=[s[0]&2,a.value];switch(s[0]){case 0:case 1:a=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(a=r.trys,a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(s[0]===6&&r.label<a[1]){r.label=a[1];a=s;break}if(a&&r.label<a[2]){r.label=a[2];r.ops.push(s);break}if(a[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{i=a=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,n=e.length;r<i;r++,n++)e[n]=t[r];return e};System.register(["./p-b2d01686.system.js","./p-5f4d0d5b.system.js","./p-663d1bb9.system.js"],(function(e){"use strict";var t,r,i,n,a,s,o,l,u,f;return{setters:[function(e){t=e.r;r=e.h;i=e.H;n=e.g;a=e.c},function(e){s=e.a;o=e.b;l=e.g;u=e.c},function(e){f=e.t}],execute:function(){var d=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 c=function(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))};var h=function(e){return Math.max(-1,Math.min(e,1))};var v="default";var g=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 n=t.length;var a={};for(;i<n;i++){e=t[i];if(e&&e[1]in document){for(i=0;i<e.length;i++){a[t[0][i]]=e[i]}return a}}if(!a[t[0][0]]){v="iOS";for(i=0;i<r.length;i++){a[t[0][i]]=r[i]}}return a}();var p=function(e){return/\.(m3u8)($|\?)/i.test(e)};var m=undefined&&undefined.__awaiter||function(e,t,r,i){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i["throw"](e))}catch(e){a(e)}}function l(e){e.done?r(e.value):n(e.value).then(s,o)}l((i=i.apply(e,t||[])).next())}))};var y=e("taro_video_control",function(){function e(e){var r=this;t(this,e);this.visible=false;this.isDraggingProgressBall=false;this.percentage=0;this.progressDimensions={left:0,width:0};this.calcPercentage=function(e){var t=e-r.progressDimensions.left;t=Math.max(t,0);t=Math.min(t,r.progressDimensions.width);return t/r.progressDimensions.width};this.onDragProgressBallStart=function(){r.isDraggingProgressBall=true;r.hideControlsTimer&&clearTimeout(r.hideControlsTimer)};this.onClickProgress=function(e){e.stopPropagation();var t=r.calcPercentage(e.pageX);r.seekFunc(t*r.duration);r.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 m(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 m(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 m(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.isDraggingProgressBall]}))}))};e.prototype.setCurrentTime=function(e){return m(this,void 0,void 0,(function(){return __generator(this,(function(t){this.currentTimeRef.innerHTML=d(e);return[2]}))}))};e.prototype.render=function(){var e=this;var t=this,n=t.controls,a=t.currentTime,s=t.duration,o=t.isPlaying,l=t.pauseFunc,u=t.playFunc,f=t.showPlayBtn,c=t.showProgress;var h=d(s);var v;if(!f){v=null}else if(o){v=r("div",{class:"taro-video-control-button taro-video-control-button-pause",onClick:l})}else{v=r("div",{class:"taro-video-control-button taro-video-control-button-play",onClick:u})}return r(i,{class:"taro-video-bar taro-video-bar-full"},n&&r("div",{class:"taro-video-controls"},v,c&&r("div",{class:"taro-video-current-time",ref:function(t){return e.currentTimeRef=t}},d(a)),c&&r("div",{class:"taro-video-progress-container",onClick:this.onClickProgress},r("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}},r("div",{class:"taro-video-progress-buffered",style:{width:"100%"}}),r("div",{class:"taro-video-ball",ref:function(t){return e.progressBallRef=t},onTouchStart:this.onDragProgressBallStart,style:{left:(h?this.currentTime/s*100:0)+"%"}},r("div",{class:"taro-video-inner"})))),c&&r("div",{class:"taro-video-duration"},h)),r("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return n(this)},enumerable:false,configurable:true});return e}());var E=s((function(e,t){typeof window!=="undefined"&&function t(r,i){e.exports=i()}(o,(function(){return function(e){var t={};function r(i){if(t[i]){return t[i].exports}var n=t[i]={i:i,l:false,exports:{}};e[i].call(n.exports,n,n.exports,r);n.l=true;return n.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 n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));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,n="~";function a(){}if(Object.create){a.prototype=Object.create(null);if(!(new a).__proto__)n=false}function s(e,t,r){this.fn=e;this.context=t;this.once=r||false}function o(e,t,r,i,a){if(typeof r!=="function"){throw new TypeError("The listener must be a function")}var o=new s(r,i||e,a),l=n?n+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 a;else delete e._events[t]}function u(){this._events=new a;this._eventsCount=0}u.prototype.eventNames=function e(){var t=[],r,a;if(this._eventsCount===0)return t;for(a in r=this._events){if(i.call(r,a))t.push(n?a.slice(1):a)}if(Object.getOwnPropertySymbols){return t.concat(Object.getOwnPropertySymbols(r))}return t};u.prototype.listeners=function e(t){var r=n?n+t:t,i=this._events[r];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,s=i.length,o=new Array(s);a<s;a++){o[a]=i[a].fn}return o};u.prototype.listenerCount=function e(t){var r=n?n+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,a,s,o){var l=n?n+t:t;if(!this._events[l])return false;var u=this._events[l],f=arguments.length,d,c;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,a),true;case 5:return u.fn.call(u.context,r,i,a,s),true;case 6:return u.fn.call(u.context,r,i,a,s,o),true}for(c=1,d=new Array(f-1);c<f;c++){d[c-1]=arguments[c]}u.fn.apply(u.context,d)}else{var h=u.length,v;for(c=0;c<h;c++){if(u[c].once)this.removeListener(t,u[c].fn,undefined,true);switch(f){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,r);break;case 3:u[c].fn.call(u[c].context,r,i);break;case 4:u[c].fn.call(u[c].context,r,i,a);break;default:if(!d)for(v=1,d=new Array(f-1);v<f;v++){d[v-1]=arguments[v]}u[c].fn.apply(u[c].context,d)}}}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,a){var s=n?n+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&&(!a||o.once)&&(!i||o.context===i)){l(this,s)}}else{for(var u=0,f=[],d=o.length;u<d;u++){if(o[u].fn!==r||a&&!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=n?n+t:t;if(this._events[r])l(this,r)}else{this._events=new a;this._eventsCount=0}return this};u.prototype.off=u.prototype.removeListener;u.prototype.addListener=u.prototype.on;u.prefixed=n;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 n=/(?:\/|^)\.(?=\/)/g;var a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var s={buildAbsoluteURL:function(e,t,r){r=r||{};e=e.trim();t=t.trim();if(!t){if(!r.alwaysNormalize){return e}var n=s.parseURL(e);if(!n){throw new Error("Error trying to parse base URL.")}n.path=s.normalizePath(n.path);return s.buildURLFromParts(n)}var a=s.parseURL(t);if(!a){throw new Error("Error trying to parse relative URL.")}if(a.scheme){if(!r.alwaysNormalize){return t}a.path=s.normalizePath(a.path);return s.buildURLFromParts(a)}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:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc){u.netLoc=o.netLoc;if(a.path[0]!=="/"){if(!a.path){u.path=o.path;if(!a.params){u.params=o.params;if(!a.query){u.query=o.query}}}else{var f=o.path;var d=f.substring(0,f.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}}}if(u.path===null){u.path=r.alwaysNormalize?s.normalizePath(a.path):a.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(n,"");while(e.length!==(e=e.replace(a,"")).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 n=t[i]={i:i,l:false,exports:{}};e[i].call(n.exports,n,n.exports,r);n.l=true;return n.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 n="[\\.|\\-|\\+|\\w|/|@]+";var a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";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 d=f[1];var c=new RegExp("(\\\\n|\\W)"+s(d)+a,"g");var h;while(h=c.exec(u)){if(h[3]==="dll-reference")continue;l[i].push(h[3])}c=new RegExp("\\("+s(d)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+a,"g");while(h=c.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 n={main:{}};while(u(r)){var a=Object.keys(r);for(var s=0;s<a.length;s++){var o=a[s];var f=r[o];var d=f.pop();n[o]=n[o]||{};if(n[o][d]||!e[o][d])continue;n[o][d]=true;i[o]=i[o]||[];i[o].push(d);var c=l(e,e[o][d],o);var h=Object.keys(c);for(var v=0;v<h.length;v++){r[h[v]]=r[h[v]]||[];r[h[v]]=r[h[v]].concat(c[h[v]])}}}return i}e.exports=function(e,t){t=t||{};var n={main:r.m};var a=t.all?{main:Object.keys(n.main)}:f(n,e);var s="";Object.keys(a).filter((function(e){return e!=="main"})).forEach((function(e){var t=0;while(a[e][t]){t++}a[e].push(t);n[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })";s=s+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+a[e].map((function(t){return""+JSON.stringify(t)+": "+n[e][t].toString()})).join(",")+"});\n"}));s=s+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+a.main.map((function(e){return""+JSON.stringify(e)+": "+n.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 d=new window.Worker(u);d.objectURL=u;return d}},"./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 n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts");var a=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 d=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts");var c=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:d["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:n["default"],audioTrackController:a["default"],emeController:c["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 n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts");var a=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 d(e,t,r){if(t)f(e.prototype,t);if(r)f(e,r);return e}var c=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 n["default"](t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate);this.registerListeners()}var t=e.prototype;t.registerListeners=function e(){var t=this.hls;t.on(a["Events"].FRAG_LOADING,this.onFragLoading,this);t.on(a["Events"].FRAG_LOADED,this.onFragLoaded,this);t.on(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this);t.on(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.on(a["Events"].ERROR,this.onError,this)};t.unregisterListeners=function e(){var t=this.hls;t.off(a["Events"].FRAG_LOADING,this.onFragLoading,this);t.off(a["Events"].FRAG_LOADED,this.onFragLoaded,this);t.off(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this);t.off(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.off(a["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 n;this.fragCurrent=i;this.partCurrent=(n=r.part)!=null?n: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,n=this.hls;var o=n.autoLevelEnabled,l=n.config,f=n.media;if(!t||!f){return}var d=r?r.stats:t.stats;var c=r?r.duration:t.duration;if(d.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()-d.loading.start;var v=Math.abs(f.playbackRate);if(h<=500*c/v){return}var g=n.levels,p=n.minAutoLevel;var m=g[t.level];var y=d.total||Math.max(d.loaded,Math.round(c*m.maxBitrate/8));var E=Math.max(1,d.bwEstimate?d.bwEstimate/8:d.loaded*1e3/h);var T=(y-d.loaded)/E;var b=f.currentTime;var S=(s["BufferHelper"].bufferInfo(f,b,l.maxBufferHole).end-b)/v;if(S>=2*c/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=c*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");n.nextLoadLevel=L;this.bwEstimator.sample(h,d.loaded);this.clearTimer();if(t.loader){this.fragCurrent=this.partCurrent=null;t.loader.abort()}n.trigger(a["Events"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:d})};t.onFragLoaded=function e(t,r){var n=r.frag,s=r.part;if(n.type===l["PlaylistLevelType"].MAIN&&Object(i["isFiniteNumber"])(n.sn)){var o=s?s.stats:n.stats;var u=s?s.duration:n.duration;this.clearTimer();this.lastLoadedFragLevel=n.level;this._nextAutoLevel=-1;if(this.hls.config.abrMaxWithRealBitrate){var f=this.hls.levels[n.level];var d=(f.loaded?f.loaded.bytes:0)+o.loaded;var c=(f.loaded?f.loaded.duration:0)+u;f.loaded={bytes:d,duration:c};f.realBitrate=Math.round(8*d/c)}if(n.bitrateTest){var h={stats:o,frag:n,part:s,id:n.type};this.onFragBuffered(a["Events"].FRAG_BUFFERED,h);n.bitrateTest=false}}};t.onFragBuffered=function e(t,r){var i=r.frag,n=r.part;var a=n?n.stats:i.stats;if(a.aborted){return}if(i.type!==l["PlaylistLevelType"].MAIN||i.sn==="initSegment"){return}var s=a.parsing.end-a.loading.start;this.bwEstimator.sample(s,a.loaded);a.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 n=i.maxAutoLevel,a=i.config,o=i.minAutoLevel,l=i.media;var f=r?r.duration:t?t.duration:0;var d=l?l.currentTime:0;var c=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1;var h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate;var v=(s["BufferHelper"].bufferInfo(l,d,a.maxBufferHole).end-d)/c;var g=this.findBestLevel(h,o,n,v,a.abrBandWidthFactor,a.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,a.maxStarvationDelay):a.maxStarvationDelay;var m=a.abrBandWidthFactor;var y=a.abrBandWidthUpFactor;if(!v){var E=this.bitrateTestDelay;if(E){var T=f?Math.min(f,a.maxLoadingDelay):a.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,n,v+p,m,y);return Math.max(g,0)};t.findBestLevel=function e(t,r,i,n,a,s){var o;var l=this.fragCurrent,f=this.partCurrent,d=this.lastLoadedFragLevel;var c=this.hls.levels;var h=c[d];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=c[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<=d){b=a*t}else{b=s*t}var S=c[m].maxBitrate;var A=S*T/b;u["logger"].trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(b)+"/"+S+"/"+T+"/"+n+"/"+A);if(b>S&&(!A||v&&!this.bitrateTestDelay||A<n)){return m}}return-1};d(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"]=c},"./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 n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var a=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 d=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");var c=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(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);t.on(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.on(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.on(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.on(a["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);t.on(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);t.on(a["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.on(a["Events"].ERROR,this.onError,this);t.on(a["Events"].BUFFER_RESET,this.onBufferReset,this);t.on(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);t.on(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);t.on(a["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.on(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function e(){var t=this.hls;t.off(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);t.off(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.off(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.off(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);t.off(a["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);t.off(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);t.off(a["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);t.off(a["Events"].ERROR,this.onError,this);t.off(a["Events"].BUFFER_RESET,this.onBufferReset,this);t.off(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);t.off(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);t.off(a["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.off(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onInitPtsFound=function e(t,r){var i=r.frag,a=r.id,s=r.initPTS;if(a==="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===n["State"].WAITING_INIT_PTS){this.tick()}}};r.startLoad=function e(t){if(!this.levels){this.startPosition=t;this.state=n["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=n["State"].IDLE}else{this.loadedmetadata=false;this.state=n["State"].WAITING_TRACK}this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t;this.tick()};r.doTick=function t(){switch(this.state){case n["State"].IDLE:this.doTickIdle();break;case n["State"].WAITING_TRACK:{var r;var i=this.levels,a=this.trackId;var o=i===null||i===void 0?void 0:(r=i[a])===null||r===void 0?void 0:r.details;if(o){if(this.waitForCdnTuneIn(o)){break}this.state=n["State"].WAITING_INIT_PTS}break}case n["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=n["State"].IDLE}break}case n["State"].WAITING_INIT_PTS:{var d=this.waitingData;if(d){var c=d.frag,h=d.part,g=d.cache,p=d.complete;if(this.initPTS[c.cc]!==undefined){this.waitingData=null;this.waitingVideoCC=-1;this.state=n["State"].FRAG_LOADING;var y=g.flush();var E={frag:c,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 ("+c.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,c);if(S<0){m["logger"].log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+b.end+" is needed");this.clearWaitingFragment()}}}else{this.state=n["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=n["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 d=i.config;if(!s||!s[l]){return}if(!o&&(this.startFragRequested||!d.startFragPrefetch)){return}var c=s[l];var h=c.details;if(!h||h.live&&this.levelLastLoaded!==l||this.waitForCdnTuneIn(h)){this.state=n["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(a["Events"].BUFFER_EOS,{type:"audio"});this.state=n["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 a=this.fragCurrent;if(a!==null&&a!==void 0&&a.loader){a.loader.abort()}this.fragCurrent=null;this.clearWaitingFragment();if(!i){this.resetTransmuxer()}else{this.setInterval(b)}if(i){this.audioSwitch=true;this.state=n["State"].IDLE}else{this.state=n["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 a=this.levels;var s=r.details,o=r.id;if(!a){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=a[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===n["State"].WAITING_TRACK&&!this.waitForCdnTuneIn(s)){this.state=n["State"].IDLE}this.tick()};r._handleFragmentLoadProgress=function e(t){var r;var i=t.frag,a=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 c["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=a?a.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,a,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:a,cache:new d["default"],complete:false},k=D.cache;k.push(new Uint8Array(s));this.waitingVideoCC=this.videoTrackCC;this.state=n["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,n=r.part;if(i.type!==u["PlaylistLevelType"].AUDIO){return}if(this.fragContextChanged(i)){this.warn("Fragment "+i.sn+(n?" p: "+n.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(a["Events"].AUDIO_TRACK_SWITCHED,{id:this.trackId})}}this.fragBufferedComplete(i,n)};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!==n["State"].ERROR&&this.state!==n["State"].STOPPED){this.state=i.fatal?n["State"].ERROR:n["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===n["State"].PARSING||this.state===n["State"].PARSED)){var a=true;var s=this.getFwdBufferInfo(this.mediaBuffer,u["PlaylistLevelType"].AUDIO);if(s&&s.len>.5){a=!this.reduceMaxBufferLength(s.len)}if(a){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 d=u.frag,c=u.part;var h=o.audio,v=o.text,g=o.id3,p=o.initSegment;if(this.fragContextChanged(d)){return}this.state=n["State"].PARSING;if(this.audioSwitch&&h){this.completeAudioSwitch()}if(p!==null&&p!==void 0&&p.tracks){this._bufferInitSegment(p.tracks,d,l);s.trigger(a["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:d,id:i,tracks:p.tracks})}if(h){var m=h.startPTS,E=h.endPTS,T=h.startDTS,b=h.endDTS;if(c){c.elementaryStreams[f["ElementaryStreamTypes"].AUDIO]={startPTS:m,endPTS:E,startDTS:T,endDTS:b}}d.setElementaryStreamInfo(f["ElementaryStreamTypes"].AUDIO,m,E,T,b);this.bufferFragmentData(h,d,c,l)}if(g!==null&&g!==void 0&&(r=g.samples)!==null&&r!==void 0&&r.length){var S=y({frag:d,id:i},g);s.trigger(a["Events"].FRAG_PARSING_METADATA,S)}if(v){var A=y({frag:d,id:i},v);s.trigger(a["Events"].FRAG_PARSING_USERDATA,A)}};r._bufferInitSegment=function e(t,r,i){if(this.state!==n["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(a["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(a["Events"].BUFFER_APPENDING,l)}this.tick()};r.loadFragment=function t(r,a,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(a.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=n["State"].WAITING_INIT_PTS}else{this.startFragRequested=true;e.prototype.loadFragment.call(this,r,a,s)}}};r.completeAudioSwitch=function t(){var r=this.hls,i=this.media,n=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(a["Events"].AUDIO_TRACK_SWITCHED,{id:n})};return t}(n["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 n=r(/*! ../errors */"./src/errors.ts");var a=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 d=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,n=r.details;var a=this.tracksInGroup[i];if(!a){this.warn("Invalid audio track id "+i);return}var s=a.details;a.details=r.details;this.log("audioTrack "+i+" loaded ["+n.startSN+"-"+n.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 n=r.audioGroupIds[r.urlId];if(this.groupId!==n){this.groupId=n;var a=this.tracks.filter((function(e){return!n||e.groupId===n}));if(this.selectDefaultTrack&&!a.some((function(e){return e.default}))){this.selectDefaultTrack=false}this.tracksInGroup=a;var s={audioTracks:a};this.log("Updating audio tracks, "+a.length+' track(s) found in "'+n+'" 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 n=r[this.trackId];this.log("Now switching to audio-track index "+t);var a=r[t];var s=a.id,o=a.groupId,l=o===void 0?"":o,u=a.name,f=a.type,d=a.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:d});if(a.details&&!a.details.live){return}var c=this.switchParams(a.url,n===null||n===void 0?void 0:n.details);this.loadPlaylist(c)};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 a=this.findTrackId(r)||this.findTrackId();if(a!==-1){this.setAudioTrack(a)}else{this.warn("No track found for running audio group-ID: "+this.groupId);this.hls.trigger(i["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["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 n=r[i];if(!this.selectDefaultTrack||n.default){if(!t||t===n.name){return n.id}}}return-1};r.loadPlaylist=function e(t){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id;var a=r.groupId;var s=r.url;if(t){try{s=t.addDirectives(s)}catch(e){this.warn("Could not construct new