@playkit-js/playkit-js-hls 1.32.14 → 1.32.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@playkit-js/playkit-js"),require("hls.js")):"function"==typeof define&&define.amd?define("playkit",["playkit-js","hls.js"],r):"object"==typeof exports?exports.playkit=r(require("@playkit-js/playkit-js"),require("hls.js")):(e.playkit=e.playkit||{},e.playkit.hls=r(e.playkit.core,e.Hls))}(self,(function(e,r){return function(){"use strict";var t={952:function(r){r.exports=e},85:function(e){e.exports=r}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,{a:r}),r},i.d=function(e,r){for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){i.r(a),i.d(a,{NAME:function(){return L},VERSION:function(){return O},default:function(){return C}});var e=i(952);function r(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function t(e,t){if(e){if("string"==typeof e)return r(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(e,t):void 0}}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,i,a,n,s=[],l=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=a.call(t)).done)&&(s.push(o.value),s.length!==r);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=t.return&&(n=t.return(),Object(n)!==n))return}finally{if(c)throw i}}return s}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function l(e){var r=function(e,r){if("object"!==s(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==s(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===s(r)?r:String(r)}function c(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,l(o.key),o)}}function u(e,r,t){return r&&c(e.prototype,r),t&&c(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function _(){return _="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var o=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=h(e)););return e}(e,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?e:t):i.value}},_.apply(this,arguments)}function f(e,r){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},f(e,r)}function E(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&f(e,r)}function g(e,r){if(r&&("object"===s(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function v(e,r,t){return(r=l(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var y,p=i(85),T=i.n(p),R=JSON.parse('{"recoverDecodingErrorDelay":3000,"recoverSwapAudioCodecDelay":3000,"abr":{"enabled":true,"restrictions":{}},"hlsConfig":{"fragLoadingMaxRetry":4,"maxMaxBufferLength":60},"network":{}}'),m=(v(v(v(v(v(v(v(v(v(v(y={},T().ErrorDetails.MANIFEST_LOAD_ERROR,{category:e.Error.Category.MANIFEST,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.MANIFEST_LOAD_TIMEOUT,{category:e.Error.Category.MANIFEST,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.MANIFEST_PARSING_ERROR,{category:e.Error.Category.MANIFEST,code:e.Error.Code.HLSJS_CANNOT_PARSE}),T().ErrorDetails.LEVEL_LOAD_ERROR,{category:e.Error.Category.NETWORK,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.LEVEL_LOAD_TIMEOUT,{category:e.Error.Category.NETWORK,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.LEVEL_SWITCH_ERROR,{category:e.Error.Category.PLAYER,code:e.Error.Code.BITRATE_SWITCH_ISSUE}),T().ErrorDetails.FRAG_LOAD_ERROR,{category:e.Error.Category.NETWORK,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.FRAG_LOAD_TIMEOUT,{category:e.Error.Category.NETWORK,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.FRAG_PARSING_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_FRAG_PARSING_ERROR}),T().ErrorDetails.BUFFER_APPEND_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_APPEND_ISSUE}),v(v(y,T().ErrorDetails.BUFFER_APPENDING_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_APPENDING_ISSUE}),T().ErrorDetails.BUFFER_STALLED_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_STALLED_ERROR}));var b=function(e){E(i,e);var r,t,o=(r=i,t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,o=h(r);if(t){var i=h(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return g(this,e)});function i(e){var r;return n(this,i),r=o.call(this,e),e&&e.readystatechange&&(r.readystatechange=e.readystatechange),r}return u(i,[{key:"loadInternal",value:function(){var e,r=this,t=this.context;e=this.loader=new XMLHttpRequest;var o=this.stats;o.tfirst=0,o.loaded=0;var i,a=this.xhrSetup;try{if(a)try{i=a(e,t.url,t)}catch(r){e.open("GET",t.url,!0),i=a(e,t.url,t)}e.readyState||e.open("GET",t.url,!0)}catch(e){i=Promise.reject(e)}(i=i||Promise.resolve()).then((function(){t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=r.readystatechange.bind(r),e.onprogress=r.loadprogress.bind(r),e.responseType=t.responseType,r.requestTimeout=window.setTimeout(r.loadtimeout.bind(r),r.config.timeout),e.send()})).catch((function(o){r.callbacks.onError({code:e.status,text:o.message},t,e)}))}}]),i}(T().DefaultConfig.loader);var A,S=function(r){E(a,r);var t,o,i=(t=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=h(t);if(o){var i=h(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return g(this,e)});function a(r){var t;n(this,a);var o=(t=i.call(this,r)).load.bind(d(t)),s=a.redirectExternalStreamsHandler;return t.load=function(r,t,i){var n=r.url;"manifest"===r.type?e.Utils.Http.jsonp(n,s,{timeout:a.redirectExternalStreamsTimeout}).then((function(e){r.url=e,o(r,t,i)})).catch((function(){return o(r,t,i)})):o(r,t,i)},t}return u(a)}(b);function D(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}v(S,"redirectExternalStreamsHandler",(function(e,r){return r}));var k=function(i){E(c,i);var a,s,l=(a=c,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=h(a);if(s){var t=h(this).constructor;e=Reflect.construct(r,arguments,t)}else e=r.apply(this,arguments);return g(this,e)});function c(r,t,o){var i;return n(this,c),v(d(i=l.call(this,r,t,o)),"_hlsjsLib",T()),v(d(i),"_triedReloadWithRedirect",!1),v(d(i),"_playerTracks",[]),v(d(i),"_startTime",0),v(d(i),"_requestFilterError",!1),v(d(i),"_responseFilterError",!1),v(d(i),"_nativeTextTracksMap",{}),v(d(i),"_lastLoadedFragSN",-1),v(d(i),"_sameFragSNLoadedCount",0),v(d(i),"_waitForSubtitleLoad",!0),v(d(i),"_adapterEventsBindings",v(v(v(v(v(v(v(v(v({},T().Events.ERROR,(function(e,r){return i._onError(r)})),T().Events.MANIFEST_LOADED,(function(e,r){return i._onManifestLoaded(r)})),T().Events.LEVEL_SWITCHED,(function(e,r){return i._onLevelSwitched(e,r)})),T().Events.AUDIO_TRACK_SWITCHED,(function(e,r){return i._onAudioTrackSwitched(e,r)})),T().Events.FPS_DROP,(function(e,r){return i._onFpsDrop(r)})),T().Events.FRAG_PARSING_METADATA,(function(e,r){return i._onFragParsingMetadata(r)})),T().Events.FRAG_LOADED,(function(e,r){return i._onFragLoaded(r)})),T().Events.MEDIA_ATTACHED,(function(){return i._onMediaAttached()})),T().Events.LEVEL_LOADED,(function(e,r){return i._onLevelLoaded(e,r)}))),v(d(i),"_onLevelLoaded",(function(r,t){if(i.isLive()){var o=t.details.endSN;if(i._lastLoadedFragSN===o){if(i._sameFragSNLoadedCount++,c._logger.debug("Same frag SN. Count is: ".concat(i._sameFragSNLoadedCount,", Max is: ").concat(i._config.network.maxStaleLevelReloads)),i._sameFragSNLoadedCount>=i._config.network.maxStaleLevelReloads){c._logger.error("Same frag loading reached max count");var a=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.NETWORK,e.Error.Code.LIVE_MANIFEST_REFRESH_ERROR,{fragSN:o});return i._trigger(e.EventType.ERROR,a),i.destroy()}c._logger.debug("Last frag SN is: ".concat(o))}else i._sameFragSNLoadedCount=0;i._lastLoadedFragSN=o}})),c._logger.debug("Creating adapter. Hls version: "+T().version),i._config=e.Utils.Object.mergeDeep({},R,i._config),i._init(),i}return u(c,[{key:"_init",value:function(){this._config.forceRedirectExternalStreams&&(this._config.hlsConfig.pLoader=S),this._maybeSetFilters(),this._hls=new(T())(this._config.hlsConfig),this._capabilities.fpsControl=!0,this._hls.subtitleDisplay=this._config.subtitleDisplay,this._addBindings()}},{key:"_maybeSetFilters",value:function(){var o=this;if("function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.requestFilter")&&(c._logger.debug("Register request filter"),e.Utils.Object.mergeDeep(this._config.hlsConfig,{loader:b,xhrSetup:function(i,a,n){var s,l={url:a,body:null,headers:{}};try{"manifest"===n.type&&(s=o._config.network.requestFilter(e.RequestType.MANIFEST,l)),n.frag&&"subtitle"!==n.frag.type&&(s=o._config.network.requestFilter(e.RequestType.SEGMENT,l))}catch(e){s=Promise.reject(e)}return(s=s||Promise.resolve(l)).then((function(e){n.url=e.url,i.open("GET",e.url,!0),Object.entries(e.headers).forEach((function(e){var o;i.setRequestHeader.apply(i,function(e){if(Array.isArray(e))return r(e)}(o=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||t(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})),"boolean"==typeof e.withCredentials&&(i.withCredentials=e.withCredentials)})).catch((function(e){throw o._requestFilterError=!0,e}))}})),"function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.responseFilter")){var i=this;c._logger.debug("Register response filter"),e.Utils.Object.mergeDeep(this._config.hlsConfig,{loader:b,readystatechange:function(r){var t=this,o=r.currentTarget,a=o.readyState,n=this.stats,s=this.context,l=this.config;if(!n.aborted&&a>=2){window.clearTimeout(this.requestTimeout);var u=n.loading;if(0===u.first&&(u.first=Math.max(performance.now(),u.start)),4===a){var d=o.status;if(d>=200&&d<300){var h,_;u.end=Math.max(n.tfirst,performance.now()),_="arraybuffer"===s.responseType?(h=o.response).byteLength:(h=o.responseText).length,n.loaded=n.total=_;var f,E={url:o.responseURL,originalUrl:s.url,data:h,headers:e.Utils.Http.convertHeadersToDictionary(o.getAllResponseHeaders())};try{"manifest"===s.type&&(f=i._config.network.responseFilter(e.RequestType.MANIFEST,E)),s.frag&&"subtitle"!==s.frag.type&&(f=i._config.network.responseFilter(e.RequestType.SEGMENT,E))}catch(e){f=Promise.reject(e)}return(f=f||Promise.resolve(E)).then((function(e){t.callbacks.onSuccess(e,n,s,o)})).catch((function(e){i._responseFilterError=!0,t.callbacks.onError({code:d,text:e.message},s,o)}))}n.retry>=l.maxRetry||d>=400&&d<499?(c._logger.error("".concat(d," while loading ").concat(s.url)),this.callbacks.onError({code:d,text:o.statusText},s,o)):(c._logger.warn("".concat(d," while loading ").concat(s.url,", retrying in ").concat(this.retryDelay,"...")),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,l.maxRetryDelay),n.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),l.timeout)}}})}}},{key:"_addBindings",value:function(){var e=this;this._mediaAttachedPromise=new Promise((function(r){return e._onMediaAttached=r}));for(var r=0,t=Object.entries(this._adapterEventsBindings);r<t.length;r++){var i=o(t[r],2),a=i[0],n=i[1];this._hls.on(a,n)}this._onRecoveredCallback=function(){return e._onRecovered()},this._onAddTrack=this._onAddTrack.bind(this),this._eventManager.listen(this._videoElement,"addtrack",this._onAddTrack),this._videoElement.textTracks.onaddtrack=this._onAddTrack}},{key:"_onFpsDrop",value:function(r){this._trigger(e.EventType.FPS_DROP,r)}},{key:"_onFragParsingMetadata",value:function(r){var t;this._trigger("hlsFragParsingMetadata",r);var o=Array.from(null===(t=this._videoElement)||void 0===t?void 0:t.textTracks).find((function(e){return"id3"===e.label})),i=Array.from((null==o?void 0:o.cues)||[]),a=[];null==r||r.samples.forEach((function(r){var t=e.Utils.binarySearch(i,(function(e){return e.startTime-r.pts}));if(t){var o=(0,e.createTimedMetadata)(t);a.push(o)}})),a.length&&this._trigger(e.EventType.TIMED_METADATA_ADDED,{cues:a})}},{key:"_onAddTrack",value:function(r){if(!this._hls.subtitleTracks.length){var t=this._parseCEATextTrack(r.track);t&&(c._logger.debug("A CEA 608/708 caption has been found",t),this._playerTracks.push(t),this._trigger(e.EventType.TRACKS_CHANGED,{tracks:this._playerTracks}))}}},{key:"attachMediaSource",value:function(){this._hls||(this._videoElement&&this._videoElement.src&&(e.Utils.Dom.setAttribute(this._videoElement,"src",""),e.Utils.Dom.removeAttribute(this._videoElement,"src")),this._init())}},{key:"detachMediaSource",value:function(){var r;this._hls&&(0===Math.floor(this.duration-this.currentTime)?this._config.hlsConfig.startPosition=0:this.currentTime>0&&(this._config.hlsConfig.startPosition=this.currentTime),this._reset(),null===(r=this._loadPromiseHandlers)||void 0===r||r.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"media detached while loading")),this._loadPromiseHandlers=null,this._loadPromise=void 0,this._hls=null)}},{key:"handleMediaError",value:function(e){return e.code===e.MEDIA_ERR_DECODE&&(c._logger.debug("The video playback was aborted due to a corruption problem or because the video used features your browser did not support.",e.message),this._handleMediaError(T().ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR))}},{key:"load",value:function(e){var r=this;return this._loadPromise||(this._startTime=e,this._loadPromise=new Promise((function(e,t){r._loadPromiseHandlers={resolve:e,reject:t},r._loadInternal()}))),this._loadPromise}},{key:"_loadInternal",value:function(){var r;this._hls&&this._sourceObj&&this._sourceObj.url?(this._hls.loadSource(this._sourceObj.url),this._hls.attachMedia(this._videoElement),this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:this.isAdaptiveBitrateEnabled()?"auto":"manual"})):null===(r=this._loadPromiseHandlers)||void 0===r||r.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"no url provided"))}},{key:"_reloadWithDirectManifest",value:function(){this._triedReloadWithRedirect=!0,this._reset(),this._config.hlsConfig.pLoader=S,this._hls=new(T())(this._config.hlsConfig),this._addBindings(),this._loadInternal()}},{key:"destroy",value:function(){var r=this;return new Promise((function(t,o){_(h(c.prototype),"destroy",r).call(r).then((function(){var o;c._logger.debug("destroy"),r._playerTracks=[],r._nativeTextTracksMap={},r._sameFragSNLoadedCount=0,r._lastLoadedFragSN=-1,null===(o=r._loadPromiseHandlers)||void 0===o||o.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"The adapter has been destroyed while loading")),r._loadPromiseHandlers=null,r._loadPromise=void 0,r._reset(),t()}),(function(){return o()}))}))}},{key:"_reset",value:function(){this._removeBindings(),this._requestFilterError=!1,this._responseFilterError=!1,this._hls.detachMedia(),this._hls.destroy()}},{key:"_parseTracks",value:function(){var e=this._parseAudioTracks(this._hls.audioTracks||[]),r=this._parseVideoTracks(this._hls.levels||[]),t=this._parseTextTracks(this._hls.subtitleTracks||[]);return e.concat(r).concat(t)}},{key:"_parseAudioTracks",value:function(r){for(var t=[],o=0;o<r.length;o++){var i={id:r[o].id,active:this._hls.audioTrack===r[o].id,label:r[o].name,language:r[o].lang,index:o};t.push(new e.AudioTrack(i))}return t}},{key:"_parseVideoTracks",value:function(r){for(var t=[],o=0;o<r.length;o++){var i={active:this._hls.startLevel===o,bandwidth:r[o].bitrate,width:r[o].width,height:r[o].height,language:"",index:o};t.push(new e.VideoTrack(i))}return t}},{key:"_parseTextTracks",value:function(r){var t,o=[],i=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return D(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?D(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,n=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return n=e.done,e},e:function(e){s=!0,a=e},f:function(){try{n||null==t.return||t.return()}finally{if(s)throw a}}}}(r);try{for(i.s();!(t=i.n()).done;){var a=t.value,n={id:a.id,active:!1,default:a.default,label:a.name,kind:a.type.toLowerCase(),language:a.lang};o.push(new e.TextTrack(n))}}catch(e){i.e(e)}finally{i.f()}return o}},{key:"_parseCEATextTrack",value:function(r){var t=null;if("captions"===r.kind){var o={id:r.id,active:"showing"===r.mode,label:r.label,kind:r.kind,language:r.language};t=new e.TextTrack(o),this._nativeTextTracksMap[t.index]=r}return t}},{key:"selectAudioTrack",value:function(r){r instanceof e.AudioTrack&&!r.active&&this._hls.audioTracks&&(this._hls.audioTrack=r.id)}},{key:"selectVideoTrack",value:function(r){r instanceof e.VideoTrack&&(!r.active||this.isAdaptiveBitrateEnabled())&&this._hls.levels&&(this.isAdaptiveBitrateEnabled()&&this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._hls.currentLevel=r.index)}},{key:"selectTextTrack",value:function(r){r instanceof e.TextTrack&&!r.active&&this._hls&&(this._hls.subtitleTracks.length?(this._hls.subtitleTrack=r.id,this._notifyTrackChanged(r)):this._selectNativeTextTrack(r))}},{key:"_selectNativeTextTrack",value:function(e){var r=this._nativeTextTracksMap[e.index];r&&(this.disableNativeTextTracks(),r.mode=this._config.subtitleDisplay?"showing":"hidden",this._notifyTrackChanged(e))}},{key:"_notifyTrackChanged",value:function(e){this._onTrackChanged(e)}},{key:"_onSubtitleFragProcessed",value:function(){this._hls.subtitleTrack=-1,this._waitForSubtitleLoad=!1,this._hls.off(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this)}},{key:"hideTextTrack",value:function(){this._hls&&(this._hls.subtitleTracks.length?this._waitForSubtitleLoad&&this._hls.subtitleTracks.length>1?this._hls.on(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this):this._hls.subtitleTrack=-1:this.disableNativeTextTracks())}},{key:"enableAdaptiveBitrate",value:function(){this.isAdaptiveBitrateEnabled()||(this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"auto"}),this._hls.nextLevel=-1)}},{key:"isAdaptiveBitrateEnabled",value:function(){return!!this._hls&&this._hls.autoLevelEnabled}},{key:"applyABRRestriction",value:function(r){e.Utils.Object.createPropertyPath(this._config,"abr.restrictions",r),this._hls.capLevelToPlayerSize||this._maybeApplyAbrRestrictions(r)}},{key:"_getLevelDetails",value:function(){var e=this._hls.levels[this._hls.currentLevel]||this._hls.levels[this._hls.nextLevel]||this._hls.levels[this._hls.nextAutoLevel]||this._hls.levels[this._hls.nextLoadLevel];return e&&e.details?e.details:{}}},{key:"_getLiveEdge",value:function(){try{var e;return(e=this._hls.liveSyncPosition?this._hls.liveSyncPosition:this._hls.config.liveSyncDuration?this._videoElement.duration-this._hls.config.liveSyncDuration:this._videoElement.duration-this._hls.config.liveSyncDurationCount*this._getLevelDetails().targetduration)>0?e:this._videoElement.duration}catch(e){return c._logger.debug("Live edge calculation failed, fall back to duration"),this._videoElement.duration}}},{key:"seekToLiveEdge",value:function(){try{this._videoElement.currentTime=this._getLiveEdge()}catch(e){return}}},{key:"getSegmentDuration",value:function(){var r=e.Utils.Object.getPropertyPath(this._hls,"streamController.fragCurrent");return r?r.duration:0}},{key:"liveDuration",get:function(){return this._getLiveEdge()+this.getSegmentDuration()}},{key:"isLive",value:function(){try{return!!this._getLevelDetails().live}catch(e){return!1}}},{key:"_onManifestLoaded",value:function(r){var t=this;c._logger.debug("The source has been loaded successfully"),this._hls.config.autoStartLoad||this._hls.startLoad(this._startTime),this._playerTracks=this._parseTracks(),this._config.abr.enabled||(this._hls.currentLevel=0),this._mediaAttachedPromise.then((function(){var e;null===(e=t._loadPromiseHandlers)||void 0===e||e.resolve({tracks:t._playerTracks}),t._loadPromiseHandlers=null}));var o=r.stats.loading,i=o.end-o.start;this._trigger(e.EventType.MANIFEST_LOADED,{miliSeconds:i})}},{key:"_maybeApplyAbrRestrictions",value:function(r){var t=this._playerTracks.filter((function(r){return r instanceof e.VideoTrack})),o=(0,e.filterTracksByRestriction)(t,r);if(o.length){var i=o[0],a=o.pop();this._hls.config.minAutoBitrate=i.bandwidth,this._hls.autoLevelCapping=a.index;var n=o.some((function(e){return e.active}));this.isAdaptiveBitrateEnabled()||n||this.selectVideoTrack(i)}else c._logger.warn("Invalid restrictions, there are not tracks within the restriction range")}},{key:"_onLevelSwitched",value:function(r,t){var o=this._playerTracks.find((function(r){return r instanceof e.VideoTrack&&r.index===t.level}));this._onTrackChanged(o)}},{key:"_onAudioTrackSwitched",value:function(r,t){var o=this._playerTracks.find((function(r){return r instanceof e.AudioTrack&&r.id===t.id}));this._onTrackChanged(o),this._handleWaitingUponAudioTrackSwitch()}},{key:"_handleWaitingUponAudioTrackSwitch",value:function(){var r=this;["IE","Edge"].includes(e.Env.browser.name)&&this._eventManager.listenOnce(this._videoElement,e.EventType.TIME_UPDATE,(function(){r._trigger(e.EventType.PLAYING)}))}},{key:"_getErrorDataObject",value:function(e){var r={};switch(r.name=e.details,r.name){case T().ErrorDetails.MANIFEST_LOAD_ERROR:case T().ErrorDetails.LEVEL_LOAD_ERROR:case T().ErrorDetails.AUDIO_TRACK_LOAD_ERROR:r.url=e.url,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.MANIFEST_LOAD_TIMEOUT:case T().ErrorDetails.LEVEL_LOAD_TIMEOUT:case T().ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:r.url=e.url;break;case T().ErrorDetails.MANIFEST_PARSING_ERROR:r.url=e.url,r.reason=e.reason;break;case T().ErrorDetails.LEVEL_SWITCH_ERROR:r.level=e.level,r.reason=e.reason;break;case T().ErrorDetails.FRAG_LOAD_ERROR:r.fragUrl=e.frag?e.frag.url:null,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.FRAG_LOAD_TIMEOUT:r.fragUrl=e.frag?e.frag.url:null;break;case T().ErrorDetails.FRAG_DECRYPT_ERROR:case T().ErrorDetails.FRAG_PARSING_ERROR:r.reason=e.reason;break;case T().ErrorDetails.KEY_LOAD_ERROR:r.fragDecryptedDataUri=e.frag&&e.frag.decryptdata?e.frag.decryptdata.uri:null,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.KEY_LOAD_TIMEOUT:r.fragDecryptedDataUri=e.frag&&e.frag.decryptdata?e.frag.decryptdata.uri:null;break;case T().ErrorDetails.BUFFER_ADD_CODEC_ERROR:r.mimeType=e.mimeType,r.errorMsg=e.err?e.err.message:null;break;case T().ErrorDetails.BUFFER_STALLED_ERROR:r.buffer=e.buffer}return(this._requestFilterError||this._responseFilterError)&&(r.reason=e.response.text),r}},{key:"_onError",value:function(r){var t=r.type,o=r.details,i=r.fatal,a=this._getErrorDataObject(r);if(i){var n,s;switch(t){case T().ErrorTypes.NETWORK_ERROR:var l;l=this._requestFilterError?e.Error.Code.REQUEST_FILTER_ERROR:this._responseFilterError?e.Error.Code.RESPONSE_FILTER_ERROR:e.Error.Code.HTTP_ERROR,![T().ErrorDetails.MANIFEST_LOAD_ERROR,T().ErrorDetails.MANIFEST_LOAD_TIMEOUT].includes(o)||this._triedReloadWithRedirect||this._config.forceRedirectExternalStreams||this._requestFilterError||this._responseFilterError?n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.NETWORK,l,a):(n=new e.Error(e.Error.Severity.RECOVERABLE,e.Error.Category.NETWORK,l,a),this._reloadWithDirectManifest());break;case T().ErrorTypes.MEDIA_ERROR:n=this._handleMediaError(o)?new e.Error(e.Error.Severity.RECOVERABLE,e.Error.Category.MEDIA,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a):new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.MEDIA,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a);break;default:n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a)}if(this._trigger(e.EventType.ERROR,n),n&&n.severity===e.Error.Severity.CRITICAL)this._loadPromiseHandlers&&(null===(s=this._loadPromiseHandlers)||void 0===s||s.reject(n),this._loadPromiseHandlers=null,this._loadPromise=void 0),this.destroy()}else{var u=this._requestFilterError||this._responseFilterError?{category:e.Error.Category.NETWORK,code:this._requestFilterError?e.Error.Code.REQUEST_FILTER_ERROR:e.Error.Code.RESPONSE_FILTER_ERROR}:m[o]||{category:0,code:0},d=u.category,h=u.code;c._logger.warn(new e.Error(e.Error.Severity.RECOVERABLE,d,h,a))}this._requestFilterError=!1,this._responseFilterError=!1}},{key:"_handleMediaError",value:function(r){c._logger.error("_handleMediaError mediaErrorName:",r);var t=performance.now(),o=!0;return r===T().ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?(c._logger.error("recover aborted due to: MANIFEST_INCOMPATIBLE_CODECS_ERROR"),o=!1):this._checkTimeDeltaHasPassed(t,this._recoverDecodingErrorDate,this._config.recoverDecodingErrorDelay)?(this._eventManager.listen(this._videoElement,e.EventType.LOADED_METADATA,this._onRecoveredCallback),c._logger.debug("try to recover using: _recoverDecodingError()"),this._recoverDecodingError()):this._checkTimeDeltaHasPassed(t,this._recoverSwapAudioCodecDate,this._config.recoverSwapAudioCodecDelay)?(this._eventManager.listen(this._videoElement,e.EventType.LOADED_METADATA,this._onRecoveredCallback),c._logger.debug("try to recover using: _recoverSwapAudioCodec()"),this._recoverSwapAudioCodec()):(c._logger.error("cannot recover, last media error recovery failed error: ",r),o=!1),o}},{key:"_onRecovered",value:function(){this._trigger(e.EventType.MEDIA_RECOVERED),this._videoElement.removeEventListener(e.EventType.LOADED_METADATA,this._onRecoveredCallback)}},{key:"_checkTimeDeltaHasPassed",value:function(e,r,t){return!r||e-r>t}},{key:"_recoverDecodingError",value:function(){this._recoverDecodingErrorDate=performance.now(),c._logger.warn("try to recover media Error"),this._hls.recoverMediaError()}},{key:"_recoverSwapAudioCodec",value:function(){this._recoverSwapAudioCodecDate=performance.now(),c._logger.warn("try to swap Audio Codec and recover media Error"),this._hls.swapAudioCodec(),this._hls.recoverMediaError()}},{key:"_removeBindings",value:function(){for(var e=0,r=Object.entries(this._adapterEventsBindings);e<r.length;e++){var t=o(r[e],2),i=t[0],a=t[1];this._hls.off(i,a)}this._hls.off(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this),this._videoElement.textTracks.onaddtrack=null,this._onRecoveredCallback=null,this._eventManager&&this._eventManager.removeAll()}},{key:"getStartTimeOfDvrWindow",value:function(){if(!this.isLive())return 0;try{var e=this._hls.levels[this._hls.nextLoadLevel].details,r=e.fragments,t=r.length,o=r[0].start+r[0].duration,i=r[t-1].start+r[t-1].duration,a=void 0!==this._hls.config.liveMaxLatencyDuration?this._hls.config.liveMaxLatencyDuration:this._hls.config.liveMaxLatencyDurationCount*e.targetduration;return Math.max(o-this._hls.config.maxFragLookUpTolerance,i-a)}catch(e){return c._logger.debug("Unable obtain the start of DVR window"),0}}},{key:"_onFragLoaded",value:function(r){if(e.Utils.Object.hasPropertyPath(r,"frag.stats.loading")){var t=r.frag.stats,o=t.loading.end-t.loading.start;this._trigger(e.EventType.FRAG_LOADED,{miliSeconds:o,bytes:t.loaded,url:r.frag.url})}}},{key:"targetBuffer",get:function(){var e=NaN;return this._hls?(e=this.isLive()?this._getLiveTargetBuffer()-(this._videoElement.currentTime-this._getLiveEdge()):this._videoElement.duration-this._videoElement.currentTime,e=Math.min(e,this._hls.config.maxMaxBufferLength+this._getLevelDetails().targetduration)):NaN}},{key:"_getLiveTargetBuffer",value:function(){return this._hls.config.liveSyncDuration?this._hls.config.liveSyncDuration:this._hls.config.liveSyncDurationCount*this._getLevelDetails().targetduration}}],[{key:"createAdapter",value:function(r,t,o){var i=e.Utils.Object.copyDeep(R);if(e.Utils.Object.hasPropertyPath(o,"sources.options")){var a=o.sources.options;i.forceRedirectExternalStreams=a.forceRedirectExternalStreams,i.redirectExternalStreamsHandler=a.redirectExternalStreamsHandler,i.redirectExternalStreamsTimeout=a.redirectExternalStreamsTimeout,S.redirectExternalStreamsHandler=i.redirectExternalStreamsHandler,S.redirectExternalStreamsTimeout=i.redirectExternalStreamsTimeout}if(e.Utils.Object.hasPropertyPath(o,"sources.startTime")&&e.Utils.Object.getPropertyPath(o,"sources.startTime")>-1&&(i.hlsConfig.startPosition=o.sources.startTime),e.Utils.Object.hasPropertyPath(o,"text.useNativeTextTrack")&&(i.subtitleDisplay=e.Utils.Object.getPropertyPath(o,"text.useNativeTextTrack")),e.Utils.Object.hasPropertyPath(o,"abr.fpsDroppedFramesInterval")&&(i.hlsConfig.fpsDroppedFramesInterval=o.abr.fpsDroppedFramesInterval),e.Utils.Object.hasPropertyPath(o,"abr.fpsDroppedMonitoringThreshold")&&(i.hlsConfig.fpsDroppedMonitoringThreshold=o.abr.fpsDroppedMonitoringThreshold),e.Utils.Object.hasPropertyPath(o,"abr.capLevelOnFPSDrop")&&(c._logger.debug("capLevelOnFPSDrop = ",o.abr.capLevelOnFPSDrop),i.hlsConfig.capLevelOnFPSDrop=o.abr.capLevelOnFPSDrop),e.Utils.Object.hasPropertyPath(o,"text")&&(i.hlsConfig.enableCEA708Captions=o.text.enableCEA708Captions,i.hlsConfig.captionsTextTrack1Label=o.text.captionsTextTrack1Label,i.hlsConfig.captionsTextTrack1LanguageCode=o.text.captionsTextTrack1LanguageCode,i.hlsConfig.captionsTextTrack2Label=o.text.captionsTextTrack2Label,i.hlsConfig.captionsTextTrack2LanguageCode=o.text.captionsTextTrack2LanguageCode),e.Utils.Object.hasPropertyPath(o,"abr")){var n=o.abr;"boolean"==typeof n.enabled&&(i.abr.enabled=n.enabled),"boolean"==typeof n.capLevelToPlayerSize&&(i.hlsConfig.capLevelToPlayerSize=n.capLevelToPlayerSize),n.defaultBandwidthEstimate&&(i.hlsConfig.abrEwmaDefaultEstimate=n.defaultBandwidthEstimate),n.restrictions&&e.Utils.Object.createPropertyPath(i,"abr.restrictions",n.restrictions)}return e.Utils.Object.hasPropertyPath(o,"streaming.lowLatencyMode")&&(i.hlsConfig.lowLatencyMode=e.Utils.Object.getPropertyPath(o,"streaming.lowLatencyMode")),e.Utils.Object.hasPropertyPath(o,"playback.options.html5.hls")&&e.Utils.Object.mergeDeep(i.hlsConfig,o.playback.options.html5.hls),i.network=o.network,new this(r,t,i)}},{key:"canPlayType",value:function(e){var r="string"==typeof e&&c._hlsMimeTypes.includes(e.toLowerCase())&&c.isMSESupported();return c._logger.debug("canPlayType result for mimeType:"+e+" is "+r.toString()),r}},{key:"canPlayDrm",value:function(){return c._logger.warn("canPlayDrm result is false"),!1}},{key:"isSupported",value:function(){var e=T().isSupported();return c._logger.debug("isSupported:"+e),e}}]),c}(e.BaseMediaSourceAdapter);A=k,v(k,"id","HlsAdapter"),v(k,"_logger",e.BaseMediaSourceAdapter.getLogger(A.id)),v(k,"_hlsMimeTypes",["application/x-mpegurl","application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"]);var O="1.32.14",L="@playkit-js/playkit-js-hls",C=k;k.isSupported()&&(0,e.registerMediaSourceAdapter)(k)}(),a}()}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@playkit-js/playkit-js"),require("hls.js")):"function"==typeof define&&define.amd?define("playkit",["playkit-js","hls.js"],r):"object"==typeof exports?exports.playkit=r(require("@playkit-js/playkit-js"),require("hls.js")):(e.playkit=e.playkit||{},e.playkit.hls=r(e.playkit.core,e.Hls))}(self,(function(e,r){return function(){"use strict";var t={952:function(r){r.exports=e},85:function(e){e.exports=r}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,{a:r}),r},i.d=function(e,r){for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){i.r(a),i.d(a,{NAME:function(){return L},VERSION:function(){return O},default:function(){return C}});var e=i(952);function r(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}function t(e,t){if(e){if("string"==typeof e)return r(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(e,t):void 0}}function o(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,i,a,n,s=[],l=!0,c=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=a.call(t)).done)&&(s.push(o.value),s.length!==r);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=t.return&&(n=t.return(),Object(n)!==n))return}finally{if(c)throw i}}return s}}(e,r)||t(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function l(e){var r=function(e,r){if("object"!==s(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!==s(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===s(r)?r:String(r)}function c(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,l(o.key),o)}}function u(e,r,t){return r&&c(e.prototype,r),t&&c(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function _(){return _="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,r,t){var o=function(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=h(e)););return e}(e,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?e:t):i.value}},_.apply(this,arguments)}function f(e,r){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},f(e,r)}function E(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&f(e,r)}function g(e,r){if(r&&("object"===s(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function v(e,r,t){return(r=l(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var y,p=i(85),T=i.n(p),R=JSON.parse('{"recoverDecodingErrorDelay":3000,"recoverSwapAudioCodecDelay":3000,"abr":{"enabled":true,"restrictions":{}},"hlsConfig":{"fragLoadingMaxRetry":4,"maxMaxBufferLength":60},"network":{}}'),m=(v(v(v(v(v(v(v(v(v(v(y={},T().ErrorDetails.MANIFEST_LOAD_ERROR,{category:e.Error.Category.MANIFEST,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.MANIFEST_LOAD_TIMEOUT,{category:e.Error.Category.MANIFEST,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.MANIFEST_PARSING_ERROR,{category:e.Error.Category.MANIFEST,code:e.Error.Code.HLSJS_CANNOT_PARSE}),T().ErrorDetails.LEVEL_LOAD_ERROR,{category:e.Error.Category.NETWORK,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.LEVEL_LOAD_TIMEOUT,{category:e.Error.Category.NETWORK,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.LEVEL_SWITCH_ERROR,{category:e.Error.Category.PLAYER,code:e.Error.Code.BITRATE_SWITCH_ISSUE}),T().ErrorDetails.FRAG_LOAD_ERROR,{category:e.Error.Category.NETWORK,code:e.Error.Code.HTTP_ERROR}),T().ErrorDetails.FRAG_LOAD_TIMEOUT,{category:e.Error.Category.NETWORK,code:e.Error.Code.TIMEOUT}),T().ErrorDetails.FRAG_PARSING_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_FRAG_PARSING_ERROR}),T().ErrorDetails.BUFFER_APPEND_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_APPEND_ISSUE}),v(v(y,T().ErrorDetails.BUFFER_APPENDING_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_APPENDING_ISSUE}),T().ErrorDetails.BUFFER_STALLED_ERROR,{category:e.Error.Category.MEDIA,code:e.Error.Code.HLS_BUFFER_STALLED_ERROR}));var b=function(e){E(i,e);var r,t,o=(r=i,t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,o=h(r);if(t){var i=h(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return g(this,e)});function i(e){var r;return n(this,i),r=o.call(this,e),e&&e.readystatechange&&(r.readystatechange=e.readystatechange),r}return u(i,[{key:"loadInternal",value:function(){var e,r=this,t=this.context;e=this.loader=new XMLHttpRequest;var o=this.stats;o.tfirst=0,o.loaded=0;var i,a=this.xhrSetup;try{if(a)try{i=a(e,t.url,t)}catch(r){e.open("GET",t.url,!0),i=a(e,t.url,t)}e.readyState||e.open("GET",t.url,!0)}catch(e){i=Promise.reject(e)}(i=i||Promise.resolve()).then((function(){t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=r.readystatechange.bind(r),e.onprogress=r.loadprogress.bind(r),e.responseType=t.responseType,r.requestTimeout=window.setTimeout(r.loadtimeout.bind(r),r.config.timeout),e.send()})).catch((function(o){r.callbacks.onError({code:e.status,text:o.message},t,e)}))}}]),i}(T().DefaultConfig.loader);var A,S=function(r){E(a,r);var t,o,i=(t=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=h(t);if(o){var i=h(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return g(this,e)});function a(r){var t;n(this,a);var o=(t=i.call(this,r)).load.bind(d(t)),s=a.redirectExternalStreamsHandler;return t.load=function(r,t,i){var n=r.url;"manifest"===r.type?e.Utils.Http.jsonp(n,s,{timeout:a.redirectExternalStreamsTimeout}).then((function(e){r.url=e,o(r,t,i)})).catch((function(){return o(r,t,i)})):o(r,t,i)},t}return u(a)}(b);function D(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}v(S,"redirectExternalStreamsHandler",(function(e,r){return r}));var k=function(i){E(c,i);var a,s,l=(a=c,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=h(a);if(s){var t=h(this).constructor;e=Reflect.construct(r,arguments,t)}else e=r.apply(this,arguments);return g(this,e)});function c(r,t,o){var i;return n(this,c),v(d(i=l.call(this,r,t,o)),"_hlsjsLib",T()),v(d(i),"_triedReloadWithRedirect",!1),v(d(i),"_playerTracks",[]),v(d(i),"_startTime",0),v(d(i),"_requestFilterError",!1),v(d(i),"_responseFilterError",!1),v(d(i),"_nativeTextTracksMap",{}),v(d(i),"_lastLoadedFragSN",-1),v(d(i),"_sameFragSNLoadedCount",0),v(d(i),"_waitForSubtitleLoad",!0),v(d(i),"_adapterEventsBindings",v(v(v(v(v(v(v(v(v({},T().Events.ERROR,(function(e,r){return i._onError(r)})),T().Events.MANIFEST_LOADED,(function(e,r){return i._onManifestLoaded(r)})),T().Events.LEVEL_SWITCHED,(function(e,r){return i._onLevelSwitched(e,r)})),T().Events.AUDIO_TRACK_SWITCHED,(function(e,r){return i._onAudioTrackSwitched(e,r)})),T().Events.FPS_DROP,(function(e,r){return i._onFpsDrop(r)})),T().Events.FRAG_PARSING_METADATA,(function(e,r){return i._onFragParsingMetadata(r)})),T().Events.FRAG_LOADED,(function(e,r){return i._onFragLoaded(r)})),T().Events.MEDIA_ATTACHED,(function(){return i._onMediaAttached()})),T().Events.LEVEL_LOADED,(function(e,r){return i._onLevelLoaded(e,r)}))),v(d(i),"_onLevelLoaded",(function(r,t){if(i.isLive()){var o=t.details.endSN;if(i._lastLoadedFragSN===o){if(i._sameFragSNLoadedCount++,c._logger.debug("Same frag SN. Count is: ".concat(i._sameFragSNLoadedCount,", Max is: ").concat(i._config.network.maxStaleLevelReloads)),i._sameFragSNLoadedCount>=i._config.network.maxStaleLevelReloads){c._logger.error("Same frag loading reached max count");var a=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.NETWORK,e.Error.Code.LIVE_MANIFEST_REFRESH_ERROR,{fragSN:o});return i._trigger(e.EventType.ERROR,a),i.destroy()}c._logger.debug("Last frag SN is: ".concat(o))}else i._sameFragSNLoadedCount=0;i._lastLoadedFragSN=o}})),c._logger.debug("Creating adapter. Hls version: "+T().version),i._config=e.Utils.Object.mergeDeep({},R,i._config),i._init(),i}return u(c,[{key:"_init",value:function(){this._config.forceRedirectExternalStreams&&(this._config.hlsConfig.pLoader=S),this._maybeSetFilters(),this._hls=new(T())(this._config.hlsConfig),this._capabilities.fpsControl=!0,this._hls.subtitleDisplay=this._config.subtitleDisplay,this._addBindings()}},{key:"_maybeSetFilters",value:function(){var o=this;if("function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.requestFilter")&&(c._logger.debug("Register request filter"),e.Utils.Object.mergeDeep(this._config.hlsConfig,{loader:b,xhrSetup:function(i,a,n){var s,l={url:a,body:null,headers:{}};try{"manifest"===n.type&&(s=o._config.network.requestFilter(e.RequestType.MANIFEST,l)),n.frag&&"subtitle"!==n.frag.type&&(s=o._config.network.requestFilter(e.RequestType.SEGMENT,l))}catch(e){s=Promise.reject(e)}return(s=s||Promise.resolve(l)).then((function(e){n.url=e.url,i.open("GET",e.url,!0),Object.entries(e.headers).forEach((function(e){var o;i.setRequestHeader.apply(i,function(e){if(Array.isArray(e))return r(e)}(o=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||t(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())})),"boolean"==typeof e.withCredentials&&(i.withCredentials=e.withCredentials)})).catch((function(e){throw o._requestFilterError=!0,e}))}})),"function"==typeof e.Utils.Object.getPropertyPath(this._config,"network.responseFilter")){var i=this;c._logger.debug("Register response filter"),e.Utils.Object.mergeDeep(this._config.hlsConfig,{loader:b,readystatechange:function(r){var t=this,o=r.currentTarget,a=o.readyState,n=this.stats,s=this.context,l=this.config;if(!n.aborted&&a>=2){window.clearTimeout(this.requestTimeout);var u=n.loading;if(0===u.first&&(u.first=Math.max(performance.now(),u.start)),4===a){var d=o.status;if(d>=200&&d<300){var h,_;u.end=Math.max(n.tfirst,performance.now()),_="arraybuffer"===s.responseType?(h=o.response).byteLength:(h=o.responseText).length,n.loaded=n.total=_;var f,E={url:o.responseURL,originalUrl:s.url,data:h,headers:e.Utils.Http.convertHeadersToDictionary(o.getAllResponseHeaders())};try{"manifest"===s.type&&(f=i._config.network.responseFilter(e.RequestType.MANIFEST,E)),s.frag&&"subtitle"!==s.frag.type&&(f=i._config.network.responseFilter(e.RequestType.SEGMENT,E))}catch(e){f=Promise.reject(e)}return(f=f||Promise.resolve(E)).then((function(e){t.callbacks.onSuccess(e,n,s,o)})).catch((function(e){i._responseFilterError=!0,t.callbacks.onError({code:d,text:e.message},s,o)}))}n.retry>=l.maxRetry||d>=400&&d<499?(c._logger.error("".concat(d," while loading ").concat(s.url)),this.callbacks.onError({code:d,text:o.statusText},s,o)):(c._logger.warn("".concat(d," while loading ").concat(s.url,", retrying in ").concat(this.retryDelay,"...")),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,l.maxRetryDelay),n.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),l.timeout)}}})}}},{key:"_addBindings",value:function(){var e=this;this._mediaAttachedPromise=new Promise((function(r){return e._onMediaAttached=r}));for(var r=0,t=Object.entries(this._adapterEventsBindings);r<t.length;r++){var i=o(t[r],2),a=i[0],n=i[1];this._hls.on(a,n)}this._onRecoveredCallback=function(){return e._onRecovered()},this._onAddTrack=this._onAddTrack.bind(this),this._eventManager.listen(this._videoElement,"addtrack",this._onAddTrack),this._videoElement.textTracks.onaddtrack=this._onAddTrack}},{key:"_onFpsDrop",value:function(r){this._trigger(e.EventType.FPS_DROP,r)}},{key:"_onFragParsingMetadata",value:function(r){var t;this._trigger("hlsFragParsingMetadata",r);var o=Array.from(null===(t=this._videoElement)||void 0===t?void 0:t.textTracks).find((function(e){return"id3"===e.label})),i=Array.from((null==o?void 0:o.cues)||[]),a=[];null==r||r.samples.forEach((function(r){var t=e.Utils.binarySearch(i,(function(e){return e.startTime-r.pts}));if(t){var o=(0,e.createTimedMetadata)(t);a.push(o)}})),a.length&&this._trigger(e.EventType.TIMED_METADATA_ADDED,{cues:a})}},{key:"_onAddTrack",value:function(r){if(!this._hls.subtitleTracks.length){var t=this._parseCEATextTrack(r.track);t&&(c._logger.debug("A CEA 608/708 caption has been found",t),this._playerTracks.push(t),this._trigger(e.EventType.TRACKS_CHANGED,{tracks:this._playerTracks}))}}},{key:"attachMediaSource",value:function(){this._hls||(this._videoElement&&this._videoElement.src&&(e.Utils.Dom.setAttribute(this._videoElement,"src",""),e.Utils.Dom.removeAttribute(this._videoElement,"src")),this._init())}},{key:"detachMediaSource",value:function(){var r;this._hls&&(0===Math.floor(this.duration-this.currentTime)?this._config.hlsConfig.startPosition=0:this.currentTime>0&&(this._config.hlsConfig.startPosition=this.currentTime),this._reset(),null===(r=this._loadPromiseHandlers)||void 0===r||r.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"media detached while loading")),this._loadPromiseHandlers=null,this._loadPromise=void 0,this._hls=null)}},{key:"handleMediaError",value:function(e){return e.code===e.MEDIA_ERR_DECODE&&(c._logger.debug("The video playback was aborted due to a corruption problem or because the video used features your browser did not support.",e.message),this._handleMediaError(T().ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR))}},{key:"load",value:function(e){var r=this;return this._loadPromise||(this._startTime=e,this._loadPromise=new Promise((function(e,t){r._loadPromiseHandlers={resolve:e,reject:t},r._loadInternal()}))),this._loadPromise}},{key:"_loadInternal",value:function(){var r;this._hls&&this._sourceObj&&this._sourceObj.url?(this._hls.loadSource(this._sourceObj.url),this._hls.attachMedia(this._videoElement),this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:this.isAdaptiveBitrateEnabled()?"auto":"manual"})):null===(r=this._loadPromiseHandlers)||void 0===r||r.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"no url provided"))}},{key:"_reloadWithDirectManifest",value:function(){this._triedReloadWithRedirect=!0,this._reset(),this._config.hlsConfig.pLoader=S,this._hls=new(T())(this._config.hlsConfig),this._addBindings(),this._loadInternal()}},{key:"destroy",value:function(){var r=this;return new Promise((function(t,o){_(h(c.prototype),"destroy",r).call(r).then((function(){var o;c._logger.debug("destroy"),r._playerTracks=[],r._nativeTextTracksMap={},r._sameFragSNLoadedCount=0,r._lastLoadedFragSN=-1,null===(o=r._loadPromiseHandlers)||void 0===o||o.reject(new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,"The adapter has been destroyed while loading")),r._loadPromiseHandlers=null,r._loadPromise=void 0,r._reset(),t()}),(function(){return o()}))}))}},{key:"_reset",value:function(){this._removeBindings(),this._requestFilterError=!1,this._responseFilterError=!1,this._hls.detachMedia(),this._hls.destroy()}},{key:"_parseTracks",value:function(){var e=this._parseAudioTracks(this._hls.audioTracks||[]),r=this._parseVideoTracks(this._hls.levels||[]),t=this._parseTextTracks(this._hls.subtitleTracks||[]);return e.concat(r).concat(t)}},{key:"_parseAudioTracks",value:function(r){for(var t=[],o=0;o<r.length;o++){var i={id:r[o].id,active:this._hls.audioTrack===r[o].id,label:r[o].name,language:r[o].lang,index:o};t.push(new e.AudioTrack(i))}return t}},{key:"_parseVideoTracks",value:function(r){for(var t=[],o=0;o<r.length;o++){var i={active:this._hls.startLevel===o,bandwidth:r[o].bitrate,width:r[o].width,height:r[o].height,language:"",index:o};t.push(new e.VideoTrack(i))}return t}},{key:"_parseTextTracks",value:function(r){var t,o=[],i=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return D(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?D(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,n=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return n=e.done,e},e:function(e){s=!0,a=e},f:function(){try{n||null==t.return||t.return()}finally{if(s)throw a}}}}(r);try{for(i.s();!(t=i.n()).done;){var a=t.value,n={id:a.id,active:!1,default:a.default,label:a.name,kind:a.type.toLowerCase(),language:a.lang};o.push(new e.TextTrack(n))}}catch(e){i.e(e)}finally{i.f()}return o}},{key:"_parseCEATextTrack",value:function(r){var t=null;if("captions"===r.kind){var o={id:r.id,active:"showing"===r.mode,label:r.label,kind:r.kind,language:r.language};t=new e.TextTrack(o),this._nativeTextTracksMap[t.index]=r}return t}},{key:"selectAudioTrack",value:function(r){r instanceof e.AudioTrack&&!r.active&&this._hls.audioTracks&&(this._hls.audioTrack=r.id)}},{key:"selectVideoTrack",value:function(r){r instanceof e.VideoTrack&&(!r.active||this.isAdaptiveBitrateEnabled())&&this._hls.levels&&(this.isAdaptiveBitrateEnabled()&&this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"manual"}),this._hls.currentLevel=r.index)}},{key:"selectTextTrack",value:function(r){r instanceof e.TextTrack&&!r.active&&this._hls&&(this._hls.subtitleTracks.length?(this._hls.subtitleTrack=r.id,this._notifyTrackChanged(r)):this._selectNativeTextTrack(r))}},{key:"_selectNativeTextTrack",value:function(e){var r=this._nativeTextTracksMap[e.index];r&&(this.disableNativeTextTracks(),r.mode=this._config.subtitleDisplay?"showing":"hidden",this._notifyTrackChanged(e))}},{key:"_notifyTrackChanged",value:function(e){this._onTrackChanged(e)}},{key:"_onSubtitleFragProcessed",value:function(){this._hls.subtitleTrack=-1,this._waitForSubtitleLoad=!1,this._hls.off(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this)}},{key:"hideTextTrack",value:function(){this._hls&&(this._hls.subtitleTracks.length?this._waitForSubtitleLoad&&this._hls.subtitleTracks.length>1?this._hls.on(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this):this._hls.subtitleTrack=-1:this.disableNativeTextTracks())}},{key:"enableAdaptiveBitrate",value:function(){this.isAdaptiveBitrateEnabled()||(this._trigger(e.EventType.ABR_MODE_CHANGED,{mode:"auto"}),this._hls.nextLevel=-1)}},{key:"isAdaptiveBitrateEnabled",value:function(){return!!this._hls&&this._hls.autoLevelEnabled}},{key:"applyABRRestriction",value:function(r){e.Utils.Object.createPropertyPath(this._config,"abr.restrictions",r),this._hls.capLevelToPlayerSize||this._maybeApplyAbrRestrictions(r)}},{key:"_getLevelDetails",value:function(){var e=this._hls.levels[this._hls.currentLevel]||this._hls.levels[this._hls.nextLevel]||this._hls.levels[this._hls.nextAutoLevel]||this._hls.levels[this._hls.nextLoadLevel];return e&&e.details?e.details:{}}},{key:"_getLiveEdge",value:function(){try{var e;return(e=this._hls.liveSyncPosition?this._hls.liveSyncPosition:this._hls.config.liveSyncDuration?this._videoElement.duration-this._hls.config.liveSyncDuration:this._videoElement.duration-this._hls.config.liveSyncDurationCount*this._getLevelDetails().targetduration)>0?e:this._videoElement.duration}catch(e){return c._logger.debug("Live edge calculation failed, fall back to duration"),this._videoElement.duration}}},{key:"seekToLiveEdge",value:function(){try{this._videoElement.currentTime=this._getLiveEdge()}catch(e){return}}},{key:"getSegmentDuration",value:function(){var r=e.Utils.Object.getPropertyPath(this._hls,"streamController.fragCurrent");return r?r.duration:0}},{key:"liveDuration",get:function(){return this._getLiveEdge()+this.getSegmentDuration()}},{key:"isLive",value:function(){try{return!!this._getLevelDetails().live}catch(e){return!1}}},{key:"_onManifestLoaded",value:function(r){var t=this;c._logger.debug("The source has been loaded successfully"),this._hls.config.autoStartLoad||this._hls.startLoad(this._startTime),this._playerTracks=this._parseTracks(),this._config.abr.enabled||(this._hls.currentLevel=0),this._mediaAttachedPromise.then((function(){var e;null===(e=t._loadPromiseHandlers)||void 0===e||e.resolve({tracks:t._playerTracks}),t._loadPromiseHandlers=null}));var o=r.stats.loading,i=o.end-o.start;this._trigger(e.EventType.MANIFEST_LOADED,{miliSeconds:i})}},{key:"_maybeApplyAbrRestrictions",value:function(r){var t=this._playerTracks.filter((function(r){return r instanceof e.VideoTrack})),o=(0,e.filterTracksByRestriction)(t,r);if(o.length){var i=o[0],a=o.pop();this._hls.config.minAutoBitrate=i.bandwidth,this._hls.autoLevelCapping=a.index;var n=o.some((function(e){return e.active}));this.isAdaptiveBitrateEnabled()||n||this.selectVideoTrack(i)}else c._logger.warn("Invalid restrictions, there are not tracks within the restriction range")}},{key:"_onLevelSwitched",value:function(r,t){var o=this._playerTracks.find((function(r){return r instanceof e.VideoTrack&&r.index===t.level}));this._onTrackChanged(o)}},{key:"_onAudioTrackSwitched",value:function(r,t){var o=this._playerTracks.find((function(r){return r instanceof e.AudioTrack&&r.id===t.id}));this._onTrackChanged(o),this._handleWaitingUponAudioTrackSwitch()}},{key:"_handleWaitingUponAudioTrackSwitch",value:function(){var r=this;["IE","Edge"].includes(e.Env.browser.name)&&this._eventManager.listenOnce(this._videoElement,e.EventType.TIME_UPDATE,(function(){r._trigger(e.EventType.PLAYING)}))}},{key:"_getErrorDataObject",value:function(e){var r={};switch(r.name=e.details,r.name){case T().ErrorDetails.MANIFEST_LOAD_ERROR:case T().ErrorDetails.LEVEL_LOAD_ERROR:case T().ErrorDetails.AUDIO_TRACK_LOAD_ERROR:r.url=e.url,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.MANIFEST_LOAD_TIMEOUT:case T().ErrorDetails.LEVEL_LOAD_TIMEOUT:case T().ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:r.url=e.url;break;case T().ErrorDetails.MANIFEST_PARSING_ERROR:r.url=e.url,r.reason=e.reason;break;case T().ErrorDetails.LEVEL_SWITCH_ERROR:r.level=e.level,r.reason=e.reason;break;case T().ErrorDetails.FRAG_LOAD_ERROR:r.fragUrl=e.frag?e.frag.url:null,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.FRAG_LOAD_TIMEOUT:r.fragUrl=e.frag?e.frag.url:null;break;case T().ErrorDetails.FRAG_DECRYPT_ERROR:case T().ErrorDetails.FRAG_PARSING_ERROR:r.reason=e.reason;break;case T().ErrorDetails.KEY_LOAD_ERROR:r.fragDecryptedDataUri=e.frag&&e.frag.decryptdata?e.frag.decryptdata.uri:null,r.responseCode=e.response?e.response.code:null;break;case T().ErrorDetails.KEY_LOAD_TIMEOUT:r.fragDecryptedDataUri=e.frag&&e.frag.decryptdata?e.frag.decryptdata.uri:null;break;case T().ErrorDetails.BUFFER_ADD_CODEC_ERROR:r.mimeType=e.mimeType,r.errorMsg=e.err?e.err.message:null;break;case T().ErrorDetails.BUFFER_STALLED_ERROR:r.buffer=e.buffer}return(this._requestFilterError||this._responseFilterError)&&(r.reason=e.response.text),r}},{key:"_onError",value:function(r){var t=r.type,o=r.details,i=r.fatal,a=this._getErrorDataObject(r);if(i){var n,s;switch(t){case T().ErrorTypes.NETWORK_ERROR:var l;l=this._requestFilterError?e.Error.Code.REQUEST_FILTER_ERROR:this._responseFilterError?e.Error.Code.RESPONSE_FILTER_ERROR:e.Error.Code.HTTP_ERROR,![T().ErrorDetails.MANIFEST_LOAD_ERROR,T().ErrorDetails.MANIFEST_LOAD_TIMEOUT].includes(o)||this._triedReloadWithRedirect||this._config.forceRedirectExternalStreams||this._requestFilterError||this._responseFilterError?n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.NETWORK,l,a):(n=new e.Error(e.Error.Severity.RECOVERABLE,e.Error.Category.NETWORK,l,a),this._reloadWithDirectManifest());break;case T().ErrorTypes.MEDIA_ERROR:n=this._handleMediaError(o)?new e.Error(e.Error.Severity.RECOVERABLE,e.Error.Category.MEDIA,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a):new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.MEDIA,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a);break;default:n=new e.Error(e.Error.Severity.CRITICAL,e.Error.Category.PLAYER,e.Error.Code.HLS_FATAL_MEDIA_ERROR,a)}if(this._trigger(e.EventType.ERROR,n),n&&n.severity===e.Error.Severity.CRITICAL)this._loadPromiseHandlers&&(null===(s=this._loadPromiseHandlers)||void 0===s||s.reject(n),this._loadPromiseHandlers=null,this._loadPromise=void 0),this.destroy()}else{var u=this._requestFilterError||this._responseFilterError?{category:e.Error.Category.NETWORK,code:this._requestFilterError?e.Error.Code.REQUEST_FILTER_ERROR:e.Error.Code.RESPONSE_FILTER_ERROR}:m[o]||{category:0,code:0},d=u.category,h=u.code;c._logger.warn(new e.Error(e.Error.Severity.RECOVERABLE,d,h,a))}this._requestFilterError=!1,this._responseFilterError=!1}},{key:"_handleMediaError",value:function(r){c._logger.error("_handleMediaError mediaErrorName:",r);var t=performance.now(),o=!0;return r===T().ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?(c._logger.error("recover aborted due to: MANIFEST_INCOMPATIBLE_CODECS_ERROR"),o=!1):this._checkTimeDeltaHasPassed(t,this._recoverDecodingErrorDate,this._config.recoverDecodingErrorDelay)?(this._eventManager.listen(this._videoElement,e.EventType.LOADED_METADATA,this._onRecoveredCallback),c._logger.debug("try to recover using: _recoverDecodingError()"),this._recoverDecodingError()):this._checkTimeDeltaHasPassed(t,this._recoverSwapAudioCodecDate,this._config.recoverSwapAudioCodecDelay)?(this._eventManager.listen(this._videoElement,e.EventType.LOADED_METADATA,this._onRecoveredCallback),c._logger.debug("try to recover using: _recoverSwapAudioCodec()"),this._recoverSwapAudioCodec()):(c._logger.error("cannot recover, last media error recovery failed error: ",r),o=!1),o}},{key:"_onRecovered",value:function(){this._trigger(e.EventType.MEDIA_RECOVERED),this._videoElement.removeEventListener(e.EventType.LOADED_METADATA,this._onRecoveredCallback)}},{key:"_checkTimeDeltaHasPassed",value:function(e,r,t){return!r||e-r>t}},{key:"_recoverDecodingError",value:function(){this._recoverDecodingErrorDate=performance.now(),c._logger.warn("try to recover media Error"),this._hls.recoverMediaError()}},{key:"_recoverSwapAudioCodec",value:function(){this._recoverSwapAudioCodecDate=performance.now(),c._logger.warn("try to swap Audio Codec and recover media Error"),this._hls.swapAudioCodec(),this._hls.recoverMediaError()}},{key:"_removeBindings",value:function(){for(var e=0,r=Object.entries(this._adapterEventsBindings);e<r.length;e++){var t=o(r[e],2),i=t[0],a=t[1];this._hls.off(i,a)}this._hls.off(T().Events.SUBTITLE_FRAG_PROCESSED,this._onSubtitleFragProcessed,this),this._videoElement.textTracks.onaddtrack=null,this._onRecoveredCallback=null,this._eventManager&&this._eventManager.removeAll()}},{key:"getStartTimeOfDvrWindow",value:function(){if(!this.isLive())return 0;try{var e=this._hls.levels[this._hls.nextLoadLevel].details,r=e.fragments,t=r.length,o=r[0].start+r[0].duration,i=r[t-1].start+r[t-1].duration,a=void 0!==this._hls.config.liveMaxLatencyDuration?this._hls.config.liveMaxLatencyDuration:this._hls.config.liveMaxLatencyDurationCount*e.targetduration;return Math.max(o-this._hls.config.maxFragLookUpTolerance,i-a)}catch(e){return c._logger.debug("Unable obtain the start of DVR window"),0}}},{key:"_onFragLoaded",value:function(r){if(e.Utils.Object.hasPropertyPath(r,"frag.stats.loading")){var t=r.frag.stats,o=t.loading.end-t.loading.start;this._trigger(e.EventType.FRAG_LOADED,{miliSeconds:o,bytes:t.loaded,url:r.frag.url})}}},{key:"targetBuffer",get:function(){var e=NaN;return this._hls?(e=this.isLive()?this._getLiveTargetBuffer()-(this._videoElement.currentTime-this._getLiveEdge()):this._videoElement.duration-this._videoElement.currentTime,e=Math.min(e,this._hls.config.maxMaxBufferLength+this._getLevelDetails().targetduration)):NaN}},{key:"_getLiveTargetBuffer",value:function(){return this._hls.config.liveSyncDuration?this._hls.config.liveSyncDuration:this._hls.config.liveSyncDurationCount*this._getLevelDetails().targetduration}}],[{key:"createAdapter",value:function(r,t,o){var i=e.Utils.Object.copyDeep(R);if(e.Utils.Object.hasPropertyPath(o,"sources.options")){var a=o.sources.options;i.forceRedirectExternalStreams=a.forceRedirectExternalStreams,i.redirectExternalStreamsHandler=a.redirectExternalStreamsHandler,i.redirectExternalStreamsTimeout=a.redirectExternalStreamsTimeout,S.redirectExternalStreamsHandler=i.redirectExternalStreamsHandler,S.redirectExternalStreamsTimeout=i.redirectExternalStreamsTimeout}if(e.Utils.Object.hasPropertyPath(o,"sources.startTime")&&e.Utils.Object.getPropertyPath(o,"sources.startTime")>-1&&(i.hlsConfig.startPosition=o.sources.startTime),e.Utils.Object.hasPropertyPath(o,"text.useNativeTextTrack")&&(i.subtitleDisplay=e.Utils.Object.getPropertyPath(o,"text.useNativeTextTrack")),e.Utils.Object.hasPropertyPath(o,"abr.fpsDroppedFramesInterval")&&(i.hlsConfig.fpsDroppedFramesInterval=o.abr.fpsDroppedFramesInterval),e.Utils.Object.hasPropertyPath(o,"abr.fpsDroppedMonitoringThreshold")&&(i.hlsConfig.fpsDroppedMonitoringThreshold=o.abr.fpsDroppedMonitoringThreshold),e.Utils.Object.hasPropertyPath(o,"abr.capLevelOnFPSDrop")&&(c._logger.debug("capLevelOnFPSDrop = ",o.abr.capLevelOnFPSDrop),i.hlsConfig.capLevelOnFPSDrop=o.abr.capLevelOnFPSDrop),e.Utils.Object.hasPropertyPath(o,"text")&&(i.hlsConfig.enableCEA708Captions=o.text.enableCEA708Captions,i.hlsConfig.captionsTextTrack1Label=o.text.captionsTextTrack1Label,i.hlsConfig.captionsTextTrack1LanguageCode=o.text.captionsTextTrack1LanguageCode,i.hlsConfig.captionsTextTrack2Label=o.text.captionsTextTrack2Label,i.hlsConfig.captionsTextTrack2LanguageCode=o.text.captionsTextTrack2LanguageCode),e.Utils.Object.hasPropertyPath(o,"abr")){var n=o.abr;"boolean"==typeof n.enabled&&(i.abr.enabled=n.enabled),"boolean"==typeof n.capLevelToPlayerSize&&(i.hlsConfig.capLevelToPlayerSize=n.capLevelToPlayerSize),n.defaultBandwidthEstimate&&(i.hlsConfig.abrEwmaDefaultEstimate=n.defaultBandwidthEstimate),n.restrictions&&e.Utils.Object.createPropertyPath(i,"abr.restrictions",n.restrictions)}return e.Utils.Object.hasPropertyPath(o,"streaming.lowLatencyMode")&&(i.hlsConfig.lowLatencyMode=e.Utils.Object.getPropertyPath(o,"streaming.lowLatencyMode")),e.Utils.Object.hasPropertyPath(o,"playback.options.html5.hls")&&e.Utils.Object.mergeDeep(i.hlsConfig,o.playback.options.html5.hls),i.network=o.network,new this(r,t,i)}},{key:"canPlayType",value:function(e){var r="string"==typeof e&&c._hlsMimeTypes.includes(e.toLowerCase())&&c.isMSESupported();return c._logger.debug("canPlayType result for mimeType:"+e+" is "+r.toString()),r}},{key:"canPlayDrm",value:function(){return c._logger.warn("canPlayDrm result is false"),!1}},{key:"isSupported",value:function(){var e=T().isSupported();return c._logger.debug("isSupported:"+e),e}}]),c}(e.BaseMediaSourceAdapter);A=k,v(k,"id","HlsAdapter"),v(k,"_logger",e.BaseMediaSourceAdapter.getLogger(A.id)),v(k,"_hlsMimeTypes",["application/x-mpegurl","application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"]);var O="1.32.15",L="@playkit-js/playkit-js-hls",C=k;k.isSupported()&&(0,e.registerMediaSourceAdapter)(k)}(),a}()}));
2
2
  //# sourceMappingURL=playkit-hls.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/playkit-js-hls",
3
- "version": "1.32.14",
3
+ "version": "1.32.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "hls",