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