From aeb5de85b601c2b6701e30f8edc74d2a99317dbe Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sun, 30 Jan 2022 12:55:25 -0800 Subject: [PATCH] Update HLS support --- player/iframechild.coffee | 2 +- templates/channel.pug | 2 +- www/js/videojs-contrib-hls.min.js | 8 -------- www/js/videojs-hlsjs-plugin.js | 8 ++++++++ 4 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 www/js/videojs-contrib-hls.min.js create mode 100644 www/js/videojs-hlsjs-plugin.js diff --git a/player/iframechild.coffee b/player/iframechild.coffee index 140c9c59..9147fded 100644 --- a/player/iframechild.coffee +++ b/player/iframechild.coffee @@ -25,7 +25,7 @@ window.IframeChild = class IframeChild extends PlayerJSPlayer iframe.addEventListener('load', => iframe.contentWindow.VOLUME = VOLUME; iframe.contentWindow.loadMediaPlayer(Object.assign({}, data, { type: 'cm' } )) - iframe.contentWindow.document.querySelector('#ytapiplayer').classList.add('vjs-fluid') + iframe.contentWindow.document.querySelector('#ytapiplayer').classList.add('vjs-16-9') adapter = iframe.contentWindow.playerjs.VideoJSAdapter(iframe.contentWindow.PLAYER.player) adapter.ready() typeof data?.meta?.thumbnail == 'string' and iframe.contentWindow.PLAYER.player.poster(data.meta.thumbnail) diff --git a/templates/channel.pug b/templates/channel.pug index 593fc432..8b52f3fc 100644 --- a/templates/channel.pug +++ b/templates/channel.pug @@ -255,7 +255,7 @@ html(lang="en") script(defer, src="/js/peertube.js") script(defer, src="/js/sc.js") script(defer, src="/js/video.js") - script(defer, src="/js/videojs-contrib-hls.min.js") + script(defer, src="/js/videojs-hlsjs-plugin.js") script(defer, src="/js/videojs-resolution-switcher.js") script(defer, src="/js/playerjs-0.0.12.js") script(defer, src="/js/dash.all.min.js") diff --git a/www/js/videojs-contrib-hls.min.js b/www/js/videojs-contrib-hls.min.js deleted file mode 100644 index 354fd7ad..00000000 --- a/www/js/videojs-contrib-hls.min.js +++ /dev/null @@ -1,8 +0,0 @@ -!function e(t,i,n){function r(s,o){if(!i[s]){if(!t[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(a)return a(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var l=i[s]={exports:{}};t[s][0].call(l.exports,function(e){var i=t[s][1][e];return r(i||e)},l,l.exports,e,t,i,n)}return i[s].exports}for(var a="function"==typeof require&&require,s=0;s=r.adStartTime&&t<=r.adEndTime)return r}return null},o=function(e,t){var i=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(e.segments)for(var r=i,o=undefined,u=0;u=32&&e<126?String.fromCharCode(e):"."},s=function(e){var t={};return Object.keys(e).forEach(function(i){var n=e[i];ArrayBuffer.isView(n)?t[i]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:t[i]=n}),t},o=function(e){var t=e.byterange||{length:Infinity,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},u={hexDump:function(e){for(var t=Array.prototype.slice.call(e),i="",n=undefined,s=undefined,o=0;o1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var e=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var t=e.selectPlaylist(),i=e.masterPlaylistLoader_.media(),n=e.tech_.buffered(),r=n.length?n.end(n.length-1)-e.tech_.currentTime():0,a=e.bufferLowWaterLine();(!i.endList||e.duration()=a)&&e.masterPlaylistLoader_.media(t),e.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){e.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){e.blacklistCurrentPlaylist(e.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){e.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){e.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){e.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){e.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120)}),this.mainSegmentLoader_.on("reseteverything",function(){e.tech_.trigger("hls-reset")}),this.audioSegmentLoader_.on("ended",function(){e.onEndOfStream()}),this.audioSegmentLoader_.on("error",function(){y["default"].log.warn("Problem encountered with the current alternate audio track. Switching back to default."),e.audioSegmentLoader_.abort(),e.audioPlaylistLoader_=null,e.setupAudio()}),this.subtitleSegmentLoader_.on("error",this.handleSubtitleError_.bind(this))}},{key:"handleAudioinfoUpdate_",value:function(e){if(C.supportsAudioInfoChange_()||!this.audioInfo_||!x(this.audioInfo_,e.info))return void(this.audioInfo_=e.info);var t="had different audio properties (channels, sample rate, etc.) or changed in some other way. This behavior is currently unsupported in Firefox 48 and below due to an issue: \n\nhttps://bugzilla.mozilla.org/show_bug.cgi?id=1247138\n\n",i=this.activeAudioGroup().map(function(e){return e.enabled}).indexOf(!0),n=this.activeAudioGroup()[i],r=this.activeAudioGroup().filter(function(e){return e.properties_&&e.properties_["default"]})[0];this.audioPlaylistLoader_?(t="The audio track '"+n.label+"' that we tried to switch to "+t+" Unfortunately this means we will have to return you to the main track '"+r.label+"'. Sorry!",r.enabled=!0,this.activeAudioGroup().splice(i,1),this.trigger("audioupdate")):(t="The rendition that we tried to switch to "+t+"Unfortunately that means we will have to blacklist the current playlist and switch to another. Sorry!",this.blacklistCurrentPlaylist()),y["default"].log.warn(t),this.setupAudio()}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"fillAudioTracks_",value:function(){var e=this.master(),t=e.mediaGroups||{};t&&t.AUDIO&&0!==Object.keys(t.AUDIO).length&&"html5"===this.mode_||(t.AUDIO={main:{"default":{"default":!0}}});for(var i in t.AUDIO){this.audioGroups_[i]||(this.audioGroups_[i]=[]);for(var n in t.AUDIO[i]){var r=t.AUDIO[i][n],a=new y["default"].AudioTrack({id:n,kind:this.audioTrackKind_(r),enabled:!1,language:r.language,label:n});a.properties_=r,this.audioGroups_[i].push(a)}}(this.activeAudioGroup().filter(function(e){return e.properties_["default"]})[0]||this.activeAudioGroup()[0]).enabled=!0}},{key:"audioTrackKind_",value:function(e){var t=e["default"]?"main":"alternative";return e.characteristics&&e.characteristics.indexOf("public.accessibility.describes-video")>=0&&(t="main-desc"),t}},{key:"fillSubtitleTracks_",value:function(){var e=this.master(),t=e.mediaGroups||{};for(var i in t.SUBTITLES){this.subtitleGroups_.groups[i]||(this.subtitleGroups_.groups[i]=[]);for(var n in t.SUBTITLES[i]){var r=t.SUBTITLES[i][n];if(!r.forced&&(this.subtitleGroups_.groups[i].push(y["default"].mergeOptions({id:n},r)),"undefined"==typeof this.subtitleGroups_.tracks[n])){var a=this.tech_.addRemoteTextTrack({id:n,kind:"subtitles",enabled:!1,language:r.language,label:n},!1).track;this.subtitleGroups_.tracks[n]=a}}}}},{key:"fillClosedCaptionTracks_",value:function(){var e=this.master(),t=e.mediaGroups||{};for(var i in t["CLOSED-CAPTIONS"]){this.closedCaptionGroups_.groups[i]||(this.closedCaptionGroups_.groups[i]=[]);for(var n in t["CLOSED-CAPTIONS"][i]){var r=t["CLOSED-CAPTIONS"][i][n];if(r.instreamId.match(/CC\d/)&&(this.closedCaptionGroups_.groups[i].push(y["default"].mergeOptions({id:n},r)),"undefined"==typeof this.closedCaptionGroups_.tracks[n])){var a=this.tech_.addRemoteTextTrack({id:r.instreamId,kind:"captions",enabled:!1,language:r.language,label:n},!1).track;this.closedCaptionGroups_.tracks[n]=a}}}}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.audioPlaylistLoader_&&this.audioSegmentLoader_.load(),this.subtitlePlaylistLoader_&&this.subtitleSegmentLoader_.load()}},{key:"activeAudioGroup",value:function(){var e=this.masterPlaylistLoader_.media(),t=undefined;return e.attributes.AUDIO&&(t=this.audioGroups_[e.attributes.AUDIO]),t||this.audioGroups_.main}},{key:"activeSubtitleGroup_",value:function(){var e=this.masterPlaylistLoader_.media(),t=undefined;return e?(e.attributes.SUBTITLES&&(t=this.subtitleGroups_.groups[e.attributes.SUBTITLES]),t||this.subtitleGroups_.groups.main):null}},{key:"activeSubtitleTrack_",value:function(){for(var e in this.subtitleGroups_.tracks)if("showing"===this.subtitleGroups_.tracks[e].mode)return this.subtitleGroups_.tracks[e];return null}},{key:"handleSubtitleError_",value:function(){y["default"].log.warn("Problem encountered loading the subtitle track. Switching back to default."),this.subtitleSegmentLoader_.abort();var e=this.activeSubtitleTrack_();e&&(e.mode="disabled"),this.setupSubtitles()}},{key:"mediaGroupChanged",value:function(){var e=this.getActiveAudioTrack_();this.stopAudioLoaders_(),this.resyncAudioLoaders_(e)}},{key:"setupAudio",value:function(){var e=this.getActiveAudioTrack_();this.stopAudioLoaders_(),this.resetAudioLoaders_(e)}},{key:"getActiveAudioTrack_",value:function(){var e=this.activeAudioGroup(),t=e.filter(function(e){return e.enabled})[0];return t||(t=e.filter(function(e){return e.properties_["default"]})[0]||e[0],t.enabled=!0),t}},{key:"stopAudioLoaders_",value:function(){this.audioPlaylistLoader_&&(this.audioPlaylistLoader_.dispose(),this.audioPlaylistLoader_=null),this.audioSegmentLoader_.pause()}},{key:"resetAudioLoaders_",value:function(e){if(!e.properties_.resolvedUri)return void this.mainSegmentLoader_.resetEverything();this.audioSegmentLoader_.resetEverything(),this.setupAudioPlaylistLoader_(e)}},{key:"resyncAudioLoaders_",value:function(e){e.properties_.resolvedUri&&(this.audioSegmentLoader_.resyncLoader(),this.setupAudioPlaylistLoader_(e))}},{key:"setupAudioPlaylistLoader_",value:function(e){var t=this;this.audioPlaylistLoader_=new d["default"](e.properties_.resolvedUri,this.hls_,this.withCredentials),this.audioPlaylistLoader_.load(),this.audioPlaylistLoader_.on("loadedmetadata",function(){var e=t.audioPlaylistLoader_.media();t.audioSegmentLoader_.playlist(e,t.requestOptions_),(!t.tech_.paused()||e.endList&&"none"!==t.tech_.preload())&&t.audioSegmentLoader_.load(),e.endList||t.audioPlaylistLoader_.trigger("firstplay")}),this.audioPlaylistLoader_.on("loadedplaylist",function(){var e=undefined;if(t.audioPlaylistLoader_&&(e=t.audioPlaylistLoader_.media()),!e)return void t.audioPlaylistLoader_.media(t.audioPlaylistLoader_.playlists.master.playlists[0]);t.audioSegmentLoader_.playlist(e,t.requestOptions_)}),this.audioPlaylistLoader_.on("error",function(){y["default"].log.warn("Problem encountered loading the alternate audio track. Switching back to default."),t.audioSegmentLoader_.abort(),t.setupAudio()})}},{key:"setupSubtitles",value:function(){var e=this,t=this.activeSubtitleGroup_(),i=this.activeSubtitleTrack_();if(this.subtitleSegmentLoader_.pause(),!i)return void(this.subtitlePlaylistLoader_&&(this.subtitlePlaylistLoader_.dispose(),this.subtitlePlaylistLoader_=null));var n=t.filter(function(e){return e.id===i.id})[0];this.subtitlePlaylistLoader_&&this.subtitlePlaylistLoader_.media()&&this.subtitlePlaylistLoader_.media().resolvedUri===n.resolvedUri||(this.subtitlePlaylistLoader_&&this.subtitlePlaylistLoader_.dispose(),this.subtitleSegmentLoader_.resetEverything(),this.subtitlePlaylistLoader_=new d["default"](n.resolvedUri,this.hls_,this.withCredentials),this.subtitlePlaylistLoader_.on("loadedmetadata",function(){var t=e.subtitlePlaylistLoader_.media();e.subtitleSegmentLoader_.playlist(t,e.requestOptions_),e.subtitleSegmentLoader_.track(e.activeSubtitleTrack_()),(!e.tech_.paused()||t.endList&&"none"!==e.tech_.preload())&&e.subtitleSegmentLoader_.load()}),this.subtitlePlaylistLoader_.on("loadedplaylist",function(){var t=undefined;e.subtitlePlaylistLoader_&&(t=e.subtitlePlaylistLoader_.media()),t&&e.subtitleSegmentLoader_.playlist(t,e.requestOptions_)}),this.subtitlePlaylistLoader_.on("error",this.handleSubtitleError_.bind(this))),this.subtitlePlaylistLoader_.media()&&this.subtitlePlaylistLoader_.media().resolvedUri===n.resolvedUri?this.subtitleSegmentLoader_.load():this.subtitlePlaylistLoader_.load()}},{key:"fastQualityChange_",value:function(){var e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader())}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_()&&this.load();var e=this.tech_.seekable();return this.tech_.duration()===Infinity&&this.tech_.currentTime()e.end(0)||e.start(0)>t.end(0)?this.seekable_=e:this.seekable_=y["default"].createTimeRanges([[t.start(0)>e.start(0)?t.start(0):e.start(0),t.end(0)0&&(i=Math.max(i,n.end(n.length-1))),t!==i&&("open"!==this.mediaSource.readyState?this.mediaSource.addEventListener("sourceopen",r):r())}},{key:"dispose",value:function(){this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.audioPlaylistLoader_&&this.audioPlaylistLoader_.dispose(),this.subtitlePlaylistLoader_&&this.subtitlePlaylistLoader_.dispose(),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var e=this.masterPlaylistLoader_.media(),t=undefined;if(e&&"open"===this.mediaSource.readyState){if(t=N(this.masterPlaylistLoader_.master,e),t.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+e.resolvedUri,this.mediaSource.endOfStream("decode");this.mainSegmentLoader_.mimeType(t[0]),t[1]&&this.audioSegmentLoader_.mimeType(t[1]),this.excludeIncompatibleVariants_(e)}}},{key:"excludeIncompatibleVariants_",value:function(e){var t=this.masterPlaylistLoader_.master,i=2,n=null,r=undefined;e.attributes.CODECS&&(r=(0,P.parseCodecs)(e.attributes.CODECS),n=r.videoCodec,i=r.codecCount),t.playlists.forEach(function(e){var t={codecCount:2,videoCodec:null};if(e.attributes.CODECS){var r=e.attributes.CODECS;t=(0,P.parseCodecs)(r),window.MediaSource&&window.MediaSource.isTypeSupported&&!window.MediaSource.isTypeSupported('video/mp4; codecs="'+R(r)+'"')&&(e.excludeUntil=Infinity)}t.codecCount!==i&&(e.excludeUntil=Infinity),t.videoCodec!==n&&(e.excludeUntil=Infinity)})}},{key:"updateAdCues_",value:function(e){var t=0,i=this.seekable();i.length&&(t=i.start(0)),v["default"].updateAdCues(e,this.cueTagsTrack_,t)}},{key:"goalBufferLength",value:function(){var e=this.tech_.currentTime(),t=L["default"].GOAL_BUFFER_LENGTH,i=L["default"].GOAL_BUFFER_LENGTH_RATE,n=Math.max(t,L["default"].MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*i,n)}},{key:"bufferLowWaterLine",value:function(){var e=this.tech_.currentTime(),t=L["default"].BUFFER_LOW_WATER_LINE,i=L["default"].BUFFER_LOW_WATER_LINE_RATE,n=Math.max(t,L["default"].MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*i,n)}}]),t}(y["default"].EventTarget);i.MasterPlaylistController=F}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,i){(function(t){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n="undefined"!=typeof window?window.videojs:void 0!==t?t.videojs:null,r=function(e){return e&&e.__esModule?e:{"default":e}}(n),a=e(2),s={FAILURE:2,TIMEOUT:-101,ABORTED:-102};i.REQUEST_ERRORS=s;var o=function(e){var t=(undefined,undefined);return t=e.offset+e.length-1,"bytes="+e.offset+"-"+t},u=function(e){var t={};return e.byterange&&(t.Range=o(e.byterange)),t},d=function(e){e.forEach(function(e){e.abort()})},l=function(e){return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}},f=function(e){var t=e.target,i=Date.now()-t.requestTime,n={bandwidth:Infinity,bytesReceived:0,roundTripTime:i||0};return n.bytesReceived=e.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},c=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:s.TIMEOUT,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:s.ABORTED,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:s.FAILURE,xhr:t}:null},h=function(e,t){return function(i,n){var r=n.response,a=c(i,n);if(a)return t(a,e);if(16!==r.byteLength)return t({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:s.FAILURE,xhr:n},e);var o=new DataView(r);return e.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),t(null,e)}},p=function(e,t){return function(i,n){var r=n.response,a=c(i,n);return a?t(a,e):0===r.byteLength?t({status:n.status,message:"Empty HLS segment content at URL: "+n.uri,code:s.FAILURE,xhr:n},e):(e.map.bytes=new Uint8Array(n.response),t(null,e))}},m=function(e,t){return function(i,n){var r=n.response,a=c(i,n);return a?t(a,e):0===r.byteLength?t({status:n.status,message:"Empty HLS segment content at URL: "+n.uri,code:s.FAILURE,xhr:n},e):(e.stats=l(n),e.key?e.encryptedBytes=new Uint8Array(n.response):e.bytes=new Uint8Array(n.response),t(null,e))}},g=function(e,t,i){var n=function r(n){if(n.data.source===t.requestId){e.removeEventListener("message",r);var a=n.data.decrypted;return t.bytes=new Uint8Array(a.bytes,a.byteOffset,a.byteLength),i(null,t)}};e.addEventListener("message",n),e.postMessage((0,a.createTransferableMessage)({source:t.requestId,encrypted:t.encryptedBytes,key:t.key.bytes,iv:t.key.iv}),[t.encryptedBytes.buffer,t.key.bytes.buffer])},y=function(e){return e.reduce(function(e,t){return t.code>e.code?t:e})},_=function(e,t,i){var n=[],r=0;return function(a,s){if(a&&(d(e),n.push(a)),(r+=1)===e.length){if(s.endOfAllRequests=Date.now(),n.length>0){var o=y(n);return i(o,s)}return s.encryptedBytes?g(t,s,i):i(null,s)}}},v=function(e,t){return function(i){return e.stats=r["default"].mergeOptions(e.stats,f(i)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(i,e)}},b=function(e,t,i,n,a,s){var o=[],l=_(o,i,s);if(n.key){var f=r["default"].mergeOptions(t,{uri:n.key.resolvedUri,responseType:"arraybuffer" -}),c=h(n,l),g=e(f,c);o.push(g)}if(n.map&&!n.map.bytes){var y=r["default"].mergeOptions(t,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:u(n.map)}),b=p(n,l),T=e(y,b);o.push(T)}var S=r["default"].mergeOptions(t,{uri:n.resolvedUri,responseType:"arraybuffer",headers:u(n)}),w=m(n,l),k=e(S,w);return k.addEventListener("progress",v(n,a)),o.push(k),function(){return d(o)}};i.mediaSegmentRequest=b}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(e,t){for(var i=0;i")),this.logger_("initialize");var n=function(){return i.monitorCurrentTime_()},r=function(){return i.techWaiting_()},s=function(){return i.cancelTimer_()},o=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",o),this.tech_.on("waiting",r),this.tech_.on(h,s),this.tech_.on("canplay",n),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",o),i.tech_.off("waiting",r),i.tech_.off(h,s),i.tech_.off("canplay",n),i.checkCurrentTimeTimeout_&&u["default"].clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return s(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&u["default"].clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=u["default"].setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_())return this.consecutiveUpdates=0,void(this.lastRecordedTime=this.tech_.currentTime());if(!this.tech_.paused()&&!this.tech_.seeking()){var e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+.1>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.outsideOfSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Trying to seek outside of seekable at time "+t+" with seekable range "+l["default"].printableRange(e)+". Seeking to "+i+"."),this.tech_.setCurrentTime(i),!0}return!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var e=this.tech_.currentTime(),t=this.tech_.buffered(),i=l["default"].findRange(t,e);return i.length&&e+3<=i.end(0)?(this.cancelTimer_(),this.tech_.setCurrentTime(e),this.logger_("Stopped at "+e+" while inside a buffered region ["+i.start(0)+" -> "+i.end(0)+"]. Attempting to resume playback by seeking to the current time."),void this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})):void 0}}},{key:"techWaiting_",value:function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return!0;if(this.tech_.seeking()||null!==this.timer_)return!0;if(this.fellOutOfLiveWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to live point (seekable end) "+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var n=this.tech_.buffered(),r=l["default"].findNextRange(n,t);if(this.videoUnderflow_(r,n,t))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(r.length>0){var a=r.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+a+", seeking to "+r.start(0)),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*a,t),!0}return!1}},{key:"outsideOfSeekableWindow_",value:function(e,t){return!!e.length&&(te.end(e.length-1)+.1)}},{key:"fellOutOfLiveWindow_",value:function(e,t){return!!(e.length&&e.start(0)>0&&t2)return{start:r,end:a}}return null}},{key:"logger_",value:function(){}}]),e}();i["default"]=p,t.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(i,"__esModule",{value:!0});var a=e(14),s=r(a),o="undefined"!=typeof window?window.videojs:void 0!==n?n.videojs:null,u=e(10),d=e(32),l=r(d),f=e(31),c=r(f),h=function(e,t,i){var n=t.slice(),r=undefined,a=undefined;for(i=i||0,r=Math.min(e.length,t.length+i),a=i;a=500?4:2},r.trigger("error")},h=function(e,t){var i=undefined,n=undefined,s=undefined;r.setBandwidth(d||e),d=null,r.state="HAVE_METADATA",i=new l["default"].Parser,i.push(e.responseText),i.end(),i.manifest.uri=t,i.manifest.attributes=i.manifest.attributes||{},s=p(r.master,i.manifest),n=1e3*(i.manifest.targetDuration||10),r.targetDuration=i.manifest.targetDuration,s?(r.master=s,r.media_=r.master.playlists[i.manifest.uri]):(n/=2,r.trigger("playlistunchanged")),r.media().endList||(c["default"].clearTimeout(a),a=c["default"].setTimeout(function(){r.trigger("mediaupdatetimeout")},n)),r.trigger("loadedplaylist")},r.state="HAVE_NOTHING",r.dispose=function(){r.stopRequest(),c["default"].clearTimeout(a),r.off()},r.stopRequest=function(){if(d){var e=d;d=null,e.onreadystatechange=null,e.abort()}},r.enabledPlaylists_=function(){return r.master.playlists.filter(u.isEnabled).length},r.isLowestEnabledRendition_=function(){if(1===r.master.playlists.length)return!0;var e=r.media(),t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===r.master.playlists.filter(function(e){return!!(0,u.isEnabled)(e)&&(e.attributes.BANDWIDTH||0)i||e.height>n}),m=p.filter(function(e){return e.width===p[0].width&&e.height===p[0].height}),u=m[m.length-1],g=m.filter(function(e){return e.bandwidth===u.bandwidth})[0]),(g||h||d||r[0]).playlist};i.simpleSelector=h;var p=function(){return h(this.playlists.master,this.systemBandwidth,parseInt(d(this.tech_.el(),"width"),10),parseInt(d(this.tech_.el(),"height"),10))};i.lastBandwidthSelector=p;var m=function(e){var t=-1;if(e<0||e>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){return t<0&&(t=this.systemBandwidth),t=e*this.systemBandwidth+(1-e)*t,h(this.playlists.master,t,parseInt(d(this.tech_.el(),"width"),10),parseInt(d(this.tech_.el(),"height"),10))}};i.movingAverageBandwidthSelector=m;var g=function(e){var t=e.master,i=e.currentTime,n=e.bandwidth,r=e.duration,a=e.segmentDuration,s=e.timeUntilRebuffer,u=e.currentTimeline,d=e.syncController,c=t.playlists.filter(function(e){return o["default"].isEnabled(e)&&o["default"].hasAttribute("BANDWIDTH",e)}),h=c.map(function(e){var t=d.getSyncPoint(e,r,u,i),l=t?1:2;return{playlist:e,rebufferingImpact:o["default"].estimateSegmentRequestTime(a,n,e)*l-s}}),p=h.filter(function(e){return e.rebufferingImpact<=0});return l(p,function(e,t){return f(t.playlist,e.playlist)}),p.length?p[0]:(l(h,function(e,t){return e.rebufferingImpact-t.rebufferingImpact}),h[0]||null)};i.minRebufferMaxBandwidthSelector=g;var y=function(){var e=this.playlists.master.playlists.filter(o["default"].isEnabled);return l(e,function(e,t){return f(e,t)}),e.filter(function(e){return(0,u.parseCodecs)(e.attributes.CODECS).videoCodec})[0]||null};i.lowestBitrateCompatibleVariantSelector=y},{}],10:[function(e,t,i){(function(t){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n="undefined"!=typeof window?window.videojs:void 0!==t?t.videojs:null,r=e(31),a=function(e){return e&&e.__esModule?e:{"default":e}}(r),s={UNSAFE_LIVE_SEGMENTS:3},o=function(e,t){var i=0,n=t-e.mediaSequence,r=e.segments[n];if(r){if("undefined"!=typeof r.start)return{result:r.start,precise:!0};if("undefined"!=typeof r.end)return{result:r.end-r.duration,precise:!0}}for(;n--;){if(r=e.segments[n],"undefined"!=typeof r.end)return{result:i+r.end,precise:!0};if(i+=r.duration,"undefined"!=typeof r.start)return{result:i+r.start,precise:!0}}return{result:i,precise:!1}},u=function(e,t){for(var i=0,n=undefined,r=t-e.mediaSequence;ri){var r=[i,t];t=r[0],i=r[1]}if(t<0){for(var a=t;a0)for(r=i-1;r>=0;r--)if(a=e.segments[r],(o+=y(a.duration))>0)return{mediaIndex:r,startTime:n-f(e,i,r)};return{mediaIndex:0,startTime:t}}if(i<0){for(r=i;r<0;r++)if((o-=e.targetDuration)<0)return{mediaIndex:0,startTime:t};i=0}for(r=i;rDate.now()};i.isBlacklisted=v;var b=function(e){var t=v(e);return!e.disabled&&!t};i.isEnabled=b;var T=function(e){for(var t=0;t=t})},d=function(e,t){return o(e,function(e){return e-1/30>=t})},l=function(e){if(e.length<2)return a["default"].createTimeRanges();for(var t=[],i=1;i=r};if(e)for(i=0;i "+e.end(i));return t.join(", ")},g=function(e,t){var i=arguments.length<=2||arguments[2]===undefined?1:arguments[2];return((e.length?e.end(e.length-1):0)-t)/i};i["default"]={findRange:u,findNextRange:d,findGaps:l,findSoleUncommonTimeRangesEnd:f,getSegmentBufferedPercent:p,TIME_FUDGE_FACTOR:1/30,printableRange:m,timeUntilRebuffer:g},t.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],12:[function(e,t,i){(function(e){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,r=function(e){return e&&e.__esModule?e:{"default":e}}(n),a={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_)}},s=function u(e,t){var i=0,n=0,s=r["default"].mergeOptions(a,t);e.ready(function(){e.trigger({type:"usage",name:"hls-error-reload-initialized"})});var o=function(){n&&e.currentTime(n)},d=function(t){null!==t&&t!==undefined&&(n=e.duration()!==Infinity&&e.currentTime()||0,e.one("loadedmetadata",o),e.src(t),e.trigger({type:"usage",name:"hls-error-reload"}),e.play())},l=function(){return Date.now()-i<1e3*s.errorInterval?void e.trigger({type:"usage",name:"hls-error-reload-canceled"}):s.getSource&&"function"==typeof s.getSource?(i=Date.now(),s.getSource.call(e,d)):void r["default"].log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")},f=function h(){e.off("loadedmetadata",o),e.off("error",l),e.off("dispose",h)},c=function(t){f(),u(e,t)};e.on("error",l),e.on("dispose",f),e.reloadSourceOnError=c},o=function(e){s(this,e)};i["default"]=o,t.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=e(10),a=function(e,t,i,n){var a=e.master.playlists[t],s=(0,r.isBlacklisted)(a),o=(0,r.isEnabled)(a);return void 0===n?o:(n?delete a.disabled:a.disabled=!0,n===o||s||(i(),n?e.trigger("renditionenabled"):e.trigger("renditiondisabled")),n)},s=function u(e,t,i){n(this,u);var r=e.masterPlaylistController_.fastQualityChange_.bind(e.masterPlaylistController_);if(t.attributes.RESOLUTION){var s=t.attributes.RESOLUTION;this.width=s.width,this.height=s.height}this.bandwidth=t.attributes.BANDWIDTH,this.id=i,this.enabled=a.bind(this,e.playlists,t.uri,r)},o=function(e){var t=e.playlists;e.representations=function(){return t.master.playlists.filter(function(e){return!(0,r.isBlacklisted)(e)}).map(function(t,i){return new s(e,t,t.uri)})}};i["default"]=o,t.exports=i["default"]},{}],14:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(i,"__esModule",{value:!0});var r=e(62),a=n(r),s=e(31),o=n(s),u=function(e,t){return/^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=a["default"].buildAbsoluteURL(o["default"].location.href,e)),a["default"].buildAbsoluteURL(e,t))};i["default"]=u,t.exports=i["default"]},{}],15:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i"))}return s(t,e),o(t,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_()}},{key:"abort",value:function(){if("WAITING"!==this.state)return void(this.pendingSegment_&&(this.pendingSegment_=null));this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(e){return void 0!==e&&(this.error_=e),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():c["default"].createTimeRanges()}},{key:"initSegment",value:function(e){var t=!(arguments.length<=1||arguments[1]===undefined)&&arguments[1];if(!e)return null;var i=(0,T.initSegmentId)(e),n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes}),n||e}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&"INIT"===this.state)&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new p["default"](this.mediaSource_,this.mimeType_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(e){var t=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];if(e){var i=this.playlist_,n=this.pendingSegment_;if(this.playlist_=e,this.xhrOptions_=t,this.hasPlayed_()||(e.syncInfo={mediaSequence:e.mediaSequence,time:0}),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();if(!i||i.uri!==e.uri)return void(null!==this.mediaIndex&&this.resyncLoader());var r=e.mediaSequence-i.mediaSequence;this.logger_("mediaSequenceDiff",r),null!==this.mediaIndex&&(this.mediaIndex-=r),n&&(n.mediaIndex-=r,n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(i,e)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(_["default"].clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return null===this.checkBufferTimeout_}},{key:"mimeType",value:function(e){this.mimeType_||(this.mimeType_=e,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_()),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(e,t){this.sourceUpdater_&&this.sourceUpdater_.remove(e,t),(0,b["default"])(e,t,this.segmentMetadataTrack_)}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&_["default"].clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=_["default"].setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&_["default"].clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=_["default"].setTimeout(this.monitorBufferTick_.bind(this),500)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_())) -;var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(e){if(O(this.playlist_,this.mediaSource_,e.mediaIndex))return void this.endOfStream();(e.mediaIndex!==this.playlist_.segments.length-1||"ended"!==this.mediaSource_.readyState||this.seeking_())&&((e.timeline!==this.currentTimeline_||null!==e.startOfSegment&&e.startOfSegment=this.goalBufferLength_())return null;if(!n&&u>=1)return null;if(this.logger_("checkBuffer_","mediaIndex:",i,"hasPlayed:",n,"currentTime:",r,"syncPoint:",a,"fetchAtBuffer:",this.fetchAtBuffer_,"bufferedTime:",u),null===a)return i=this.getSyncSegmentCandidate_(t),this.logger_("getSync","mediaIndex:",i),this.generateSegmentInfo_(t,i,null,!0);if(null!==i){this.logger_("walkForward","mediaIndex:",i+1);var d=t.segments[i];return o=d&&d.end?d.end:s,this.generateSegmentInfo_(t,i+1,o,!1)}if(this.fetchAtBuffer_){var f=l["default"].getMediaInfoForTime(t,s,a.segmentIndex,a.time);i=f.mediaIndex,o=f.startTime}else{var f=l["default"].getMediaInfoForTime(t,r,a.segmentIndex,a.time);i=f.mediaIndex,o=f.startTime}return this.logger_("getMediaIndexForTime","mediaIndex:",i,"startOfSegment:",o),this.generateSegmentInfo_(t,i,o,!1)}},{key:"getSyncSegmentCandidate_",value:function(e){var t=this;if(-1===this.currentTimeline_)return 0;var i=e.segments.map(function(e,t){return{timeline:e.timeline,segmentIndex:t}}).filter(function(e){return e.timeline===t.currentTimeline_});return i.length?i[Math.min(i.length-1,1)].segmentIndex:Math.max(e.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(e,t,i,n){if(t<0||t>=e.segments.length)return null;var r=e.segments[t];return{requestId:"segment-loader-"+Math.random(),uri:r.resolvedUri,mediaIndex:t,isSyncRequest:n,startOfSegment:i,playlist:e,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:r.timeline,duration:r.duration,segment:r}}},{key:"abortRequestEarly_",value:function(e){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return!1;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return!1;var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=l["default"].estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),a=(0,w.timeUntilRebuffer)(this.buffered_(),t,this.hls_.tech_.playbackRate())-1;if(r<=a)return!1;var s=(0,k.minRebufferMaxBandwidthSelector)({master:this.hls_.playlists.master,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(s){var o=r-a,u=o-s.rebufferingImpact,d=.5;return a<=w.TIME_FUDGE_FACTOR&&(d=1),!s.playlist||s.playlist.uri===this.playlist_.uri||u0&&t.start(0)0&&this.remove(0,n)}},{key:"createSimplifiedSegmentObj_",value:function(e){var t=e.segment,i={resolvedUri:t.resolvedUri,byterange:t.byterange,requestId:e.requestId};if(t.key){var n=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key={resolvedUri:t.key.resolvedUri,iv:n}}return t.map&&(i.map=this.initSegment(t.map)),i}},{key:"segmentRequestFinished_",value:function(e,t){if(this.mediaRequests+=1,t.stats&&(this.mediaBytesTransferred+=t.stats.bytesReceived,this.mediaTransferDuration+=t.stats.roundTripTime),!this.pendingSegment_)return void(this.mediaRequestsAborted+=1);if(t.requestId===this.pendingSegment_.requestId){if(e)return this.pendingSegment_=null,this.state="READY",e.code===S.REQUEST_ERRORS.ABORTED?void(this.mediaRequestsAborted+=1):(this.pause(),e.code===S.REQUEST_ERRORS.TIMEOUT?(this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,void this.trigger("bandwidthupdate")):(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error")));this.bandwidth=t.stats.bandwidth,this.roundTrip=t.stats.roundTripTime,t.map&&(t.map=this.initSegment(t.map,!0)),this.processSegmentResponse_(t)}}},{key:"processSegmentResponse_",value:function(e){var t=this.pendingSegment_;t.bytes=e.bytes,e.map&&(t.segment.map.bytes=e.map.bytes),t.endOfAllRequests=e.endOfAllRequests,this.handleSegment_()}},{key:"handleSegment_",value:function(){var e=this;if(!this.pendingSegment_)return void(this.state="READY");this.state="APPENDING";var t=this.pendingSegment_,i=t.segment;if(this.syncController_.probeSegmentInfo(t),t.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");null!==t.timestampOffset&&t.timestampOffset!==this.sourceUpdater_.timestampOffset()&&(this.sourceUpdater_.timestampOffset(t.timestampOffset),this.trigger("timestampoffset")),i.map&&function(){var t=(0,T.initSegmentId)(i.map);if(!e.activeInitSegmentId_||e.activeInitSegmentId_!==t){var n=e.initSegment(i.map);e.sourceUpdater_.appendBuffer(n.bytes,function(){e.activeInitSegmentId_=t})}}(),t.byteLength=t.bytes.byteLength,"number"==typeof i.start&&"number"==typeof i.end?this.mediaSecondsLoaded+=i.end-i.start:this.mediaSecondsLoaded+=i.duration,this.sourceUpdater_.appendBuffer(t.bytes,this.handleUpdateEnd_.bind(this))}},{key:"handleUpdateEnd_",value:function(){if(this.logger_("handleUpdateEnd_","segmentInfo:",this.pendingSegment_),!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_,t=e.segment,i=null!==this.mediaIndex;if(this.pendingSegment_=null,this.recordThroughput_(e),this.addSegmentMetadataCue_(e),this.state="READY",this.mediaIndex=e.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate"),t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration)return void this.resetEverything();i&&this.trigger("bandwidthupdate"),this.trigger("progress"),O(e.playlist,this.mediaSource_,e.mediaIndex+1)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(e){var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}},{key:"logger_",value:function(){}},{key:"addSegmentMetadataCue_",value:function(e){if(this.segmentMetadataTrack_){var t=e.segment,i=t.start,n=t.end;if(E(i)&&E(n)){(0,b["default"])(i,n,this.segmentMetadataTrack_);var r=_["default"].WebKitDataCue||_["default"].VTTCue,a={uri:e.uri,timeline:e.timeline,playlist:e.playlist.uri,start:i,end:n},s=JSON.stringify(a),o=new r(i,n,s);o.value=a,this.segmentMetadataTrack_.addCue(o)}}}}]),t}(c["default"].EventTarget);i["default"]=A,t.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],16:[function(e,t,i){(function(e){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i=l)&&(o=l,s={time:d.start,segmentIndex:u})}}return s}},{name:"Discontinuity",run:function(e,t,i,n,r){var a=null;if(r=r||0,t.discontinuityStarts&&t.discontinuityStarts.length)for(var s=null,o=0;o=f)&&(s=f,a={time:l.time,segmentIndex:u})}}return a}},{name:"Playlist",run:function(e,t,i,n,r){if(t.syncInfo){return{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence}}return null}}];i.syncPointStrategies=p;var m=function(e){function t(){var e=arguments.length<=0||arguments[0]===undefined?{}:arguments[0];r(this,t),o(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.inspectCache_=undefined,this.timelines=[],this.discontinuities=[],this.datetimeToDisplayTime=null,e.debug&&(this.logger_=h["default"].log.bind(h["default"],"sync-controller ->"))}return a(t,e),s(t,[{key:"getSyncPoint",value:function(e,t,i,n){var r=this.runStrategies_(e,t,i,n);return r.length?this.selectSyncPoint_(r,{key:"time",value:n}):null}},{key:"getExpiredTime",value:function(e,t){if(!e||!e.segments)return null;var i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;var n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+(0,f.sumDurations)(e,n.segmentIndex,0))}},{key:"runStrategies_",value:function(e,t,i,n){for(var r=[],a=0;a:",o))}return r}},{key:"selectSyncPoint_",value:function(e,t){for(var i=e[0].syncPoint,n=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy,a=1;a chosen: ",i),i}},{key:"saveExpiredSegmentInfo",value:function(e,t){for(var i=t.mediaSequence-e.mediaSequence,n=i-1;n>=0;n--){var r=e.segments[n];if(r&&"undefined"!=typeof r.start){t.syncInfo={mediaSequence:e.mediaSequence+n,time:r.start},this.logger_("playlist sync:",t.syncInfo),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(e){if(!this.datetimeToDisplayTime&&e.dateTimeObject){var t=e.dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-t}}},{key:"reset",value:function(){this.inspectCache_=undefined}},{key:"probeSegmentInfo",value:function(e){var t=e.segment,i=undefined;(i=t.map?this.probeMp4Segment_(e):this.probeTsSegment_(e))&&this.calculateSegmentTimeMapping_(e,i)&&this.saveDiscontinuitySyncInfo_(e)}},{key:"probeMp4Segment_",value:function(e){var t=e.segment,i=d["default"].timescale(t.map.bytes),n=d["default"].startTime(i,e.bytes);return null!==e.timestampOffset&&(e.timestampOffset-=n),{start:n,end:n+t.duration}}},{key:"probeTsSegment_",value:function(e){var t=(0,l.inspect)(e.bytes,this.inspectCache_),i=undefined,n=undefined;return t?(t.video&&2===t.video.length?(this.inspectCache_=t.video[1].dts,i=t.video[0].dtsTime,n=t.video[1].dtsTime):t.audio&&2===t.audio.length&&(this.inspectCache_=t.audio[1].dts,i=t.audio[0].dtsTime,n=t.audio[1].dtsTime),{start:i,end:n}):null}},{key:"timestampOffsetForTimeline",value:function(e){return"undefined"==typeof this.timelines[e]?null:this.timelines[e].time}},{key:"calculateSegmentTimeMapping_",value:function(e,t){var i=e.segment,n=this.timelines[e.timeline];if(null!==e.timestampOffset)this.logger_("tsO:",e.timestampOffset),n={time:e.startOfSegment,mapping:e.startOfSegment-t.start},this.timelines[e.timeline]=n,this.trigger("timestampoffset"),i.start=e.startOfSegment,i.end=t.end+n.mapping;else{if(!n)return!1;i.start=t.start+n.mapping,i.end=t.end+n.mapping}return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(e){var t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts.length)for(var n=0;no){var u=undefined;u=s<0?i.start-(0,f.sumDurations)(t,e.mediaIndex,r):i.end+(0,f.sumDurations)(t,e.mediaIndex+1,r),this.discontinuities[a]={time:u,accuracy:o}}}}},{key:"logger_",value:function(){}}]),t}(h["default"].EventTarget);i["default"]=m}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],18:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(){var e=arguments.length<=0||arguments[0]===undefined?"":arguments[0],t={codecCount:0},i=undefined;return t.codecCount=e.split(",").length,t.codecCount=t.codecCount||2,i=/(^|\s|,)+(avc1)([^ ,]*)/i.exec(e),i&&(t.videoCodec=i[2],t.videoObjectTypeIndicator=i[3]),t.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(e),t.audioProfile=t.audioProfile&&t.audioProfile[2],t};i.parseCodecs=n},{}],19:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i>7))^a]=a;for(s=o=0;!n[s];s^=l||1,o=d[o]||1)for(h=o^o<<1^o<<2^o<<3^o<<4,h=h>>8^255&h^99,n[s]=h,r[h]=s,c=u[f=u[l=u[s]]],m=16843009*c^65537*f^257*l^16843008*s,p=257*u[h]^16843008*h,a=0;a<4;a++)t[a][s]=p=p<<24^p>>>8,i[a][h]=m=m<<24^m>>>8;for(a=0;a<5;a++)t[a]=t[a].slice(0),i[a]=i[a].slice(0);return e},s=null,o=function(){function e(t){n(this,e),s||(s=a()),this._tables=[[s[0][0].slice(),s[0][1].slice(),s[0][2].slice(),s[0][3].slice(),s[0][4].slice()],[s[1][0].slice(),s[1][1].slice(),s[1][2].slice(),s[1][3].slice(),s[1][4].slice()]];var i=undefined,r=undefined,o=undefined,u=undefined,d=undefined,l=this._tables[0][4],f=this._tables[1],c=t.length,h=1;if(4!==c&&6!==c&&8!==c)throw new Error("Invalid aes key size");for(u=t.slice(0),d=[],this._key=[u,d],i=c;i<4*c+28;i++)o=u[i-1],(i%c==0||8===c&&i%c==4)&&(o=l[o>>>24]<<24^l[o>>16&255]<<16^l[o>>8&255]<<8^l[255&o],i%c==0&&(o=o<<8^o>>>24^h<<24,h=h<<1^283*(h>>7))),u[i]=u[i-c]^o;for(r=0;i;r++,i--)o=u[3&r?i:i-4],d[r]=i<=4||r<4?o:f[0][l[o>>>24]]^f[1][l[o>>16&255]]^f[2][l[o>>8&255]]^f[3][l[255&o]]}return r(e,[{key:"decrypt",value:function(e,t,i,n,r,a){var s=this._key[1],o=e^s[0],u=n^s[1],d=i^s[2],l=t^s[3],f=undefined,c=undefined,h=undefined,p=s.length/4-2,m=undefined,g=4,y=this._tables[1],_=y[0],v=y[1],b=y[2],T=y[3],S=y[4];for(m=0;m>>24]^v[u>>16&255]^b[d>>8&255]^T[255&l]^s[g],c=_[u>>>24]^v[d>>16&255]^b[l>>8&255]^T[255&o]^s[g+1],h=_[d>>>24]^v[l>>16&255]^b[o>>8&255]^T[255&u]^s[g+2],l=_[l>>>24]^v[o>>16&255]^b[u>>8&255]^T[255&d]^s[g+3],g+=4,o=f,u=c,d=h;for(m=0;m<4;m++)r[(3&-m)+a]=S[o>>>24]<<24^S[u>>16&255]<<16^S[d>>8&255]<<8^S[255&l]^s[g++],f=o,o=u,u=d,d=l,l=f}}]),e}();i["default"]=o,t.exports=i["default"]},{}],22:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i>8|e>>>24},c=function(e,t,i){var n=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),r=new o["default"](Array.prototype.slice.call(t)),a=new Uint8Array(e.byteLength),s=new Int32Array(a.buffer),u=undefined,d=undefined,l=undefined,c=undefined,h=undefined,p=undefined,m=undefined,g=undefined,y=undefined;for(u=i[0],d=i[1],l=i[2],c=i[3],y=0;y-1)}},{key:"trigger",value:function(e){var t=undefined,i=undefined,n=undefined,r=undefined;if(t=this.listeners[e])if(2===arguments.length)for(n=t.length,i=0;i-1;t=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}]),t}(u["default"]);i["default"]=d},{}],34:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var s=function(){function e(e,t){var i=[],n=!0,r=!1,a=undefined;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done)&&(i.push(s.value),!t||i.length!==t);n=!0);}catch(u){r=!0,a=u}finally{try{!n&&o["return"]&&o["return"]()}finally{if(r)throw a}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,t){for(var i=0;i0&&(s.duration=e.duration),0===e.duration&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=n},key:function(){return e.attributes?"NONE"===e.attributes.METHOD?void(d=null):e.attributes.URI?(e.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),d={method:e.attributes.METHOD||"AES-128",uri:e.attributes.URI},void("undefined"!=typeof e.attributes.IV&&(d.iv=e.attributes.IV))):void this.trigger("warn",{message:"ignoring key declaration without URI"}):void this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){if(!isFinite(e.number))return void this.trigger("warn",{message:"ignoring invalid media sequence: "+e.number});this.manifest.mediaSequence=e.number},"discontinuity-sequence":function(){if(!isFinite(e.number))return void this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+e.number});this.manifest.discontinuitySequence=e.number,h=e.number},"playlist-type":function(){if(!/VOD|EVENT/.test(e.playlistType))return void this.trigger("warn",{message:"ignoring unknown playlist type: "+e.playlist});this.manifest.playlistType=e.playlistType},map:function(){u={},e.uri&&(u.uri=e.uri),e.byterange&&(u.byterange=e.byterange)},"stream-inf":function(){if(this.manifest.playlists=n,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!e.attributes)return void this.trigger("warn",{message:"ignoring empty stream-inf attributes"});s.attributes||(s.attributes={}),o(s.attributes,e.attributes)},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(e.attributes&&e.attributes.TYPE&&e.attributes["GROUP-ID"]&&e.attributes.NAME))return void this.trigger("warn",{message:"ignoring incomplete or missing media group"});var i=this.manifest.mediaGroups[e.attributes.TYPE];i[e.attributes["GROUP-ID"]]=i[e.attributes["GROUP-ID"]]||{},t=i[e.attributes["GROUP-ID"]],r={"default":/yes/i.test(e.attributes.DEFAULT)},r["default"]?r.autoselect=!0:r.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(r.language=e.attributes.LANGUAGE),e.attributes.URI&&(r.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(r.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(r.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(r.forced=/yes/i.test(e.attributes.FORCED)),t[e.attributes.NAME]=r},discontinuity:function(){h+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(n.length)},"program-date-time":function(){this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject},targetduration:function(){if(!isFinite(e.duration)||e.duration<0)return void this.trigger("warn",{message:"ignoring invalid target duration: "+e.duration});this.manifest.targetDuration=e.duration},totalduration:function(){if(!isFinite(e.duration)||e.duration<0)return void this.trigger("warn",{message:"ignoring invalid total duration: "+e.duration});this.manifest.totalDuration=e.duration},"cue-out":function(){s.cueOut=e.data},"cue-out-cont":function(){s.cueOutCont=e.data},"cue-in":function(){s.cueIn=e.data}})[e.tagType]||l).call(i)},uri:function(){s.uri=e.uri,n.push(s),!this.manifest.targetDuration||"duration"in s||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),d&&(s.key=d),s.timeline=h,u&&(s.map=u),s={}},comment:function(){}})[e.type].call(i)}),e}return s(t,e),u(t,[{key:"push",value:function(e){this.lineStream.push(e)}},{key:"end",value:function(){this.lineStream.push("\n")}}]),t}(l["default"]);i["default"]=m},{}],36:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i-1}},{key:"trigger",value:function(e){var t=this.listeners[e],i=void 0,n=void 0,r=void 0;if(t)if(2===arguments.length)for(n=t.length,i=0;i>4?i+20:i+10},this.parseAdtsSize=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i},this.push=function(i){var n,r,a,s,o=0,u=0;for(e.length?(s=e.length,e=new Uint8Array(i.byteLength+s),e.set(e.subarray(0,s)),e.set(i,s)):e=i;e.length-u>=3;)if(e[u]!=="I".charCodeAt(0)||e[u+1]!=="D".charCodeAt(0)||e[u+2]!=="3".charCodeAt(0))if(!0&e[u]&&240==(240&e[u+1])){if(e.length-u<7)break;if((o=this.parseAdtsSize(e,u))>e.length)break;a={type:"audio",data:e.subarray(u,u+o),pts:t,dts:t},this.trigger("data",a),u+=o}else u++;else{if(e.length-u<10)break;if((o=this.parseId3TagSize(e,u))>e.length)break;r={type:"timed-metadata",data:e.subarray(u,u+o)},this.trigger("data",r),u+=o}n=e.length-u,e=n>0?e.subarray(u):new Uint8Array}},n.prototype=new r,t.exports=n},{}],38:[function(e,t,i){"use strict";var n=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},a=function(e,t,i){var n,r="";for(n=t;n>4?i+20:i+10},u=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i},d=function(e,t){return e[t]==="I".charCodeAt(0)&&e[t+1]==="D".charCodeAt(0)&&e[t+2]==="3".charCodeAt(0)?"timed-metadata":!0&e[t]&&240==(240&e[t+1])?"audio":null},l=function(e){for(var t=0;t+5>>2];t++}return null},f=function(e){var t,i,n;t=10,64&e[5]&&(t+=4,t+=r(e.subarray(10,14)));do{if((i=r(e.subarray(t+4,t+8)))<1)return null;if("PRIV"===String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3])){n=e.subarray(t+10,t+i+10);for(var a=0;a>>2;return d*=4,d+=3&u[7]}break}}t+=10,t+=i}while(t>5,o=1024*(1+(3&e[d+6])),u=9e4*o/a[(60&e[d+2])>>>2],r=d+i,e.byteLength>>6&3),channelcount:(1&e[d+2])<<2|(192&e[d+3])>>>6,samplerate:a[(60&e[d+2])>>>2],samplingfrequencyindex:(60&e[d+2])>>>2,samplesize:16,data:e.subarray(d+7+n,r)}),e.byteLength===r)return void(e=undefined);l++,e=e.subarray(r)}else d++},this.flush=function(){this.trigger("done")}},n.prototype=new r,t.exports=n},{}],40:[function(e,t,i){"use strict";var n,r,a,s=e(61),o=e(60);r=function(){var e,t,i=0;r.prototype.init.call(this),this.push=function(n){var r;for(t?(r=new Uint8Array(t.byteLength+n.data.byteLength),r.set(t),r.set(n.data,t.byteLength),t=r):t=n.data;i3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done")}},r.prototype=new s,a={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},n=function(){var e,t,i,s,u,d,l,f=new r;n.prototype.init.call(this),e=this,this.push=function(e){"video"===e.type&&(t=e.trackId,i=e.pts,s=e.dts,f.push(e))},f.on("data",function(n){var r={trackId:t,pts:i,dts:s,data:n};switch(31&n[0]){case 5:r.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:r.nalUnitType="sei_rbsp",r.escapedRBSP=u(n.subarray(1));break;case 7:r.nalUnitType="seq_parameter_set_rbsp",r.escapedRBSP=u(n.subarray(1)),r.config=d(r.escapedRBSP);break;case 8:r.nalUnitType="pic_parameter_set_rbsp";break;case 9:r.nalUnitType="access_unit_delimiter_rbsp"}e.trigger("data",r)}),f.on("done",function(){e.trigger("done")}),this.flush=function(){f.flush()},l=function(e,t){var i,n,r=8,a=8;for(i=0;i0)throw new Error("Attempted to create new NAL wihout closing the old one");r=this.length,this.length+=4,this.position=this.length},this.endNalUnit=function(e){var t,i;this.length===r+4?this.length-=4:r>0&&(t=r+4,i=this.length-t,this.position=r,this.view.setUint32(this.position,i),this.position=this.length,e&&e.push(this.bytes.subarray(t,t+i))),r=0},this.writeMetaDataDouble=function(e,t){var i;if(s(this,2+e.length+9),this.view.setUint16(this.position,e.length),this.position+=2,"width"===e)this.bytes.set(o,this.position),this.position+=5;else if("height"===e)this.bytes.set(u,this.position),this.position+=6;else if("videocodecid"===e)this.bytes.set(d,this.position),this.position+=12;else for(i=0;i>>16,this.bytes[14]=(65280&e)>>>8,this.bytes[15]=(255&e)>>>0;break;case n.AUDIO_TAG:this.bytes[11]=175,this.bytes[12]=t?0:1;break;case n.METADATA_TAG:this.position=11,this.view.setUint8(this.position,2),this.position++,this.view.setUint16(this.position,10),this.position+=2,this.bytes.set([111,110,77,101,116,97,68,97,116,97],this.position),this.position+=10,this.bytes[this.position]=8,this.position++,this.view.setUint32(this.position,r),this.position=this.length,this.bytes.set([0,0,9],this.position),this.position+=3,this.length=this.position}return i=this.length-11,this.bytes[1]=(16711680&i)>>>16,this.bytes[2]=(65280&i)>>>8,this.bytes[3]=(255&i)>>>0,this.bytes[4]=(16711680&this.dts)>>>16,this.bytes[5]=(65280&this.dts)>>>8,this.bytes[6]=(255&this.dts)>>>0,this.bytes[7]=(4278190080&this.dts)>>>24,this.bytes[8]=0,this.bytes[9]=0,this.bytes[10]=0,s(this,4),this.view.setUint32(this.length,this.length),this.length+=4,this.position+=4,this.bytes=this.bytes.subarray(0,this.length),this.frameTime=n.frameTime(this.bytes),this}},n.AUDIO_TAG=8,n.VIDEO_TAG=9,n.METADATA_TAG=18,n.isAudioFrame=function(e){return n.AUDIO_TAG===e[0]},n.isVideoFrame=function(e){return n.VIDEO_TAG===e[0]},n.isMetaData=function(e){return n.METADATA_TAG===e[0]},n.isKeyFrame=function(e){return n.isVideoFrame(e)?23===e[11]:!!n.isAudioFrame(e)||!!n.isMetaData(e)},n.frameTime=function(e){var t=e[4]<<16;return t|=e[5]<<8,t|=e[6]<<0,t|=e[7]<<24},t.exports=n},{}],45:[function(e,t,i){t.exports={tag:e(44),Transmuxer:e(47),getFlvHeader:e(43)}},{}],46:[function(e,t,i){"use strict";var n=function(){var e=this;this.list=[],this.push=function(e){this.list.push({bytes:e.bytes,dts:e.dts,pts:e.pts,keyFrame:e.keyFrame,metaDataTag:e.metaDataTag})},Object.defineProperty(this,"length",{get:function(){return e.list.length}})};t.exports=n},{}],47:[function(e,t,i){"use strict";var n,r,a,s,o,u,d=e(61),l=e(44),f=e(49),c=e(39),h=e(40).H264Stream,p=e(42),m=e(46);s=function(e,t){"number"==typeof t.pts&&(e.timelineStartInfo.pts===undefined?e.timelineStartInfo.pts=t.pts:e.timelineStartInfo.pts=Math.min(e.timelineStartInfo.pts,t.pts)),"number"==typeof t.dts&&(e.timelineStartInfo.dts===undefined?e.timelineStartInfo.dts=t.dts:e.timelineStartInfo.dts=Math.min(e.timelineStartInfo.dts,t.dts))},o=function(e,t){var i=new l(l.METADATA_TAG);return i.dts=t,i.pts=t,i.writeMetaDataDouble("videocodecid",7),i.writeMetaDataDouble("width",e.width),i.writeMetaDataDouble("height",e.height),i},u=function(e,t){var i,n=new l(l.VIDEO_TAG,!0);for(n.dts=t,n.pts=t,n.writeByte(1),n.writeByte(e.profileIdc),n.writeByte(e.profileCompatibility),n.writeByte(e.levelIdc),n.writeByte(255),n.writeByte(225),n.writeShort(e.sps[0].length),n.writeBytes(e.sps[0]),n.writeByte(e.pps.length),i=0;i=n[0]&&(s=n.shift(),this.writeMetaDataTags(o,s)),(e.extraData!==t||r.pts-s>=1e3)&&(this.writeMetaDataTags(o,r.pts),t=e.extraData,s=r.pts),a=new l(l.AUDIO_TAG),a.pts=r.pts,a.dts=r.dts,a.writeBytes(r.data),o.push(a.finalize());n.length=0,t=null,this.trigger("data",{track:e,tags:o.list}),this.trigger("done","AudioSegmentStream")},this.writeMetaDataTags=function(t,i){var n;n=new l(l.METADATA_TAG),n.pts=i,n.dts=i,n.writeMetaDataDouble("audiocodecid",10),n.writeMetaDataBoolean("stereo",2===e.channelcount),n.writeMetaDataDouble("audiosamplerate",e.samplerate),n.writeMetaDataDouble("audiosamplesize",16),t.push(n.finalize()),n=new l(l.AUDIO_TAG,!0),n.pts=i,n.dts=i,n.view.setUint16(n.position,e.extraData),n.position+=2,n.length=Math.max(n.length,n.position),t.push(n.finalize())},this.onVideoKeyFrame=function(e){n.push(e)}},a.prototype=new d,r=function(e){var t,i,n=[];r.prototype.init.call(this),this.finishFrame=function(n,r){if(r){if(t&&e&&e.newMetadata&&(r.keyFrame||0===n.length)){var a=o(t,r.dts).finalize(),s=u(e,r.dts).finalize();a.metaDataTag=s.metaDataTag=!0,n.push(a),n.push(s),e.newMetadata=!1,this.trigger("keyframe",r.dts)}r.endNalUnit(),n.push(r.finalize()),i=null}},this.push=function(t){s(e,t),t.pts=Math.round(t.pts/90),t.dts=Math.round(t.dts/90),n.push(t)},this.flush=function(){for(var r,a=new m;n.length&&"access_unit_delimiter_rbsp"!==n[0].nalUnitType;)n.shift();if(0===n.length)return void this.trigger("done","VideoSegmentStream");for(;n.length;)r=n.shift(),"seq_parameter_set_rbsp"===r.nalUnitType?(e.newMetadata=!0,t=r.config,e.width=t.width,e.height=t.height,e.sps=[r.data],e.profileIdc=t.profileIdc,e.levelIdc=t.levelIdc,e.profileCompatibility=t.profileCompatibility,i.endNalUnit()):"pic_parameter_set_rbsp"===r.nalUnitType?(e.newMetadata=!0,e.pps=[r.data],i.endNalUnit()):"access_unit_delimiter_rbsp"===r.nalUnitType?(i&&this.finishFrame(a,i),i=new l(l.VIDEO_TAG),i.pts=r.pts,i.dts=r.dts):("slice_layer_without_partitioning_rbsp_idr"===r.nalUnitType&&(i.keyFrame=!0),i.endNalUnit()),i.startNalUnit(),i.writeBytes(r.data);i&&this.finishFrame(a,i),this.trigger("data",{track:e,tags:a.list}),this.trigger("done","VideoSegmentStream")}},r.prototype=new d,n=function(e){var t,i,s,o,u,d,l,m,g,y,_,v,b=this;n.prototype.init.call(this),e=e||{},this.metadataStream=new f.MetadataStream,e.metadataStream=this.metadataStream,t=new f.TransportPacketStream,i=new f.TransportParseStream,s=new f.ElementaryStream,o=new f.TimestampRolloverStream("video"),u=new f.TimestampRolloverStream("audio"),d=new f.TimestampRolloverStream("timed-metadata"),l=new c,m=new h,v=new p(e),t.pipe(i).pipe(s),s.pipe(o).pipe(m),s.pipe(u).pipe(l),s.pipe(d).pipe(this.metadataStream).pipe(v),_=new f.CaptionStream,m.pipe(_).pipe(v),s.on("data",function(e){var t,i,n;if("metadata"===e.type){for(t=e.tracks.length;t--;)"video"===e.tracks[t].type?i=e.tracks[t]:"audio"===e.tracks[t].type&&(n=e.tracks[t]);i&&!g&&(v.numberOfTracks++,g=new r(i),m.pipe(g).pipe(v)),n&&!y&&(v.numberOfTracks++,y=new a(n),l.pipe(y).pipe(v),g&&g.on("keyframe",y.onVideoKeyFrame))}}),this.push=function(e){t.push(e)},this.flush=function(){t.flush()},this.resetCaptions=function(){_.reset()},v.on("data",function(e){b.trigger("data",e)}),v.on("done",function(){b.trigger("done")})},n.prototype=new d,t.exports=n},{}],48:[function(e,t,i){"use strict";var n=e(61),r=function(e){for(var t=0,i={payloadType:-1,payloadSize:0},n=0,r=0;t>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(t===this.END_OF_CAPTION_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.topRow_=13,this.mode_="rollUp";else if(t===this.ROLL_UP_3_ROWS_)this.topRow_=12,this.mode_="rollUp";else if(t===this.ROLL_UP_4_ROWS_)this.topRow_=11,this.mode_="rollUp";else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[14]=this.nonDisplayed_[14].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=c();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=c();else if(t===this.RESUME_DIRECT_CAPTIONING_)this.mode_="paintOn";else if(this.isSpecialCharacter(n,r))n=(3&n)<<8,a=l(n|r),this[this.mode_](e.pts,a),this.column_++;else if(this.isExtCharacter(n,r))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[14]=this.displayed_[14].slice(0,-1),n=(3&n)<<8,a=l(n|r),this[this.mode_](e.pts,a),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&r)&&this.addFormatting(e.pts,["i"]),1==(1&r)&&this.addFormatting(e.pts,["u"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var s=f.indexOf(7968&t);s!==this.row_&&(this.clearFormatting(e.pts),this.row_=s),1&r&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,["i"])}else this.isNormalChar(n)&&(0===r&&(r=null),a=l(n),a+=l(r),this[this.mode_](e.pts,a),this.column_+=a.length)}};h.prototype=new n,h.prototype.flushDisplayed=function(e){var t=this.displayed_.map(function(e){return e.trim()}).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},h.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=c(),this.nonDisplayed_=c(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.formatting_=[]},h.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},h.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},h.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},h.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},h.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},h.prototype.isPAC=function(e,t){return e>=this.BASE_&&e=64&&t<=127},h.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},h.prototype.isNormalChar=function(e){return e>=32&&e<=127},h.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);var i=t.reduce(function(e,t){return e+"<"+t+">"},"");this[this.mode_](e,i)},h.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce(function(e,t){return e+""},"");this.formatting_=[],this[this.mode_](e,t)}},h.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},h.prototype.rollUp=function(e,t){var i=this.displayed_[14];i+=t,this.displayed_[14]=i},h.prototype.shiftRowsUp_=function(){var e;for(e=0;e>>4>1&&(n+=t[n]+1),0===i.pid?(i.type="pat",e(t.subarray(n),i),this.trigger("data",i)):i.pid===this.pmtPid?(i.type="pmt",e(t.subarray(n),i),this.trigger("data",i)):this.programMapTable===undefined?this.packetsWaitingForPmt.push([t,n,i]):this.processPes_(t,n,i)},this.processPes_=function(e,t,i){i.streamType=this.programMapTable[i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i)}},r.prototype=new s,r.STREAM_TYPES={h264:27,adts:15},a=function(){var e=this,t={data:[],size:0},i={data:[],size:0},n={data:[],size:0},r=function(e,t){var i;t.packetLength=6+(e[4]<<8|e[5]),t.dataAlignmentIndicator=0!=(4&e[6]),i=e[7],192&i&&(t.pts=(14&e[9])<<27|(255&e[10])<<20|(254&e[11])<<12|(255&e[12])<<5|(254&e[13])>>>3,t.pts*=4,t.pts+=(6&e[13])>>>1,t.dts=t.pts,64&i&&(t.dts=(14&e[14])<<27|(255&e[15])<<20|(254&e[16])<<12|(255&e[17])<<5|(254&e[18])>>>3,t.dts*=4,t.dts+=(6&e[18])>>>1)),t.data=e.subarray(9+e[8])},s=function(t,i,n){var a,s=new Uint8Array(t.size),o={type:i},u=0,d=0,l=!1;if(t.data.length&&!(t.size<9)){for(o.trackId=t.data[0].pid,u=0;u>>2;p*=4,p+=3&h[7],u.timeStamp=p,t.pts===undefined&&t.dts===undefined&&(t.pts=u.timeStamp,t.dts=u.timeStamp),this.trigger("timestamp",u)}t.frames.push(u),n+=10,n+=a}while(n>>4>1&&(t+=e[4]+1),t},o=function(e,t){var i=r(e);return 0===i?"pat":i===t?"pmt":t?"pes":null},u=function(e){var t=a(e),i=4+s(e);return t&&(i+=e[i]+1),(31&e[i+10])<<8|e[i+11]},d=function(e){var t={},i=a(e),n=4+s(e);if(i&&(n+=e[n]+1),1&e[n+5]){var r,o,u;r=(15&e[n+1])<<8|e[n+2],o=3+r-4,u=(15&e[n+10])<<8|e[n+11];for(var d=12+u;d=e.byteLength)return null;var i,n=null;return i=e[t+7],192&i&&(n={},n.pts=(14&e[t+9])<<27|(255&e[t+10])<<20|(254&e[t+11])<<12|(255&e[t+12])<<5|(254&e[t+13])>>>3,n.pts*=4,n.pts+=(6&e[t+13])>>>1,n.dts=n.pts,64&i&&(n.dts=(14&e[t+14])<<27|(255&e[t+15])<<20|(254&e[t+16])<<12|(255&e[t+17])<<5|(254&e[t+18])>>>3,n.dts*=4,n.dts+=(6&e[t+18])>>>1)),n},c=function(e){switch(e){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},h=function(e){for(var t,i=4+s(e),n=e.subarray(i),r=0,a=0,o=!1;a3&&"slice_layer_without_partitioning_rbsp_idr"===(t=c(31&n[a+3]))&&(o=!0),o};t.exports={parseType:o,parsePat:u,parsePmt:d,parsePayloadUnitStartIndicator:a,parsePesType:l,parsePesTime:f,videoPacketContainsKeyFrame:h}},{}],52:[function(e,t,i){"use strict";t.exports={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21}},{}],53:[function(e,t,i){"use strict";var n=e(61),r=function(e,t){var i=1;for(e>t&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},a=function(e){var t,i;a.prototype.init.call(this),this.type_=e,this.push=function(e){e.type===this.type_&&(i===undefined&&(i=e.dts),e.dts=r(e.dts,i),e.pts=r(e.pts,i),t=e.dts,this.trigger("data",e))},this.flush=function(){i=t,this.trigger("done")},this.discontinuity=function(){i=void 0,t=void 0}};a.prototype=new n,t.exports={TimestampRolloverStream:a,handleRollover:r}},{}],54:[function(e,t,i){t.exports={generator:e(55),Transmuxer:e(57).Transmuxer,AudioSegmentStream:e(57).AudioSegmentStream,VideoSegmentStream:e(57).VideoSegmentStream}},{}],55:[function(e,t,i){"use strict";var n,r,a,s,o,u,d,l,f,c,h,p,m,g,y,_,v,b,T,S,w,k,O,E,A,L,P,C,I,U,D,x,R,M,B,j,N=Math.pow(2,32)-1;!function(){var e;if(O={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},"undefined"!=typeof Uint8Array){for(e in O)O.hasOwnProperty(e)&&(O[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);E=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),L=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),A=new Uint8Array([0,0,0,1]),P=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),C=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),I={video:P,audio:C},x=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),D=new Uint8Array([0,0,0,0,0,0,0,0]),R=new Uint8Array([0,0,0,0,0,0,0,0]),M=R,B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),j=R,U=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}}(),n=function(e){var t,i,n,r=[],a=0;for(t=1;t>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},s=function(){return n(O.ftyp,E,A,E,L)},_=function(e){return n(O.hdlr,I[e])},o=function(e){return n(O.mdat,e)},y=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(t[12]=e.samplerate>>>24&255,t[13]=e.samplerate>>>16&255,t[14]=e.samplerate>>>8&255,t[15]=255&e.samplerate),n(O.mdhd,t)},g=function(e){return n(O.mdia,y(e),_(e.type),d(e))},u=function(e){return n(O.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},d=function(e){return n(O.minf,"video"===e.type?n(O.vmhd,U):n(O.smhd,D),r(),b(e))},l=function(e,t){for(var i=[],r=t.length;r--;)i[r]=S(t[r]);return n.apply(null,[O.moof,u(e)].concat(i))},f=function(e){for(var t=e.length,i=[];t--;)i[t]=p(e[t]);return n.apply(null,[O.moov,h(4294967295)].concat(i).concat(c(e)))},c=function(e){for(var t=e.length,i=[];t--;)i[t]=w(e[t]);return n.apply(null,[O.mvex].concat(i))},h=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n(O.mvhd,t)},v=function(e){var t,i,r=e.samples||[],a=new Uint8Array(4+r.length);for(i=0;i>>8),a.push(255&i[t].byteLength),a=a.concat(Array.prototype.slice.call(i[t]));for(t=0;t>>8),s.push(255&r[t].byteLength),s=s.concat(Array.prototype.slice.call(r[t]));return n(O.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),n(O.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([i.length]).concat(a).concat([r.length]).concat(s))),n(O.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},t=function(e){return n(O.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),a(e))}}(),m=function(e){var t=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return n(O.tkhd,t)},S=function(e){var t,i,r,a,s,o,u;return t=n(O.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),o=Math.floor(e.baseMediaDecodeTime/(N+1)),u=Math.floor(e.baseMediaDecodeTime%(N+1)),i=n(O.tfdt,new Uint8Array([1,0,0,0,o>>>24&255,o>>>16&255,o>>>8&255,255&o,u>>>24&255,u>>>16&255,u>>>8&255,255&u])),s=92,"audio"===e.type?(r=k(e,s),n(O.traf,t,i,r)):(a=v(e),r=k(e,a.length+s),n(O.traf,t,i,r,a))},p=function(e){return e.duration=e.duration||4294967295,n(O.trak,m(e),g(e))},w=function(e){var t=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==e.type&&(t[t.length-1]=0),n(O.trex,t)},function(){var e,t,i;i=function(e,t){var i=0,n=0,r=0,a=0;return e.length&&(e[0].duration!==undefined&&(i=1),e[0].size!==undefined&&(n=2),e[0].flags!==undefined&&(r=4),e[0].compositionTimeOffset!==undefined&&(a=8)),[0,0,i|n|r|a,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},t=function(e,t){var r,a,s,o;for(a=e.samples||[],t+=20+16*a.length,r=i(a,t),o=0;o>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size,s.flags.isLeading<<2|s.flags.dependsOn,s.flags.isDependedOn<<6|s.flags.hasRedundancy<<4|s.flags.paddingValue<<1|s.flags.isNonSyncSample,61440&s.flags.degradationPriority,15&s.flags.degradationPriority,(4278190080&s.compositionTimeOffset)>>>24,(16711680&s.compositionTimeOffset)>>>16,(65280&s.compositionTimeOffset)>>>8,255&s.compositionTimeOffset]);return n(O.trun,new Uint8Array(r))},e=function(e,t){var r,a,s,o;for(a=e.samples||[],t+=20+8*a.length,r=i(a,t),o=0;o>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size]);return n(O.trun,new Uint8Array(r))},k=function(i,n){return"audio"===i.type?e(i,n):t(i,n)}}(),t.exports={ftyp:s,mdat:o,moof:l,moov:f,initSegment:function(e){var t,i=s(),n=f(e);return t=new Uint8Array(i.byteLength+n.byteLength),t.set(i),t.set(n,i.byteLength),t}}},{}],56:[function(e,t,i){"use strict";var n,r,a,s;n=function(e,t){var i,a,s,o,u,d=[];if(!t.length)return null;for(i=0;i1?i+a:e.byteLength,s===t[0]&&(1===t.length?d.push(e.subarray(i+8,o)):(u=n(e.subarray(i+8,o),t.slice(1)),u.length&&(d=d.concat(u)))),i=o;return d},r=function(e){var t="";return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),t+=String.fromCharCode(e[2]),t+=String.fromCharCode(e[3])},a=function(e){var t={};return n(e,["moov","trak"]).reduce(function(e,t){var i,r,a,s,o;return(i=n(t,["tkhd"])[0])?(r=i[0],a=0===r?12:20,s=i[a]<<24|i[a+1]<<16|i[a+2]<<8|i[a+3],(o=n(t,["mdia","mdhd"])[0])?(r=o[0],a=0===r?12:20,e[s]=o[a]<<24|o[a+1]<<16|o[a+2]<<8|o[a+3],e):null):null},t)},s=function(e,t){var i,r,a;return i=n(t,["moof","traf"]),r=[].concat.apply([],i.map(function(t){return n(t,["tfhd"]).map(function(i){var r,a,s;return r=i[4]<<24|i[5]<<16|i[6]<<8|i[7],a=e[r]||9e4,s=n(t,["tfdt"]).map(function(e){var t,i;return t=e[0],i=e[4]<<24|e[5]<<16|e[6]<<8|e[7],1===t&&(i*=Math.pow(2,32),i+=e[8]<<24|e[9]<<16|e[10]<<8|e[11]),i})[0],(s=s||Infinity)/a})})),a=Math.min.apply(null,r),isFinite(a)?a:0},t.exports={parseType:r,timescale:a,startTime:s}},{}],57:[function(e,t,i){"use strict";var n,r,a,s,o,u,d,l,f,c,h,p=e(61),m=e(55),g=e(49),y=e(39),_=e(40).H264Stream,v=e(37),b=e(41),T=e(59),S=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],w=["width","height","profileIdc","levelIdc","profileCompatibility"];o=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0}}},u=function(e){return e[0]==="I".charCodeAt(0)&&e[1]==="D".charCodeAt(0)&&e[2]==="3".charCodeAt(0)},c=function(e,t){var i;if(e.length!==t.length)return!1;for(i=0;i45e3))){for(n=b[e.samplerate],n||(n=t[0].data),r=0;r=n?t:(e.minSegmentDts=Infinity,t.filter(function(t){return t.dts>=n&&(e.minSegmentDts=Math.min(e.minSegmentDts,t.dts),e.minSegmentPts=e.minSegmentDts,!0)}))},this.generateSampleTable_=function(e){var t,i,n=[];for(t=0;t=-1e4&&i<=45e3&&(!n||o>i)&&(n=a,o=i));return n?n.gop:null},this.extendFirstKeyFrame_=function(e){var t;return!e[0][0].keyFrame&&e.length>1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},this.groupNalsIntoFrames_=function(e){var t,i,n=[],r=[];for(n.byteLength=0,t=0;t=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}for(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,w.forEach(function(e){s.info[e]=this.videoTrack[e]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,S.forEach(function(e){s.info[e]=this.audioTrack[e]},this)),1===this.pendingTracks.length?s.type=this.pendingTracks[0].type:s.type="combined",this.emittedTracks+=this.pendingTracks.length,n=m.initSegment(this.pendingTracks),s.initSegment=new Uint8Array(n.byteLength),s.initSegment.set(n),s.data=new Uint8Array(this.pendingBytes),r=0;r=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},a=function(e){var t,i,o=this,d=!0;a.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var t={};this.transmuxPipeline_=t,t.type="aac",t.metadataStream=new g.MetadataStream,t.aacStream=new v,t.audioTimestampRolloverStream=new g.TimestampRolloverStream("audio"),t.timedMetadataTimestampRolloverStream=new g.TimestampRolloverStream("timed-metadata"),t.adtsStream=new y,t.coalesceStream=new s(e,t.metadataStream),t.headOfPipeline=t.aacStream,t.aacStream.pipe(t.audioTimestampRolloverStream).pipe(t.adtsStream),t.aacStream.pipe(t.timedMetadataTimestampRolloverStream).pipe(t.metadataStream).pipe(t.coalesceStream),t.metadataStream.on("timestamp",function(e){t.aacStream.setTimestamp(e.timeStamp)}),t.aacStream.on("data",function(e){"timed-metadata"!==e.type||t.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:o.baseMediaDecodeTime},codec:"adts",type:"audio"},t.coalesceStream.numberOfTracks++,t.audioSegmentStream=new r(i),t.adtsStream.pipe(t.audioSegmentStream).pipe(t.coalesceStream))}),t.coalesceStream.on("data",this.trigger.bind(this,"data")),t.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var a={};this.transmuxPipeline_=a,a.type="ts",a.metadataStream=new g.MetadataStream,a.packetStream=new g.TransportPacketStream,a.parseStream=new g.TransportParseStream,a.elementaryStream=new g.ElementaryStream,a.videoTimestampRolloverStream=new g.TimestampRolloverStream("video"),a.audioTimestampRolloverStream=new g.TimestampRolloverStream("audio"),a.timedMetadataTimestampRolloverStream=new g.TimestampRolloverStream("timed-metadata"),a.adtsStream=new y,a.h264Stream=new _,a.captionStream=new g.CaptionStream,a.coalesceStream=new s(e,a.metadataStream),a.headOfPipeline=a.packetStream,a.packetStream.pipe(a.parseStream).pipe(a.elementaryStream),a.elementaryStream.pipe(a.videoTimestampRolloverStream).pipe(a.h264Stream),a.elementaryStream.pipe(a.audioTimestampRolloverStream).pipe(a.adtsStream),a.elementaryStream.pipe(a.timedMetadataTimestampRolloverStream).pipe(a.metadataStream).pipe(a.coalesceStream),a.h264Stream.pipe(a.captionStream).pipe(a.coalesceStream),a.elementaryStream.on("data",function(e){var s;if("metadata"===e.type){for(s=e.tracks.length;s--;)t||"video"!==e.tracks[s].type?i||"audio"!==e.tracks[s].type||(i=e.tracks[s],i.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime):(t=e.tracks[s],t.timelineStartInfo.baseMediaDecodeTime=o.baseMediaDecodeTime);t&&!a.videoSegmentStream&&(a.coalesceStream.numberOfTracks++,a.videoSegmentStream=new n(t),a.videoSegmentStream.on("timelineStartInfo",function(e){i&&(i.timelineStartInfo=e,a.audioSegmentStream.setEarliestDts(e.dts))}),a.videoSegmentStream.on("baseMediaDecodeTime",function(e){i&&a.audioSegmentStream.setVideoBaseMediaDecodeTime(e)}),a.h264Stream.pipe(a.videoSegmentStream).pipe(a.coalesceStream)),i&&!a.audioSegmentStream&&(a.coalesceStream.numberOfTracks++,a.audioSegmentStream=new r(i),a.adtsStream.pipe(a.audioSegmentStream).pipe(a.coalesceStream))}}),a.coalesceStream.on("data",this.trigger.bind(this,"data")),a.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(e){var n=this.transmuxPipeline_;this.baseMediaDecodeTime=e,i&&(i.timelineStartInfo.dts=undefined,i.timelineStartInfo.pts=undefined,l(i),i.timelineStartInfo.baseMediaDecodeTime=e,n.audioTimestampRolloverStream&&n.audioTimestampRolloverStream.discontinuity()),t&&(n.videoSegmentStream&&(n.videoSegmentStream.gopCache_=[],n.videoTimestampRolloverStream.discontinuity()),t.timelineStartInfo.dts=undefined,t.timelineStartInfo.pts=undefined,l(t),n.captionStream.reset(),t.timelineStartInfo.baseMediaDecodeTime=e),n.timedMetadataTimestampRolloverStream&&n.timedMetadataTimestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.push=function(e){if(d){var t=u(e);t&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),d=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){d=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},a.prototype=new p,t.exports={Transmuxer:a,VideoSegmentStream:n,AudioSegmentStream:r,AUDIO_PROPERTIES:S,VIDEO_PROPERTIES:w}},{}],58:[function(e,t,i){"use strict";var n=e(52),r=e(53).handleRollover,a={};a.ts=e(51),a.aac=e(38);var s=function(e){return e[0]==="I".charCodeAt(0)&&e[1]==="D".charCodeAt(0)&&e[2]==="3".charCodeAt(0)},o=function(e,t){for(var i,n=0,r=188;r=0;)if(71!==e[u]||71!==e[d])u--,d--;else{switch(n=e.subarray(u,d),a.ts.parseType(n,t.pid)){case"pes":r=a.ts.parsePesType(n,t.table),s=a.ts.parsePayloadUnitStartIndicator(n),"audio"===r&&s&&(o=a.ts.parsePesTime(n))&&(o.type="audio",i.audio.push(o),l=!0)}if(l)break;u-=188,d-=188}},d=function(e,t,i){for(var n,r,s,o,u,d,l,f=0,c=188,h=!1,p={data:[],size:0};c=0;)if(71!==e[f]||71!==e[c])f--,c--;else{switch(n=e.subarray(f,c),a.ts.parseType(n,t.pid)){case"pes":r=a.ts.parsePesType(n,t.table),s=a.ts.parsePayloadUnitStartIndicator(n),"video"===r&&s&&(o=a.ts.parsePesTime(n))&&(o.type="video",i.video.push(o),h=!0)}if(h)break;f-=188,c-=188}},l=function(e,t){if(e.audio&&e.audio.length){var i=t;void 0===i&&(i=e.audio[0].dts),e.audio.forEach(function(e){e.dts=r(e.dts,i),e.pts=r(e.pts,i),e.dtsTime=e.dts/9e4,e.ptsTime=e.pts/9e4})}if(e.video&&e.video.length){var n=t;if(void 0===n&&(n=e.video[0].dts),e.video.forEach(function(e){e.dts=r(e.dts,n),e.pts=r(e.pts,n),e.dtsTime=e.dts/9e4,e.ptsTime=e.pts/9e4}),e.firstKeyFrame){var a=e.firstKeyFrame;a.dts=r(a.dts,n),a.pts=r(a.pts,n),a.dtsTime=a.dts/9e4,a.ptsTime=a.dts/9e4}}},f=function(e){for(var t,i=!1,n=0,r=null,s=null,o=0,u=0;e.length-u>=3;){switch(a.aac.parseType(e,u)){case"timed-metadata":if(e.length-u<10){i=!0;break}if((o=a.aac.parseId3TagSize(e,u))>e.length){i=!0;break}null===s&&(t=e.subarray(u,u+o),s=a.aac.parseAacTimestamp(t)),u+=o;break;case"audio":if(e.length-u<7){i=!0;break}if((o=a.aac.parseAdtsSize(e,u))>e.length){i=!0;break}null===r&&(t=e.subarray(u,u+o),r=a.aac.parseSampleRate(t)),n++,u+=o;break;default:u++}if(i)return null}if(null===r||null===s)return null;var d=9e4/r;return{audio:[{type:"audio",dts:s,pts:s},{type:"audio",dts:s+1024*n*d,pts:s+1024*n*d}]}},c=function(e){var t={pid:null,table:null},i={};o(e,t);for(var r in t.table)if(t.table.hasOwnProperty(r)){var a=t.table[r];switch(a){case n.H264_STREAM_TYPE:i.video=[],d(e,t,i),0===i.video.length&&delete i.video;break;case n.ADTS_STREAM_TYPE:i.audio=[],u(e,t,i),0===i.audio.length&&delete i.audio}}return i},h=function(e,t){var i,n=s(e);return(i=n?f(e):c(e))&&(i.audio||i.video)?(l(i,t),i):null};t.exports={inspect:h}},{}],59:[function(e,t,i){var n,r,a,s,o,u;n=function(e){return 9e4*e},r=function(e,t){return e*t},a=function(e){return e/9e4},s=function(e,t){return e/t},o=function(e,t){return n(s(e,t))},u=function(e,t){return r(a(e),t)},t.exports={secondsToVideoTs:n,secondsToAudioTs:r,videoTsToSeconds:a,audioTsToSeconds:s,audioTsToVideoTs:o,videoTsToAudioTs:u}},{}],60:[function(e,t,i){"use strict";var n;n=function(e){var t=e.byteLength,i=0,n=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+n},this.loadWord=function(){var r=e.byteLength-t,a=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");a.set(e.subarray(r,r+s)),i=new DataView(a.buffer).getUint32(0),n=8*s,t-=s},this.skipBits=function(e){var r;n>e?(i<<=e,n-=e):(e-=n,r=Math.floor(e/8),e-=8*r,t-=r,this.loadWord(),i<<=e,n-=e)},this.readBits=function(e){var r=Math.min(n,e),a=i>>>32-r;return n-=r,n>0?i<<=r:t>0&&this.loadWord(),r=e-r,r>0?a<>>e))return i<<=e,n-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},t.exports=n},{}],61:[function(e,t,i){"use strict";var n=function(){this.init=function(){var e={};this.on=function(t,i){e[t]||(e[t]=[]),e[t]=e[t].concat(i)},this.off=function(t,i){var n;return!!e[t]&&(n=e[t].indexOf(i),e[t]=e[t].slice(),e[t].splice(n,1),n>-1)},this.trigger=function(t){var i,n,r,a;if(i=e[t])if(2===arguments.length)for(r=i.length,n=0;n-1;o=n+i)i=/^\/(?:\.\.\/)*/.exec(s.slice(n))[0].length,a=(a+s.substring(o,n)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(i-1)/3+"}$"),"/");return a+s.substr(o)}};"object"==typeof i&&"object"==typeof t?t.exports=n:"function"==typeof define&&define.amd?define([],function(){return n}):"object"==typeof i?i.URLToolkit=n:e.URLToolkit=n}(this)},{}],63:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(i,"__esModule",{value:!0});var a=e(31),s=r(a),o="undefined"!=typeof window?window.videojs:void 0!==n?n.videojs:null,u=r(o),d=function(e){Object.defineProperties(e.frame,{id:{get:function(){return u["default"].log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return u["default"].log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return u["default"].log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}})},l=function(e){undefined;return isNaN(e)||Math.abs(e)===Infinity?Number.MAX_VALUE:e},f=function(e,t,i){var n=s["default"].WebKitDataCue||s["default"].VTTCue;t&&t.forEach(function(e){var t=e.stream;this.inbandTextTracks_[t].addCue(new n(e.startTime+this.timestampOffset,e.endTime+this.timestampOffset,e.text))},e),i&&function(){var t=l(e.mediaSource_.duration);i.forEach(function(e){var t=e.cueTime+this.timestampOffset;e.frames.forEach(function(e){var i=new n(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,d(i),this.metadataTrack_.addCue(i)},this)},e),e.metadataTrack_&&e.metadataTrack_.cues&&e.metadataTrack_.cues.length&&function(){for(var i=e.metadataTrack_.cues,n=[],r=0;r=0;i--){var r=t[i];"captions"===r.kind&&e.removeRemoteTextTrack(r)}n(e,"metadata","Timed Metadata")};i.cleanupTextTracks=r},{}],65:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(e){return/mp4a\.\d+.\d+/i.test(e)},r=function(e){return/avc1\.[\da-f]+/i.test(e)},a=function(e){var t={type:"",parameters:{}},i=e.trim().split(";");return t.type=i.shift().trim(),i.forEach(function(e){var i=e.trim().split("=");if(i.length>1){var n=i[0].replace(/"/g,"").trim(),r=i[1].replace(/"/g,"").trim();t.parameters[n]=r}}),t},s=function(e){return e.map(function(e){return e.replace(/avc1\.(\d+)\.(\d+)/i,function(e,t,i){return"avc1."+("00"+Number(t).toString(16)).slice(-2)+"00"+("00"+Number(i).toString(16)).slice(-2)})})};i["default"]={isAudioCodec:n,parseContentType:a,isVideoCodec:r,translateLegacyCodecs:s},t.exports=i["default"]},{}],66:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e(64),r=function(e,t,i){var r=t.player_;if(i.captions&&i.captions.length){e.inbandTextTracks_||(e.inbandTextTracks_={});for(var a in i.captionStreams)if(!e.inbandTextTracks_[a]){r.tech_.trigger({type:"usage",name:"hls-608"});var s=r.textTracks().getTrackById(a);e.inbandTextTracks_[a]=s||r.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}i.metadata&&i.metadata.length&&!e.metadataTrack_&&((0,n.removeExistingTrack)(r,"metadata","Timed Metadata",!0),e.metadataTrack_=r.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,e.metadataTrack_.inBandMetadataTrackDispatchType=i.metadata.dispatchType)};i["default"]=r,t.exports=i["default"]},{}],67:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n={TIME_BETWEEN_CHUNKS:1,BYTES_PER_CHUNK:32768};i["default"]=n,t.exports=i["default"]},{}],68:[function(e,t,i){(function(n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i=0&&(this.timestampOffset_=e,this.mediaSource_.swfObj.vjs_discontinuity(),this.basePtsOffset_=NaN,this.audioBufferEnd_=NaN,this.videoBufferEnd_=NaN,this.transmuxer_.postMessage({action:"reset"}))}}),Object.defineProperty(this,"buffered",{get:function(){if(!(this.mediaSource_&&this.mediaSource_.swfObj&&"vjs_getProperty"in this.mediaSource_.swfObj))return c["default"].createTimeRange();var e=this.mediaSource_.swfObj.vjs_getProperty("buffered");return e&&e.length&&(e[0][0]=L(e[0][0],3),e[0][1]=L(e[0][1],3)),c["default"].createTimeRanges(e)}}),this.mediaSource_.player_.on("seeked",function(){if((0,g["default"])(0,Infinity,i.metadataTrack_),i.inbandTextTracks_)for(var e in i.inbandTextTracks_)(0,g["default"])(0,Infinity,i.inbandTextTracks_[e])});var s=this.onHlsReset_.bind(this);this.mediaSource_.player_.tech_.on("hls-reset",s),this.mediaSource_.player_.tech_.hls.on("dispose",function(){i.transmuxer_.terminate(),i.mediaSource_.player_.tech_.off("hls-reset",s)})}return s(t,e),o(t,[{key:"appendBuffer",value:function(e){var t=undefined;if(this.updating)throw t=new Error("SourceBuffer.append() cannot be called while an update is in progress"),t.name="InvalidStateError",t.code=11,t;this.updating=!0,this.mediaSource_.readyState="open",this.trigger({type:"update"}),this.transmuxer_.postMessage({action:"push",data:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength},[e.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"abort",value:function(){this.buffer_=[],this.bufferSize_=0,this.mediaSource_.swfObj.vjs_abort(),this.updating&&(this.updating=!1,this.trigger({type:"updateend"}))}},{key:"remove",value:function(e,t){if((0,g["default"])(e,t,this.metadataTrack_),this.inbandTextTracks_)for(var i in this.inbandTextTracks_)(0,g["default"])(e,t,this.inbandTextTracks_[i]);this.trigger({type:"update"}),this.trigger({type:"updateend"})}},{key:"receiveBuffer_",value:function(e){var t=this;(0,_["default"])(this,this.mediaSource_,e),(0,v.addTextTrackData)(this,e.captions,e.metadata),E(function(){var i=t.convertTagsToData_(e);0===t.buffer_.length&&E(t.processBuffer_.bind(t)),i&&(t.buffer_.push(i),t.bufferSize_+=i.byteLength)})}},{key:"processBuffer_",value:function(){var e=this,t=O["default"].BYTES_PER_CHUNK;if(!this.buffer_.length)return void(!1!==this.updating&&(this.updating=!1,this.trigger({type:"updateend"})));var i=this.buffer_[0].subarray(0,t);i.byteLength=n){for(;--d;){var l=a[d];if(!(l.pts>n)&&(l.keyFrame||l.metaDataTag))break}for(;d;){if(!a[d-1].metaDataTag)break;d--}}var f=a.slice(d),c=undefined;for(c=isNaN(this.audioBufferEnd_)?n:this.audioBufferEnd_+.1,f.length&&(c=Math.min(c,f[0].pts)),d=0;d=c);)d++;var h=s.slice(d);h.length&&(this.audioBufferEnd_=h[h.length-1].pts),f.length&&(this.videoBufferEnd_=f[f.length-1].pts);var p=this.getOrderedTags_(f,h);if(0!==p.length){if(p[0].ptsthis.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=t)}},{key:"addSourceBuffer",value:function(e){var t=undefined,i=(0,_.parseContentType)(e);if(/^(video|audio)\/mp2t$/i.test(i.type)){var n=[];i.parameters&&i.parameters.codecs&&(n=i.parameters.codecs.split(","),n=(0,_.translateLegacyCodecs)(n),n=n.filter(function(e){return(0,_.isAudioCodec)(e)||(0,_.isVideoCodec)(e)})),0===n.length&&(n=["avc1.4d400d","mp4a.40.2"]),t=new g["default"](this,n),0!==this.sourceBuffers.length&&(this.sourceBuffers[0].createRealSourceBuffers_(),t.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else t=this.nativeMediaSource_.addSourceBuffer(e);return this.sourceBuffers.push(t),t}}]),t}(p["default"].EventTarget);i["default"]=b,t.exports=i["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],72:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=function(e,t,i){var n=undefined,r=undefined;if(i&&i.cues)for(n=i.cues.length;n--;)r=i.cues[n],r.startTime<=t&&r.endTime>=e&&i.removeCue(r)};i["default"]=n,t.exports=i["default"]},{}],73:[function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i=0&&(this.timestampOffset_=e,this.appendAudioInitSegment_=!0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e}))}}),Object.defineProperty(this,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(e){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=e),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=e)}}),Object.defineProperty(this,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(this,"buffered",{get:function(){var e=null,t=null,i=0,n=[],r=[];if(!this.videoBuffer_&&!this.audioBuffer_)return l["default"].createTimeRange();if(!this.videoBuffer_)return this.audioBuffer_.buffered;if(!this.audioBuffer_)return this.videoBuffer_.buffered;if(this.audioDisabled_)return this.videoBuffer_.buffered;if(0===this.videoBuffer_.buffered.length&&0===this.audioBuffer_.buffered.length)return l["default"].createTimeRange();for(var a=this.videoBuffer_.buffered,s=this.audioBuffer_.buffered,o=a.length;o--;)n.push({time:a.start(o),type:"start"}),n.push({time:a.end(o),type:"end"});for(o=s.length;o--;)n.push({time:s.start(o),type:"start"}),n.push({time:s.end(o),type:"end"});for(n.sort(function(e,t){return e.time-t.time}),o=0;o=49}return!0};var F=w["default"].getComponent("Component"),G=function(e){function t(e,i,n){var a=this;if(r(this,t),o(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,i,n.hls),i.options_&&i.options_.playerId){var s=(0,w["default"])(i.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return w["default"].log.warn("player.hls is deprecated. Use player.tech_.hls instead."),i.trigger({type:"usage",name:"hls-player-access"}),a}})}if(this.tech_=i,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&(i.featuresNativeVideoTracks||i.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");this.on(d["default"],["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(e){var t=d["default"].fullscreenElement||d["default"].webkitFullscreenElement||d["default"].mozFullScreenElement||d["default"].msFullscreenElement;t&&t.contains(a.tech_.el())&&a.masterPlaylistController_.fastQualityChange_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_)return void(this.ignoreNextSeekingEvent_=!1);this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),this.audioTrackChange_=function(){a.masterPlaylistController_.setupAudio(),a.tech_.trigger({type:"usage",name:"hls-audio-change"})},this.textTrackChange_=function(){a.masterPlaylistController_.setupSubtitles()},this.on(this.tech_,"play",this.play)}return a(t,e),s(t,[{key:"setOptions_",value:function(){var e=this;this.options_.withCredentials=this.options_.withCredentials||!1,"number"!=typeof this.options_.blacklistDuration&&(this.options_.blacklistDuration=300),"number"!=typeof this.options_.bandwidth&&(this.options_.bandwidth=4194304),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&4194304===this.options_.bandwidth,["withCredentials","bandwidth"].forEach(function(t){"undefined"!=typeof e.source_[t]&&(e.options_[t]=e.source_[t])}),this.bandwidth=this.options_.bandwidth}},{key:"src",value:function(e){var t=this;e&&(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=M,this.masterPlaylistController_=new k.MasterPlaylistController(this.options_),this.playbackWatcher_=new U["default"](w["default"].mergeOptions(this.options_,{seekable:function(){return t.seekable()}})),this.masterPlaylistController_.on("error",function(){w["default"].players[t.tech_.options_.playerId].error(t.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):M.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=M.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(e){this.masterPlaylistController_.selectPlaylist=e.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=e,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(e){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=e,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var e=1/(this.bandwidth||1),t=undefined;return t=this.throughput>0?1/this.throughput:0,Math.floor(1/(e+t))},set:function(){w["default"].log.error('The "systemBandwidth" property is read-only')}}}),Object.defineProperties(this.stats,{bandwidth:{get:function(){return t.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return t.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return t.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return t.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return t.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return t.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return t.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return t.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.masterPlaylistController_.on("sourceopen",function(){t.tech_.audioTracks().addEventListener("change",t.audioTrackChange_),t.tech_.remoteTextTracks().addEventListener("change",t.textTrackChange_)}),this.masterPlaylistController_.on("selectedinitialmedia",function(){(0,L["default"])(t)}),this.masterPlaylistController_.on("audioupdate",function(){t.tech_.clearTracks("audio"),t.masterPlaylistController_.activeAudioGroup().forEach(function(e){t.tech_.audioTracks().addTrack(e)})}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.masterPlaylistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.tech_.ready(function(){return t.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(w["default"].URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var e=this,t=w["default"].players[this.tech_.options_.playerId];t&&t.qualityLevels&&(this.qualityLevels_=t.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){j(e.qualityLevels_,e)}),this.playlists.on("mediachange",function(){B(e.qualityLevels_,e.playlists)}))}},{key:"activeAudioGroup_",value:function(){return this.masterPlaylistController_.activeAudioGroup()}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(e){this.masterPlaylistController_.setCurrentTime(e)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_.audioTracks().removeEventListener("change",this.audioTrackChange_),this.tech_.remoteTextTracks().removeEventListener("change",this.textTrackChange_),o(Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}}]),t}(F),q=function V(e){return{canHandleSource:function(t){var i=arguments.length<=1||arguments[1]===undefined?{}:arguments[1],n=w["default"].mergeOptions(w["default"].options,i);return(!n.hls||!n.hls.mode||n.hls.mode===e)&&V.canPlayType(t.type,n)},handleSource:function(t,i){var n=arguments.length<=2||arguments[2]===undefined?{}:arguments[2],r=w["default"].mergeOptions(w["default"].options,n,{hls:{mode:e}});return"flash"===e&&i.setTimeout(function(){i.trigger("loadstart")},1),i.hls=new G(t,i,r),i.hls.xhr=(0,m["default"])(),i.hls.src(t.src),i.hls},canPlayType:function(e){var t=arguments.length<=1||arguments[1]===undefined?{}:arguments[1],i=w["default"].mergeOptions(w["default"].options,t);return V.canPlayType(e,i)?"maybe":""}}};q.canPlayType=function(e,t){ -if(w["default"].browser.IE_VERSION&&w["default"].browser.IE_VERSION<=10)return!1;var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;return!(!t.hls.overrideNative&&M.supportsNativeHls)&&i.test(e)},"undefined"!=typeof w["default"].MediaSource&&"undefined"!=typeof w["default"].URL||(w["default"].MediaSource=v.MediaSource,w["default"].URL=v.URL);var H=w["default"].getTech("Flash");v.MediaSource.supportsNativeMediaSources()&&w["default"].getTech("Html5").registerSourceHandler(q("html5"),0),C["default"].Uint8Array&&H&&H.registerSourceHandler(q("flash")),w["default"].HlsHandler=G,w["default"].HlsSourceHandler=q,w["default"].Hls=M,w["default"].use||w["default"].registerComponent("Hls",M),w["default"].m3u8=T["default"],w["default"].options.hls=w["default"].options.hls||{},w["default"].registerPlugin?w["default"].registerPlugin("reloadSourceOnError",x["default"]):w["default"].plugin("reloadSourceOnError",x["default"]),t.exports={Hls:M,HlsHandler:G,HlsSourceHandler:q}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[77]); \ No newline at end of file diff --git a/www/js/videojs-hlsjs-plugin.js b/www/js/videojs-hlsjs-plugin.js new file mode 100644 index 00000000..28a49fec --- /dev/null +++ b/www/js/videojs-hlsjs-plugin.js @@ -0,0 +1,8 @@ +/** + * videojs-hlsjs-plugin + * v1.0.16 + * 2022-01-30 + * www.streamroot.io + * Copyright 2018 + **/ +!function(r){var i={};function a(e){if(i[e])return i[e].exports;var t=i[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=r,a.c=i,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(r,i,function(e){return t[e]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,r){"use strict";var r=r(1),r=(window.videojs&&(r.registerConfigPlugin(window.videojs),r.registerSourceHandler(window.videojs)),{register:r.registerSourceHandler}),i="hlsSourceHandler";window[i]||(window[i]=r)},function(e,t,r){"use strict";var C="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},I=r(2);function i(e){var t=this;e&&(t.srOptions_||(t.srOptions_={}),t.srOptions_.hlsjsConfig||(t.srOptions_.hlsjsConfig=e.hlsjsConfig),t.srOptions_.captionConfig||(t.srOptions_.captionConfig=e.captionConfig))}e.exports={registerSourceHandler:function(D){var e,O={};function r(f,a){a.name_="StreamrootHlsjs";var n,s=a.el(),i={},g=null,o=null,l=null,p=null,d=null,u=null,c=D(a.options_.playerId),h=c.qualityLevels&&c.qualityLevels(),m=(h&&c.hlsQualitySelector&&(a.hls={}),!1);function v(e){1===i[I.ErrorTypes.MEDIA_ERROR]?n.recoverMediaError():2===i[I.ErrorTypes.MEDIA_ERROR]?(n.swapAudioCodec(),n.recoverMediaError()):2>>8^255&n^99,t[c[n]=r]),o=t[s],l=t[o],d=257*t[n]^16843008*n;h[r]=d<<24|d>>>8,f[r]=d<<16|d>>>16,g[r]=d<<8|d>>>24,p[r]=d,m[n]=(d=16843009*l^65537*o^257*s^16843008*r)<<24|d>>>8,v[n]=d<<16|d>>>16,y[n]=d<<8|d>>>24,E[n]=d,r?(r=s^t[t[t[l^s]]],i^=t[t[i]]):r=i=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),u=!0,r=0;r>>5}function v(e,t){return!!(t+1>>6),d=(60&t[r+2])>>>2;if(!(o.length-1>>6,K.logger.log("manifest codec:"+i+",ADTS data:type:"+l+",sampleingIndex:"+d+"["+o[d]+"Hz],channelConfig:"+a),t=/firefox/i.test(s)?6<=d?(l=5,n=new Array(4),d-3):(l=2,n=new Array(2),d):-1!==s.indexOf("android")?(l=2,n=new Array(2),d):(l=5,n=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=d?d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=d&&1==a||/vivaldi/i.test(s))||!i&&1==a)&&(l=2,n=new Array(2)),d)),n[0]=l<<3,n[0]|=(14&d)>>1,n[1]|=(1&d)<<7,n[1]|=a<<3,5===l&&(n[1]|=(14&t)>>1,n[2]=(1&t)<<7,n[2]|=8,n[3]=0),{config:n,samplerate:o[d],channelCount:a,codec:"mp4a.40."+l,manifestCodec:u};e.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(t,r,i,a),e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,K.logger.log("parsed codec:"+e.codec+",rate:"+t.samplerate+",nb channel:"+t.channelCount))}function h(e){return 9216e4/e}function E(e,t,r,i,a){var n,i=function(e,t,r,i,a){var n=e.length,s=l(e,t),e=d(e,t);if(0<(e-=s)&&t+s+e<=n)return{headerLength:s,frameLength:e,stamp:r+i*a}}(t,r,i,a,h(e.samplerate));if(i)return a=i.stamp,n=i.headerLength,i=i.frameLength,t={unit:t.subarray(r+n,r+n+i),pts:a,dts:a},e.samples.push(t),{sample:t,length:i+n}}var A=t("./src/demux/id3.js"),_=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(A.default.getID3Data(e,0)||[]).length,r=e.length;tt.length))return n=this.parseHeader(t,r),n&&r+n.frameLength<=t.length?(i=i+a*(9e4*n.samplesPerFrame/n.sampleRate),a={unit:t.subarray(r,r+n.frameLength),pts:i,dts:i},e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(a),{sample:a,length:n.frameLength}):void 0},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!=r&&0!=a&&15!=a&&3!=n)return a=1e3*o.BitratesMap[14*(3==r?3-i:3==i?3:4)+a-1],n=o.SamplingRateMap[3*(3==r?0:2==r?1:2)+n],e=e[t+3]>>6==3?1:2,i=8*(t=o.SamplesCoefficients[r][i])*(r=o.BytesInSlot[i]),{sampleRate:n,channelCount:e,frameLength:parseInt(t*a/n+s,10)*r,samplesPerFrame:i}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e||(e=(e-=this.bitsAvailable)-((t=e>>3)>>3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return 32>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(t,r,i,a,n,s){var o=this.discardEPB(n.data),e=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(e.buffer,function(e){n.data=l.getAvcDecryptedUnit(o,e),s||l.decryptAvcSamples(t,r,i+1,a)})},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),u={video:1,audio:2,id3:3,text:4},L=function(){function C(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var e=C.prototype;return e.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new s(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},C.probe=function(e){e=C._syncOffset(e);return!(e<0)&&(e&&K.logger.warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?"),!0)},C._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r>4){if((r=t+5+e[t+4])===t+188)continue}else r=t+4;switch(g){case y:f&&(o&&(i=R(o))&&A(i,!1),o={data:[],size:0}),o&&(o.data.push(e.subarray(r,t+188)),o.size+=t+188-r);break;case E:f&&(l&&(i=R(l))&&(n.isAAC?k:L)(i),l={data:[],size:0}),l&&(l.data.push(e.subarray(r,t+188)),l.size+=t+188-r);break;case T:f&&(d&&(i=R(d))&&w(i),d={data:[],size:0}),d&&(d.data.push(e.subarray(r,t+188)),d.size+=t+188-r);break;case 0:f&&(r+=e[r]+1),b=this._pmtId=S(e,r);break;case b:f&&(r+=e[r]+1);var O=_(e,r,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);0<(y=O.avc)&&(a.pid=y),0<(E=O.audio)&&(n.pid=E,n.isAAC=O.isAAC),0<(T=O.id3)&&(s.pid=T),m&&!v&&(K.logger.log("reparse from beginning"),m=!1,t=D-188),v=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=!0}}else this.observer.trigger(G.default.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o&&(i=R(o))?(A(i,!0),a.pesData=null):a.pesData=o,l&&(i=R(l))?((n.isAAC?k:L)(i),n.pesData=null):(l&&l.size&&K.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=l),d&&(i=R(d))?(w(i),s.pesData=null):s.pesData=d,null==this.sampleAes?this.remuxer.remux(n,a,s,this._txtTrack,u,c,h):this.decryptAndRemux(n,a,s,this._txtTrack,u,c,h)},e.decryptAndRemux=function(e,t,r,i,a,n,s){var o;e.samples&&e.isAAC?(o=this).sampleAes.decryptAacSamples(e.samples,0,function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}):this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},e.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){var o;t.samples?(o=this).sampleAes.decryptAvcSamples(t.samples,0,0,function(){o.remuxer.remux(e,t,r,i,a,n,s)}):this.remuxer.remux(e,t,r,i,a,n,s)},e.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},e._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},e._parsePMT=function(e,t,r,i){var a,n={audio:-1,avc:-1,id3:-1,isAAC:!0},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);te.size-6)return null;if(192&(r=l[7])&&(4294967295<(i=536870912*(14&l[9])+4194304*(255&l[10])+16384*(254&l[11])+128*(255&l[12])+(254&l[13])/2)&&(i-=8589934592),64&r?(4294967295<(a=536870912*(14&l[14])+4194304*(255&l[15])+16384*(254&l[16])+128*(255&l[17])+(254&l[18])/2)&&(a-=8589934592),54e5=e[r-1].pts)e.push(t);else for(var i=r-1;0<=i;i--)if(t.pts>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))},c.mdia=function(e){return c.box(c.types.mdia,c.mdhd(e.timescale,e.duration),c.hdlr(e.type),c.minf(e))},c.mfhd=function(e){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},c.minf=function(e){return"audio"===e.type?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(e)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(e))},c.moof=function(e,t,r){return c.box(c.types.moof,c.mfhd(e),c.traf(r,t))},c.moov=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trak(e[t]);return c.box.apply(null,[c.types.moov,c.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(c.mvex(e)))},c.mvex=function(e){for(var t=e.length,r=[];t--;)r[t]=c.trex(e[t]);return c.box.apply(null,[c.types.mvex].concat(r))},c.mvhd=function(e,t){t*=e;var r=Math.floor(t/(1+n)),t=Math.floor(t%(1+n)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return c.box(c.types.mvhd,e)},c.sdtp=function(e){for(var t,r=e.samples||[],i=new Uint8Array(4+r.length),a=0;a>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(n=0;n>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var u=c.box(c.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(a))),s=e.width,o=e.height,l=e.pixelRatio[0],d=e.pixelRatio[1];return c.box(c.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,s>>8&255,255&s,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,c.box(c.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),c.box(c.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,255&l,d>>24,d>>16&255,d>>8&255,255&d])))},c.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},c.mp4a=function(e){var t=e.samplerate;return c.box(c.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),c.box(c.types.esds,c.esds(e)))},c.mp3=function(e){var t=e.samplerate;return c.box(c.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},c.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?c.box(c.types.stsd,c.STSD,c.mp4a(e)):c.box(c.types.stsd,c.STSD,c.mp3(e)):c.box(c.types.stsd,c.STSD,c.avc1(e))},c.tkhd=function(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,a=Math.floor(r/(1+n)),r=Math.floor(r%(1+n));return c.box(c.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))},c.traf=function(e,t){var r=c.sdtp(e),i=e.id,a=Math.floor(t/(1+n)),t=Math.floor(t%(1+n));return c.box(c.types.traf,c.box(c.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),c.box(c.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,t>>24,t>>16&255,t>>8&255,255&t])),c.trun(e,r.length+16+20+8+16+8+8),r)},c.trak=function(e){return e.duration=e.duration||4294967295,c.box(c.types.trak,c.tkhd(e),c.mdia(e))},c.trex=function(e){e=e.id;return c.box(c.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},c.trun=function(e,t){var r,i,a,n,s,o=e.samples||[],l=o.length,e=12+16*l,d=new Uint8Array(e);for(d.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(t+=8+e)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,n.isLeading<<2|n.dependsOn,n.isDependedOn<<6|n.hasRedundancy<<4|n.paddingValue<<1|n.isNonSync,61440&n.degradPrio,15&n.degradPrio,s>>>24&255,s>>>16&255,s>>>8&255,255&s],12+16*r);return c.box(c.types.trun,d)},c.initSegment=function(e){c.types||c.init();var e=c.moov(e),t=new Uint8Array(c.FTYP.byteLength+e.byteLength);return t.set(c.FTYP),t.set(e,c.FTYP.byteLength),t},c}();function c(e,t,r,i){e=e*t*(r=void 0===r?1:r);return(i=void 0===i?!1:i)?Math.round(e):e}function V(e,t){return c(e,1e3,1/9e4,t=void 0===t?!1:t)}function f(e,t){return c(e,9e4,1/(t=void 0===t?1:t))}var T,U=f(10),Y=f(.2),D=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r;e=navigator.userAgent;this.isSafari=i&&-1>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:n=e[d++],l+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[d++],s=e[d++],l+=String.fromCharCode((15&a)<<12|(63&n)<<6|(63&s)<<0)}}return l},o}();var i=r._utf8ArrayToStr;t.default=r},"./src/demux/mp4demuxer.js":function(e,t,r){"use strict";r.r(t);var n=r("./src/utils/logger.js"),o=r("./src/events.js"),s=Math.pow(2,32)-1;t.default=function(){function h(e,t){this.observer=e,this.remuxer=t}var e=h.prototype;return e.resetTimeStamp=function(e){this.initPTS=e},e.resetInitSegment=function(e,t,r,i){var a,n;e&&e.byteLength?(null==t&&(t="mp4a.40.5"),null==r&&(r="avc1.42e01e"),n={},(a=this.initData=h.parseInitSegment(e)).audio&&a.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:i?e:null}:(a.audio&&(n.audio={container:"audio/mp4",codec:t,initSegment:i?e:null}),a.video&&(n.video={container:"video/mp4",codec:r,initSegment:i?e:null})),this.observer.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,{tracks:n})):(t&&(this.audioCodec=t),r&&(this.videoCodec=r))},h.probe=function(e){return 0>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},h.findBox=function(e,t){var r,i,a,n,s,o=[];if(e.data?(n=e.start,i=e.end,e=e.data):(n=0,i=e.byteLength),!t.length)return null;for(r=n;r>>31)return;l=h.readUint32(i,o+=4);o+=4,a.push({referenceSize:d,subsegmentDuration:l,info:{duration:l/n,start:s,end:s+d-1}}),s+=d,r=o+=4}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:u,references:a,moovEndOffset:t}},h.parseInitSegment=function(e){var a=[];return h.findBox(e,["moov","trak"]).forEach(function(e){var t,r,i=h.findBox(e,["tkhd"])[0];i&&(r=i.data[i.start],i=h.readUint32(i,0===r?12:20),(t=h.findBox(e,["mdia","mdhd"])[0])&&(r=t.data[t.start],t=h.readUint32(t,0===r?12:20),!(r=h.findBox(e,["mdia","hdlr"])[0])||(r={soun:"audio",vide:"video"}[h.bin2str(r.data.subarray(r.start+8,r.start+12))])&&((e=h.findBox(e,["mdia","minf","stbl","stsd"])).length&&(e=e[0],e=h.bin2str(e.data.subarray(e.start+12,e.start+16)),n.logger.log("MP4Demuxer:"+r+":"+e+" found")),a[i]={timescale:t,type:r},a[r]={timescale:t,id:i})))}),a},h.getStartDTS=function(r,e){e=h.findBox(e,["moof","traf"]),e=[].concat.apply([],e.map(function(t){return h.findBox(t,["tfhd"]).map(function(e){e=h.readUint32(e,4),e=r[e].timescale||9e4;return h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);return r=1===t?(r*=Math.pow(2,32))+h.readUint32(e,8):r})[0]/e})})),e=Math.min.apply(null,e);return isFinite(e)?e:0},h.offsetStartDTS=function(r,e,a){h.findBox(e,["moof","traf"]).map(function(t){return h.findBox(t,["tfhd"]).map(function(e){var e=h.readUint32(e,4),i=r[e].timescale||9e4;h.findBox(t,["tfdt"]).map(function(e){var t=e.data[e.start],r=h.readUint32(e,4);0===t?h.writeUint32(e,4,r-a*i):(r=(r=(r*=Math.pow(2,32))+h.readUint32(e,8))-a*i,r=Math.max(r,0),t=Math.floor(r/(1+s)),r=Math.floor(r%(1+s)),h.writeUint32(e,4,t),h.writeUint32(e,8,r))})})})},e.append=function(e,t,r,i){var a=this.initData;a||(this.resetInitSegment(e,this.audioCodec,this.videoCodec,!1),a=this.initData);var n,s=this.initPTS;void 0===s&&(n=h.getStartDTS(a,e),this.initPTS=s=n-t,this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:s})),h.offsetStartDTS(a,e,s),n=h.getStartDTS(a,e),this.remuxer.remux(a.audio,a.video,null,null,n,r,i,e)},e.destroy=function(){},h}()},"./src/errors.ts":function(e,t,r){"use strict";var i,a;r.r(t),r.d(t,"ErrorTypes",function(){return i}),r.d(t,"ErrorDetails",function(){return a}),(r=i=i||{}).NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",(t=a=a||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException"},"./src/events.js":function(e,t,r){"use strict";r.r(t);t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":function(t,r,e){"use strict";e.r(r);var f,s,i={},a=(e.r(i),e.d(i,"newCue",function(){return ht}),e("./node_modules/url-toolkit/src/url-toolkit.js")),d=e("./src/errors.ts"),w=e("./src/polyfills/number-isFinite.js"),E=e("./src/events.js"),D=e("./src/utils/logger.js"),o={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},n=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(1>8*(15-r)&255;return t},i.setDecryptDataFromLevelKey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&((r=new O(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},i=e,(t=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange||[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this.levelkey||this._decryptdata?(!this._decryptdata&&this.levelkey&&("number"!=typeof(e=this.sn)&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&D.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)),this._decryptdata):null;var e}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(w.isFiniteNumber)(this.programDateTime))return null;var e=Object(w.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&g(i.prototype,t),r&&g(i,r),e}();function m(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(e){if(this[e]){for(var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(e){return parseFloat(this[e])},e.enumeratedString=function(e){return this[e]},e.decimalResolution=function(e){e=v.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},r.parseAttrList=function(e){var t,r={};for(y.lastIndex=0;null!==(t=y.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},r}(),b={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function S(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var _=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,R=/#EXT-X-MEDIA:(.*)/g,P=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),F=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,M=/\.(mp4|m4s|m4v|m4a)$/i,A=function(){function l(){}return l.findGroup=function(e,t){for(var r=0;r=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){for(var i=e.buffered,a=[],n=0;nn&&(i[s-1].end=e[a].end):i.push(e[a])):i.push(e[a])}else i=e;for(var o,u=0,c=t,h=t,l=0;le.endSN)return 0;for(a=l-e.startSN,(s=e.fragments)[a]=t,o=a;0u.length))for(var d=0;dr.startCC||e&&e.cce}(t,r,a))return a}return null}function he(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);e=e?t[e.sn-t[0].sn+1]:null;return e&&!fe(r,i,e)?e:V.search(t,fe.bind(null,r,i))}function fe(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);t=Math.min(t,r.duration+(r.deltaPTS||0));return r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0}var ge=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,a!==e)return this.moved=!0,void(null!==i&&(this.stallReported&&(e=self.performance.now()-i,D.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(e)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0));if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){e=Y.bufferInfo(r,a,0),o=0r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s=n&&ad&&d>l.currentTime&&(D.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+d.toFixed(3)),l.currentTime=d),this.nextLoadPosition=d),e.PTSKnown&&i=e.startSN&&r<=e.endSN&&(d=n[r-e.startSN],a.cc===d.cc&&D.logger.log("live playlist, switching playlist, load frag with next SN: "+(s=d).sn)),s||(s=V.search(n,function(e){return a.cc-e.cc}))&&D.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn))),s||(s=n[Math.min(u-1,Math.round(u/2))],D.logger.log("live playlist, switching playlist, unknown, load middle frag : "+s.sn))),s)},a._findFragment=function(e,t,r,i,a,n,s){var o,l=this.hls.config;return(a=an-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[r-1])&&(n=a.sn-s.startSN,r=t&&a.level===t.level,o=i[n-1],i=i[1+n],t&&a.sn===t.sn&&(r&&!a.backtracked?a.snl.maxBufferHole&&t.dropped&&n?(a=o,D.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):D.logger.log("Re-loading fragment with SN: "+(a=i).sn):a=null:a.backtracked&&(i&&i.backtracked?(D.logger.warn("Already backtracked from fragment "+i.sn+", will not backtrack to fragment "+a.sn+". Loading fragment "+i.sn),a=i):(D.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),a.dropped=0,o?(a=o).backtracked=!0:n&&(a=null))))),a},a._loadKey=function(e){this.state=ye,this.hls.trigger(E.default.KEY_LOADING,{frag:e})},a._loadFragment=function(e){var t=this.fragmentTracker.getState(e);"initSegment"!==(this.fragCurrent=e).sn&&(this.startFragRequested=!0),Object(w.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===B||t===j?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(E.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new ee(this.hls,"main")),this.state=Ee):t===G&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},a.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,s.MAIN)},a.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},a._checkFragmentChanged=function(){var e,t,r=this.media;r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),Y.isBuffered(r,t)?e=this.getBufferedFrag(t):Y.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),!e||(r=e)!==this.fragPlaying&&(this.hls.trigger(E.default.FRAG_CHANGED,{frag:r}),t=r.level,this.fragPlaying&&this.fragPlaying.level===t||this.hls.trigger(E.default.LEVEL_SWITCHED,{level:t}),this.fragPlaying=r))},a.immediateLevelSwitch=function(){D.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,(t=this.media)?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e);var e,t=this.fragCurrent;t&&t.loader&&t.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,Y.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},a.nextLevelSwitch=function(){var e,t,r=this.media;r&&r.readyState&&((t=this.getBufferedFrag(r.currentTime))&&1=e&&(t.maxMaxBufferLength/=2,D.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},a._checkBuffer=function(){var e=this.media;e&&0!==e.readyState&&(e=(this.mediaBuffer||e).buffered,!this.loadedmetadata&&e.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,e))},a.onFragLoadEmergencyAborted=function(){this.state=T,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},a.onBufferFlushed=function(){var e=this.mediaBuffer||this.media;e&&this.fragmentTracker.detectEvictedFragments(h.VIDEO,e.buffered),this.state=T,this.fragPrevious=null},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&0<=r&&(D.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},a._getAudioCodec=function(e){e=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(D.logger.log("swapping playlist audio codec"),e=e&&(-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),e},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(E.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e}))},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){e=this.getBufferedFrag(e.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&De(t.prototype,a),r&&De(t,r),e}(Q);function Ce(e,t){for(var r=0;re[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var a=Math.floor((i+r)/2);if(te[a].endTime))return e[a];r=a+1}}return e[r].endTime-t=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function Ge(e,t){for(var r=0;r500*r.duration/c){var s=e.levels,h=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/n),o=s[r.level],o=o.realBitrate?Math.max(o.realBitrate,o.bitrate):o.bitrate,o=a.total||Math.max(a.loaded,Math.round(r.duration*o/8)),f=t.currentTime,o=(o-a.loaded)/h,l=(Y.bufferInfo(t,f,e.config.maxBufferHole).end-f)/c;if(l<2*r.duration/c&&ls.start(0)&&this.removeBufferRange(o,l,0,a)&&this.hls.trigger(E.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}else D.logger.error("flushLiveBackBuffer called without attaching media")}},i.onLevelUpdated=function(e){e=e.details;0this._msDuration&&this._levelDuration>e||!Object(w.isFiniteNumber)(e))&&(D.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},i.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var a=r[i];a&&(t+=a.buffered.length)}}catch(e){D.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(E.default.BUFFER_FLUSHED)}},i.doAppending=function(){var t=this.config,r=this.hls,i=this.segments,a=this.sourceBuffer;if(Object.keys(a).length){if(!this.media||this.media.error)return this.segments=[],void D.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var n=i.shift();if(n)try{var e=a[n.type];if(!e)return void this._onSBUpdateEnd();if(e.updating)return void i.unshift(n);e.ended=!1,this.parent=n.parent,e.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0}catch(e){D.logger.error("error while trying to append buffer:"+e.message),i.unshift(n);a={type:d.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===e.code?(this.segments=[],a.details=d.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,a.details=d.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.appendErrorMaxRetry&&(D.logger.log("fail "+t.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],a.fatal=!0)),r.trigger(E.default.ERROR,a)}}}},i.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),D.logger.log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return D.logger.warn("abort flushing too many retries"),!0;a=i[r];if(a){if(a.ended=!1,a.updating)return D.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,a,e,t))return this.flushBufferCounter++,!1}return D.logger.log("buffer flushed"),!0},i.removeBufferRange=function(e,t,r,i){try{for(var a=0;athis.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)},i.getMaxLevel=function(r){var i=this;if(!this.levels)return-1;var e=this.levels.filter(function(e,t){return a.isLevelAllowed(t,i.restrictedLevels)&&t<=r});return a.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},i.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},a.isLevelAllowed=function(e,t){return-1===(t=void 0===t?[]:t).indexOf(e)},a.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,a=e.length-1,n=0;n=t||s.height>=r)&&(s=s,!(i=e[n+1])||(s.width!==i.width||s.height!==i.height))){a=n;break}}return a},e=a,i=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(r=[{key:"mediaWidth",get:function(){var e,t=this.media;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=a.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,t=this.media;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=a.contentScaleFactor),e}}])&&Ye(e.prototype,r),i&&Ye(e,i),a}(n);var qe=window.performance,ze=function(t){var e;function r(e){return t.call(this,e,E.default.MEDIA_ATTACHING)||this}e=t,(i=r).prototype=Object.create(e.prototype),(i.prototype.constructor=i).__proto__=e;var i=r.prototype;return i.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},i.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},i.checkFPS=function(e,t,r){var i,a,n,s,o=qe.now();t&&(this.lastTime&&(s=o-this.lastTime,i=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,s=1e3*i/s,(n=this.hls).trigger(E.default.FPS_DROP,{currentDropped:i,currentDecoded:a,totalDroppedFrames:r}),0n.config.fpsDroppedMonitoringThreshold*a&&(s=n.currentLevel,D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0=s)&&(n.trigger(E.default.FPS_DROP_LEVEL_CAPPING,{level:s-=1,droppedLevel:n.currentLevel}),n.autoLevelCapping=s,n.streamController.nextLevelSwitch()))),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=t)},i.checkFPSInterval=function(){var e,t=this.video;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))},r}(n),Xe=window,Qe=Xe.performance,$e=Xe.XMLHttpRequest,Xe=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Qe.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var t=this.context,r=this.loader=new $e,i=this.stats,i=(i.tfirst=0,i.loaded=0,this.xhrSetup);try{if(i)try{i(r,t.url)}catch(e){r.open("GET",t.url,!0),i(r,t.url)}r.readyState||r.open("GET",t.url,!0)}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),r.send()},t.readystatechange=function(e){var t,r,e=e.currentTarget,i=e.readyState,a=this.stats,n=this.context,s=this.config;a.aborted||2<=i&&(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(Qe.now(),a.trequest)),4===i?200<=(i=e.status)&&i<300?(a.tload=Math.max(a.tfirst,Qe.now()),r="arraybuffer"===n.responseType?(t=e.response).byteLength:(t=e.responseText).length,a.loaded=a.total=r,r={url:e.responseURL,data:t},this.callbacks.onSuccess(r,a,n,e)):a.retry>=s.maxRetry||400<=i&&i<499?(D.logger.error(i+" while loading "+n.url),this.callbacks.onError({code:i,text:e.statusText},n,e)):(D.logger.warn(i+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),a.retry++):this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout))},t.loadtimeout=function(){D.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats,e=(r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total),this.callbacks.onProgress);e&&e(r,this.context,null,t)},e}();function Je(e,t){for(var r=0;r=this.tracks.length?D.logger.warn("Invalid audio track id:",e.id):(D.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()&&(t=1e3*e.details.targetduration,this.setInterval(t)),!e.details.live&&this.hasInterval()&&this.clearInterval())},a.onAudioTrackSwitched=function(e){e=this.tracks[e.id].groupId;e&&this.audioGroupId!==e&&(this.audioGroupId=e)},a.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},a.onError=function(e){e.type===d.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(D.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},a._setAudioTrack=function(e){var t,r,i;this._trackId===e&&this.tracks[this._trackId].details?D.logger.debug("Same id as current audio-track passed, and track details available -> no-op"):e<0||e>=this.tracks.length?D.logger.warn("Invalid id passed to audio-track controller"):(t=this.tracks[e],D.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e,e=t.url,r=t.type,i=t.id,this.hls.trigger(E.default.AUDIO_TRACK_SWITCHING,{id:i,type:r,url:e}),this._loadTrackDetailsIfNeeded(t))},a.doTick=function(){this._updateTrack(this._trackId)},a._selectAudioGroup=function(e){var e=this.hls.levels[e];e&&e.audioGroupIds&&(e=e.audioGroupIds[e.urlId],this.audioGroupId!==e&&(this.audioGroupId=e,this._selectInitialAudioTrack()))},a._selectInitialAudioTrack=function(){var t,r,e,i=this,a=this.tracks;a.length&&(e=this.tracks[this._trackId],t=null,e&&(t=e.name),this._selectDefaultTrack&&((e=a.filter(function(e){return e.default})).length?a=e:D.logger.warn("No default audio tracks defined")),r=!1,(e=function(){a.forEach(function(e){r||i.audioGroupId&&e.groupId!==i.audioGroupId||t&&t!==e.name||(i._setAudioTrack(e.id),r=!0)})})(),r||(t=null,e()),r||(D.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0})))},a._needsTrackLoading=function(e){var t=e.details,e=e.url;return!(t&&!t.live)&&!!e},a._loadTrackDetailsIfNeeded=function(e){var t;this._needsTrackLoading(e)&&(t=e.url,e=e.id,D.logger.log("loading audio-track playlist for id: "+e),this.hls.trigger(E.default.AUDIO_TRACK_LOADING,{url:t,id:e}))},a._updateTrack=function(e){e<0||e>=this.tracks.length||(this.clearInterval(),this._trackId=e,D.logger.log("trying to update audio-track "+e),e=this.tracks[e],this._loadTrackDetailsIfNeeded(e))},a._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;for(var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,t=t.groupId,a=(D.logger.warn("Loading failed on audio track id: "+e+", group-id: "+t+', name/language: "'+r+'" / "'+i+'"'),e),n=0;nr||i.nextStart))return;D.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=r+.05}if(t.initSegment&&!t.initSegment.data)d=t.initSegment;else if(n<=r){var d=a[0];if(null!==this.videoTrackCC&&d.cc!==this.videoTrackCC&&(c=this.videoTrackCC,d=V.search(a,function(e){return e.ccc?-1:0})),t.live&&d.loadIdx&&d.loadIdx===this.fragLoadIdx)return i=i.nextStart||r,D.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(i+.05)),void(this.media.currentTime=i+.05)}else{var v=f.maxFragLookUpTolerance,i=s?a[s.sn-a[0].sn+1]:void 0,y=function(e){var t=Math.min(v,e.duration);return e.start+e.duration-t<=n?1:e.start-t>n&&e.start?-1:0},l=n=t.startPTS&&(D.logger.log("switching audio track : flushing all audio"),this.state=Re,n.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),this.audioSwitch=!(s=!0),n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))):(this.audioSwitch=!1,n.trigger(E.default.AUDIO_TRACK_SWITCHED,{id:i}))),this.pendingData);if(!o)return D.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void n.trigger(E.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&o.push({type:t.type,data:e,parent:"audio",content:"data"})}),!s&&o.length&&(o.forEach(function(e){r.state===Se&&(r.pendingBuffering=!0,r.hls.trigger(E.default.BUFFER_APPENDING,e))}),this.pendingData=[],this.appended=!0)),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Se&&(this.stats.tparsed=tt.now(),this.state=_e,this._checkAppendedParsed())},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},a.onBufferAppended=function(e){var t;"audio"===e.parent&&((t=this.state)!==Se&&t!==_e||(this.pendingBuffering=0=r.maxBufferLength&&(r.maxMaxBufferLength/=2,D.logger.warn("AudioStreamController: reduce max buffer length to "+r.maxMaxBufferLength+"s")),this.state=T):(D.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Re,this.hls.trigger(E.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})))}},a.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(D.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),e.forEach(function(e){t.hls.trigger(E.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=_e):(this.state=T,this.fragPrevious=null,this.tick())},t=e,(a=[{key:"state",set:function(e){var t;this.state!==e&&(t=this.state,this._state=e,D.logger.log("audio stream:"+t+"->"+e))},get:function(){return this._state}}])&&Ze(t.prototype,a),r&&Ze(t,r),e}(Q),it=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var E={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function T(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function b(e){for(var t=1;t/gi,"\n")}at.prototype={parse:function(e){var i=this;function t(){for(var e=0,t=ut(t=i.buffer);e>>0).toString()}var vt={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},yt=100,Et={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Tt={17:2,18:4,21:6,22:8,23:10,19:13,20:15},bt={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},St={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_t=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],l=((xt={ERROR:0,0:"ERROR",TEXT:1,1:"TEXT",WARNING:2,2:"WARNING",INFO:2})[2]="INFO",xt[xt.DEBUG=3]="DEBUG",xt[xt.DATA=3]="DATA",{verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e];this.verboseLevel}}),Rt=function(){function e(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;ryt&&(l.log("ERROR","Too large cursor position "+this.pos),this.pos=yt)},t.moveCursor=function(e){var t=this.pos+e;if(1=yt?l.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){for(var t=e;t ("+gt([n,s])+")"),(r=(r=(r=(r=this.parseCmd(n,s))||this.parseMidrow(n,s))||this.parsePAC(n,s))||this.parseBackgroundAttributes(n,s))||(i=this.parseChars(n,s))&&(this.currChNr&&0<=this.currChNr?this.channels[this.currChNr-1].insertChars(i):l.log("WARNING","No channel found yet. TEXT-MODE?")),r?this.dataCounters.cmd+=2:i?this.dataCounters.char+=2:(this.dataCounters.other+=2,l.log("WARNING","Couldn't parse cleaned data "+gt([n,s])+" orig: "+gt([t[a],t[a+1]])))):this.dataCounters.padding+=2}},t.parseCmd=function(e,t){var r=null;if(!((20===e||28===e)&&32<=t&&t<=47)&&!((23===e||31===e)&&33<=t&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,l.log("DEBUG","Repeated command ("+gt([e,t])+") is dropped"),!0;var r=20===e||23===e?1:2,i=this.channels[r-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.parseMidrow=function(e,t){var r=null;return(17===e||25===e)&&32<=t&&t<=47&&((r=17===e?1:2)!==this.currChNr?(l.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),l.log("DEBUG","MIDROW ("+gt([e,t])+")"),!0))},t.parsePAC=function(e,t){var r=null;if(!((17<=e&&e<=23||25<=e&&e<=31)&&64<=t&&t<=127)&&!((16===e||24===e)&&64<=t&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,!(this.lastCmdB=null);var i=e<=23?1:2,r=(64<=t&&t<=95?1==i?Et:bt:1==i?Tt:St)[e],r=this.interpretPAC(r,t);return this.channels[i-1].setPAC(r),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=i,!0},t.interpretPAC=function(e,t){var r=t,e={color:null,italics:!1,indent:null,underline:!1,row:e},r=95e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),Ct={parse:function(e,t,i,a,c,h){var r,e=Object(Pe.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f="00:00.000",n=0,s=0,o=0,g=[],l=!0,d=!1,u=new ct;u.oncue=function(e){var t=i[a],r=i.ccOffset;t&&t.new&&(void 0!==s?r=i.ccOffset=t.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,i.new=!1;for(;a&&a.new;)e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC];e.presentationOffset=r}(i,a,o)),o&&(r=o-i.presentationOffset),d&&(e.startTime+=r-s,e.endTime+=r-s),e.id=mt(e.startTime.toString())+mt(e.endTime.toString())+mt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),0=n.length||r!==a||!s||this.stopped?this._clearReloadTimer():(D.logger.log("subtitle track "+r+" loaded"),i.live?(n=se(s.details,i,e.stats.trequest),D.logger.log("Reloading live subtitle playlist in "+n+"ms"),this.timer=setTimeout(function(){t._loadCurrentTrack()},n)):this._clearReloadTimer())},a.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},a.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},a._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},a._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,t=t[e];e<0||!t||t.details&&!t.details.live||(D.logger.log("Loading subtitle track "+e),r.trigger(E.default.SUBTITLE_TRACK_LOADING,{url:t.url,id:e}))},a._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;t&&(t=Ft(t.textTracks),-1===e?[].slice.call(t).forEach(function(e){e.mode="disabled"}):(i=t[i])&&(i.mode="disabled"),(i=t[e])&&(i.mode=r?"showing":"hidden"))},a._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(w.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,D.logger.log("Switching to subtitle track "+e),t.trigger(E.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},a._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Ft(this.media.textTracks),r=0;r=r[n].start&&a<=r[n].end){i=r[n];break}e=t.start+t.duration;i?i.end=e:r.push(i={start:a,end:e})}}},r.onMediaAttached=function(e){e=e.media;(this.media=e).addEventListener("seeking",this._onMediaSeeking),this.state=T},r.onMediaDetaching=function(){var t=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]}),this.media=null,this.state=pe)},r.onError=function(e){e=e.frag;e&&"subtitle"===e.type&&(this.state=T)},r.onSubtitleTracksUpdated=function(e){var t=this;D.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach(function(e){t.tracksBuffered[e.id]=[]})},r.onSubtitleTrackSwitch=function(e){this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId?(e=this.tracks[this.currentTrackId])&&e.details&&this.setInterval(500):this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,e=e.details,r=this.currentTrackId,i=this.tracks,a=i[r];if(!(t>=i.length||t!==r)&&a){if(e.live){var i=a.details,t=e,n=this.lastAVStart,s=(void 0===n&&(n=0),-1),o=(ne(i,t,function(e,t,r){t.start=e.start,s=r}),t.fragments);if(s<0)o.forEach(function(e){e.start+=n});else for(var l=s+1;l "+t)),s.apply(o.console,i)}:r}var s=function(e){if(o.console&&!0===e||"object"==typeof e){!function(t){for(var e=arguments.length,r=new Array(1