From 4bdbc706d7c0dcc38a54b797865c20d01bd89cb2 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Mon, 28 Aug 2023 16:46:09 +0200 Subject: [PATCH 01/55] implement p2p-media-loader : https://github.com/Novage/p2p-media-loader/tree/master --- pod/video/templates/videos/video-header.html | 32 ++- pod/video/templates/videos/video-script.html | 262 ++++++++++++------ .../templates/videos/video_page_content.html | 4 + 3 files changed, 196 insertions(+), 102 deletions(-) diff --git a/pod/video/templates/videos/video-header.html b/pod/video/templates/videos/video-header.html index 7b7ab6c9a5..981c4844a5 100644 --- a/pod/video/templates/videos/video-header.html +++ b/pod/video/templates/videos/video-header.html @@ -1,10 +1,25 @@ {% load static %} + + + - {% with 'video.js/dist/lang/'|add:request.LANGUAGE_CODE|add:'.js' as videojs_lang %} - - {% endwith %} +{% with 'video.js/dist/lang/'|add:request.LANGUAGE_CODE|add:'.js' as videojs_lang %} + +{% endwith %} + + + + + + + + + + @@ -49,16 +64,6 @@ - - - - - - - - @@ -74,7 +79,6 @@ {% if video.overview or playlist_in_get %} - {% endif %} diff --git a/pod/video/templates/videos/video-script.html b/pod/video/templates/videos/video-script.html index 0cb5acc2d6..e67f2ddb44 100644 --- a/pod/video/templates/videos/video-script.html +++ b/pod/video/templates/videos/video-script.html @@ -7,106 +7,191 @@ var seektime = 10; var options = {}; var player; + var engineHlsJs; var initialized_player = function() { - window.onmessage = function(event) { - var evt = event || window.event; - {# maybe use request.get_host to protect it... #} - if(evt.data.type == 'player:play') { - player.play(); - evt.source.postMessage({paused: player.paused(), data: {}}, evt.origin); - } - if(evt.data.type == 'player:pause') { - player.pause(); - evt.source.postMessage({paused: player.paused(), data: {}}, evt.origin); - } - if(evt.data.type == 'player:mute') { - player.muted(true); - evt.source.postMessage({muted: player.muted(), data: {}}, evt.origin); - } - if(evt.data.type == 'player:unmute') { - player.muted(false); - evt.source.postMessage({muted: player.muted(), data: {}}, evt.origin); - } - }; - - options = { - notSupportedMessage: "{% trans 'Please use different browser' %} (Mozilla Firefox, Google Chrome, Safari, Microsoft Edge)", - //language: "fr", //en or nl - {% if video.is_video and request.GET.is_iframe %} - fluid: false, - {% else %} - fluid: true, - {% endif %} - responsive: true, - playbackRates: {{video_playbackrates}}, - userActions: { - hotkeys: function(event) { - // `this` is the player in this context - if (event.code === 'Space') { - event.preventDefault(); - if(!this.paused()) this.pause(); - else this.play(); + window.onmessage = function(event) { + var evt = event || window.event; + {# maybe use request.get_host to protect it... #} + if(evt.data.type == 'player:play') { + player.play(); + evt.source.postMessage({paused: player.paused(), data: {}}, evt.origin); } - if (event.key === 'm') { - event.preventDefault(); - this.muted(!this.muted()); + if(evt.data.type == 'player:pause') { + player.pause(); + evt.source.postMessage({paused: player.paused(), data: {}}, evt.origin); } - if (event.key === 'f') { - event.preventDefault(); - this.requestFullscreen(); + if(evt.data.type == 'player:mute') { + player.muted(true); + evt.source.postMessage({muted: player.muted(), data: {}}, evt.origin); } - // `arrow left` - if (event.code === 'ArrowLeft') { - event.preventDefault(); - this.currentTime(Math.floor(this.currentTime())-seektime); + if(evt.data.type == 'player:unmute') { + player.muted(false); + evt.source.postMessage({muted: player.muted(), data: {}}, evt.origin); } - // `arrow right` - if (event.code === 'ArrowRight') { - event.preventDefault(); - this.currentTime(Math.floor(this.currentTime())+seektime); + }; + var VideoHlsjsConfig = { + maxBufferSize: 0, + maxBufferLength: 10, + liveSyncDurationCount: 10, + } + const p2p_config = { + segments:{ + // number of segments to pass for processing to P2P algorithm + forwardSegmentCount:50, // usually should be equal or greater than p2pDownloadMaxPriority and httpDownloadMaxPriority + swarmId: 'https://pod.univ-lille.fr/media/videos/7f08fab4c221715162d57ff0189ace167c63f9ccfc00c7dbee27ea01065d456f/17137/playlist.m3u8', // any unique string + }, + loader:{ + /** configure personal tracker and STUN servers + * trackerAnnounce: [ + * "wss://personal.tracker1.com", + * "wss://personal.tracker2.com" + * ], + * rtcConfig: { + * iceServers: [ + * { urls: "stun:stun.l.google.com:19302" }, + * { urls: "stun:global.stun.twilio.com:3478?transport=udp" } + * ] + * } + */ + // how long to store the downloaded segments for P2P sharing + cachedSegmentExpiration:86400000, + // count of the downloaded segments to store for P2P sharing + cachedSegmentsCount:1000, + + // first 4 segments (priorities 0, 1, 2 and 3) are required buffer for stable playback + requiredSegmentsPriority:3, + + // each 1 second each of 10 segments ahead of playhead position gets 6% probability for random HTTP download + httpDownloadMaxPriority:9, + httpDownloadProbability:0.06, + httpDownloadProbabilityInterval: 1000, + + // disallow randomly download segments over HTTP if there are no connected peers + httpDownloadProbabilitySkipIfNoPeers: true, + + // P2P will try to download only first 51 segment ahead of playhead position + p2pDownloadMaxPriority: 50, + + // 1 second timeout before retrying HTTP download of a segment in case of an error + httpFailedSegmentTimeout:1000, + + // number of simultaneous downloads for P2P and HTTP methods + simultaneousP2PDownloads:20, + simultaneousHttpDownloads:3, + + // enable mode, that try to prevent HTTP downloads on stream start-up + httpDownloadInitialTimeout: 120000, // try to prevent HTTP downloads during first 2 minutes + httpDownloadInitialTimeoutPerSegment: 17000, // try to prevent HTTP download per segment during first 17 seconds + + // allow to continue aborted P2P downloads via HTTP + httpUseRanges: true, + } + }; + if (p2pml.hlsjs.Engine.isSupported()) { + console.log("p2pml"); + engineHlsJs = new p2pml.hlsjs.Engine(p2p_config); + console.log("Engine ! " + engineHlsJs); + VideoHlsjsConfig["loader"] = engineHlsJs.createLoaderClass(); + engineHlsJs.on(p2pml.core.Events.PeerConnect, onPeerConnect.bind(this)); + engineHlsJs.on(p2pml.core.Events.PeerClose, onPeerClose.bind(this)); + engineHlsJs.on("segment_loaded", (segment, peerId) => console.log("segment_loaded from", peerId ? `peer ${peerId}` : "HTTP", segment.url)); + } + + function onPeerConnect(peer) { + console.log("peer_connect", peer.id, peer.remoteAddress) + } + + function onPeerClose(id) { + console.log("peer_close", peerId) + } + + options = { + notSupportedMessage: "{% trans 'Please use different browser' %} (Mozilla Firefox, Google Chrome, Safari, Microsoft Edge)", + //language: "fr", //en or nl + {% if video.is_video and request.GET.is_iframe %} + fluid: false, + {% else %} + fluid: true, + {% endif %} + responsive: true, + playbackRates: {{video_playbackrates}}, + html5: { + hlsjsConfig: VideoHlsjsConfig, + }, + userActions: { + hotkeys: function(event) { + // `this` is the player in this context + if (event.code === 'Space') { + event.preventDefault(); + if(!this.paused()) this.pause(); + else this.play(); + } + if (event.key === 'm') { + event.preventDefault(); + this.muted(!this.muted()); + } + if (event.key === 'f') { + event.preventDefault(); + this.requestFullscreen(); + } + // `arrow left` + if (event.code === 'ArrowLeft') { + event.preventDefault(); + this.currentTime(Math.floor(this.currentTime())-seektime); + } + // `arrow right` + if (event.code === 'ArrowRight') { + event.preventDefault(); + this.currentTime(Math.floor(this.currentTime())+seektime); + } + if( event.code === "ArrowUp" ) { + event.preventDefault(); + this.volume(this.volume()+0.1); + } + if( event.code === "ArrowDown" ) { + event.preventDefault(); + this.volume(this.volume()-0.1); + } } - if( event.code === "ArrowUp" ) { - event.preventDefault(); - this.volume(this.volume()+0.1); + }, + plugins: { + {% if event is None %} + seekButtons: { + forward: seektime, + back: seektime } - if( event.code === "ArrowDown" ) { - event.preventDefault(); - this.volume(this.volume()-0.1); + {% endif %} + {% if not video.is_video and event is None %} + // enable videojs-wavesurfer plugin + ,wavesurfer: { + backend: 'MediaElement', + displayMilliseconds: true, + debug: false, + waveColor: 'grey', + progressColor: 'black', + cursorColor: 'var(--pod-primary)', + hideScrollbar: false } + {% endif %} } - }, - plugins: { - {% if event is None %} - seekButtons: { - forward: seektime, - back: seektime - } - {% endif %} - {% if not video.is_video and event is None %} - // enable videojs-wavesurfer plugin - ,wavesurfer: { - backend: 'MediaElement', - displayMilliseconds: true, - debug: false, - waveColor: 'grey', - progressColor: 'black', - cursorColor: 'var(--pod-primary)', - hideScrollbar: false - } - {% endif %} } - } - player = videojs('podvideoplayer', options, function(){}); + player = videojs('podvideoplayer', options, function(){}); - player.on('firstplay', function(){ - var data_form = $( "#video_count_form" ).serializeArray(); - jqxhr = $.post( - $( "#video_count_form" ).attr("action"), - data_form - ); - }); + if (p2pml.hlsjs.Engine.isSupported()) { + console.log("init player"); + p2pml.hlsjs.initVideoJsContribHlsJsPlayer(player); + console.log("init ok !"); + } + + player.on('firstplay', function(){ + var data_form = $( "#video_count_form" ).serializeArray(); + jqxhr = $.post( + $( "#video_count_form" ).attr("action"), + data_form + ); + }); {% if video.is_video %} /** get all mp4 format **/ @@ -114,7 +199,8 @@ {% if video.get_playlist_master %} var srcOptions = { - src: '{{video.get_playlist_master.source_file.url}}', + //src: '{{video.get_playlist_master.source_file.url}}', + src: 'https://pod.univ-lille.fr/media/videos/7f08fab4c221715162d57ff0189ace167c63f9ccfc00c7dbee27ea01065d456f/17137/playlist.m3u8', type: '{{video.get_playlist_master.encoding_format}}', }; player.on('loadedmetadata', function() { diff --git a/pod/video/templates/videos/video_page_content.html b/pod/video/templates/videos/video_page_content.html index 39cc936808..7dac3ed359 100644 --- a/pod/video/templates/videos/video_page_content.html +++ b/pod/video/templates/videos/video_page_content.html @@ -116,6 +116,10 @@

{% include 'videos/video-element.html' %} +
+ + +
{% include 'videos/video-all-info.html' %}
{% endif %} {% endblock video-element %} From ce34c8eecc814c1f86320e11e08977ec9d41fe55 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Tue, 29 Aug 2023 11:31:50 +0200 Subject: [PATCH 02/55] add p2p configuration in video script - show p2p stat in video_page_content template --- pod/video/templates/videos/video-script.html | 126 ++++++++++++------ .../templates/videos/video_page_content.html | 7 +- 2 files changed, 91 insertions(+), 42 deletions(-) diff --git a/pod/video/templates/videos/video-script.html b/pod/video/templates/videos/video-script.html index e67f2ddb44..1d2e1f3aca 100644 --- a/pod/video/templates/videos/video-script.html +++ b/pod/video/templates/videos/video-script.html @@ -3,11 +3,18 @@ {% load i18n %} {% get_setting "VIDEO_PLAYBACKRATES" '[0.5, 1, 1.5, 2]' as video_playbackrates %} {% get_setting "USE_VIDEO_EVENT_TRACKING" False as video_event_tracking %} +{% get_setting "USE_VIDEO_P2P" False as use_video_p2p %} + diff --git a/pod/video/templates/videos/video_page_content.html b/pod/video/templates/videos/video_page_content.html index 7dac3ed359..a7698c4228 100644 --- a/pod/video/templates/videos/video_page_content.html +++ b/pod/video/templates/videos/video_page_content.html @@ -116,11 +116,10 @@

{% include 'videos/video-element.html' %} -
- - +
+ 0 | + {% include 'videos/video-all-info.html' %}
-
{% include 'videos/video-all-info.html' %}
{% endif %} {% endblock video-element %} From 1b15d8fd4c096bb3c37a9ac83492d858c7f2fd72 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Wed, 30 Aug 2023 10:57:01 +0200 Subject: [PATCH 03/55] add minus in stats info --- pod/video/templates/videos/video_page_content.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pod/video/templates/videos/video_page_content.html b/pod/video/templates/videos/video_page_content.html index a7698c4228..9f25f463cd 100644 --- a/pod/video/templates/videos/video_page_content.html +++ b/pod/video/templates/videos/video_page_content.html @@ -117,7 +117,7 @@

{% include 'videos/video-element.html' %}

- 0 | + 0 | - {% include 'videos/video-all-info.html' %}
{% endif %} From e781dd7ba85d1994a6204603419468154862bf22 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Thu, 7 Sep 2023 15:36:00 +0200 Subject: [PATCH 04/55] change npm package to get videojs8 and p2p media loader from peertube. Comment other plugin to update version --- pod/package.json | 11 +++++++---- pod/video/templates/videos/video-header.html | 10 +++++++--- pod/video/templates/videos/video-script.html | 8 +++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pod/package.json b/pod/package.json index 9ddfaf9757..fc176abb9f 100644 --- a/pod/package.json +++ b/pod/package.json @@ -1,7 +1,6 @@ { "license": "LGPL-3.0", "dependencies": { - "@silvermine/videojs-quality-selector": "^1.2.5", "blueimp-file-upload": "^10.32.0", "bootstrap": "^5.3.0", "bootstrap-icons": "^1.10.5", @@ -11,16 +10,20 @@ "jquery-ui-dist": "^1.13.2", "js-cookie": "^3.0.5", "spark-md5": "^3.0.2", - "video.js": "^7.18.1", - "videojs-contrib-quality-levels": "^2.1.0", + "video.js": "^8.5.2", + "videojs-contrib-quality-levels": "^4.0.0", "videojs-hls-quality-selector": "^1.1.4", + "videojs-quality-selector-hls": "^1.1.1", "videojs-overlay": "^2.1.5", "videojs-seek-buttons": "^2.2.1", "videojs-vr": "^1.8.0", "videojs-vtt-thumbnails": "^0.0.13", "videojs-wavesurfer": "^3.8.0", "wavesurfer.js": "^6.1.0", - "waypoints": "^4.0.1" + "waypoints": "^4.0.1", + "@silvermine/videojs-quality-selector": "^1.2.5", + "@peertube/p2p-media-loader-core": "^1.0.14", + "@peertube/p2p-media-loader-hlsjs": "^1.0.14" }, "engines": { "yarn": ">= 1.0.0" diff --git a/pod/video/templates/videos/video-header.html b/pod/video/templates/videos/video-header.html index 981c4844a5..d4e6468a51 100644 --- a/pod/video/templates/videos/video-header.html +++ b/pod/video/templates/videos/video-header.html @@ -1,7 +1,8 @@ {% load static %} - - + + + @@ -9,8 +10,9 @@ {% endwith %} - + +{% comment %} @@ -21,6 +23,7 @@ --> + @@ -96,3 +99,4 @@ {% endif %} +{% endcomment %} \ No newline at end of file diff --git a/pod/video/templates/videos/video-script.html b/pod/video/templates/videos/video-script.html index e44d36fb23..ddd841b06d 100644 --- a/pod/video/templates/videos/video-script.html +++ b/pod/video/templates/videos/video-script.html @@ -121,7 +121,7 @@ responsive: true, playbackRates: {{video_playbackrates}}, html5: { - hlsjsConfig: VideoHlsjsConfig, + hlsjsConfig: VideoHlsjsConfig }, userActions: { hotkeys: function(event) { @@ -159,7 +159,7 @@ } } }, - plugins: { + plugins: {/* {% if event is None %} seekButtons: { forward: seektime, @@ -177,7 +177,7 @@ cursorColor: 'var(--pod-primary)', hideScrollbar: false } - {% endif %} + {% endif %}*/ } } @@ -213,9 +213,11 @@ //Add source to player player.src(srcOptions); //add quality selector to player + /* player.hlsQualitySelector({ displayCurrentQuality: true, }); + */ player.on("error", function(e) { e.stopImmediatePropagation(); var error = player.error(); From 6d7d0fce8fec82887817eac36c609b9dbdfd5d61 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Thu, 7 Sep 2023 15:52:16 +0200 Subject: [PATCH 05/55] add videojs-hlsjs-plugin.js --- pod/video/static/js/videojs-hlsjs-plugin.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 pod/video/static/js/videojs-hlsjs-plugin.js diff --git a/pod/video/static/js/videojs-hlsjs-plugin.js b/pod/video/static/js/videojs-hlsjs-plugin.js new file mode 100644 index 0000000000..5448022baf --- /dev/null +++ b/pod/video/static/js/videojs-hlsjs-plugin.js @@ -0,0 +1 @@ +!function(r){var i={};function n(t){var e;return(i[t]||(e=i[t]={i:t,l:!1,exports:{}},r[t].call(e.exports,e,e.exports,n),e.l=!0,e)).exports}n.m=r,n.c=i,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,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(t,e,r){"use strict";var w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O=r(2);function i(t){var e=this;t&&(e.srOptions_||(e.srOptions_={}),e.srOptions_.hlsjsConfig||(e.srOptions_.hlsjsConfig=t.hlsjsConfig),e.srOptions_.captionConfig||(e.srOptions_.captionConfig=t.captionConfig))}t.exports={registerSourceHandler:function(C){var t,_={};function r(i,n){n.name_="StreamrootHlsjs";var s,a=n.el(),o={},l=null,u=null,d=null,c=null,f=null,g=null,p=C(n.options_.playerId),h=p.qualityLevels&&p.qualityLevels(),m=(h&&p.hlsQualitySelector&&(n.hls={}),!1);function v(t){1===o[O.ErrorTypes.MEDIA_ERROR]?s.recoverMediaError():2===o[O.ErrorTypes.MEDIA_ERROR]?(s.swapAudioCodec(),s.recoverMediaError()):2{return r={"./src/config.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{enableStreamingMode:()=>function(t){var e=t.loader;e!==g.default&&e!==f.default?(v.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):(0,g.fetchSupported)()&&(t.loader=g.default,t.progressive=!0,t.enableSoftwareAES=!0,v.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))},hlsDefaultConfig:()=>S,mergeConfig:()=>function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return y({},t,e)}});var e=r("./src/controller/abr-controller.ts"),i=r("./src/controller/audio-stream-controller.ts"),n=r("./src/controller/audio-track-controller.ts"),s=r("./src/controller/subtitle-stream-controller.ts"),a=r("./src/controller/subtitle-track-controller.ts"),o=r("./src/controller/buffer-controller.ts"),l=r("./src/controller/timeline-controller.ts"),u=r("./src/controller/cap-level-controller.ts"),d=r("./src/controller/fps-controller.ts"),c=r("./src/controller/eme-controller.ts"),h=r("./src/controller/cmcd-controller.ts"),f=r("./src/utils/xhr-loader.ts"),g=r("./src/utils/fetch-loader.ts"),p=r("./src/utils/cues.ts"),m=r("./src/utils/mediakeys-helper.ts"),v=r("./src/utils/logger.ts");function y(){return(y=Object.assign?Object.assign.bind():function(t){for(var e=1;e{"use strict";r.r(e),r.d(e,{default:()=>i});var T=r("./src/polyfills/number.ts"),n=r("./src/utils/ewma-bandwidth-estimator.ts"),y=r("./src/events.ts"),s=r("./src/errors.ts"),o=r("./src/types/loader.ts"),S=r("./src/utils/logger.ts");function a(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{default:()=>n});var s=r("./src/polyfills/number.ts"),f=r("./src/controller/base-stream-controller.ts"),g=r("./src/events.ts"),a=r("./src/utils/buffer-helper.ts"),o=r("./src/controller/fragment-tracker.ts"),i=r("./src/types/level.ts"),d=r("./src/types/loader.ts"),p=r("./src/loader/fragment.ts"),c=r("./src/demux/chunk-cache.ts"),h=r("./src/demux/transmuxer-interface.ts"),m=r("./src/types/transmuxer.ts"),l=r("./src/controller/fragment-finders.ts"),u=r("./src/utils/discontinuities.ts"),v=r("./src/errors.ts");function y(){return(y=Object.assign?Object.assign.bind():function(t){for(var e=1;et||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=t+.05),r&&e>r.end+a.targetduration)||(r&&r.len||!s.len)&&((i=this.getNextFragment(e,a))?this.loadFragment(i,a,e):this.bufferFlushed=!0)))))},r.getMaxBufferLength=function(t){var e=n.prototype.getMaxBufferLength.call(this);return t?Math.max(e,t):e},r.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},r.onAudioTracksUpdated=function(t,e){e=e.audioTracks;this.resetTransmuxer(),this.levels=e.map(function(t){return new i.Level(t)})},r.onAudioTrackSwitching=function(t,e){var r=!!e.url,e=(this.trackId=e.id,this.fragCurrent);e&&e.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=f.State.IDLE):this.state=f.State.STOPPED,this.tick()},r.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},r.onLevelLoaded=function(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(g.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},r.onAudioTrackLoaded=function(t,e){if(null==this.mainDetails)this.cachedTrackLoadedData=e;else{var r=this.levels,i=e.details,e=e.id;if(r){this.log("Track "+e+" loaded ["+i.startSN+","+i.endSN+"],duration:"+i.totalduration);var r=r[e],n=0;if(i.live||null!=(s=r.details)&&s.live){var s=this.mainDetails;if(i.fragments[0]||(i.deltaUpdateFailed=!0),i.deltaUpdateFailed||!s)return;n=!r.details&&i.hasProgramDateTime&&s.hasProgramDateTime?((0,u.alignMediaPlaylistByPDT)(i,s),i.fragments[0].start):this.alignPlaylists(i,r.details)}r.details=i,this.levelLastLoaded=e,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(r.details,n),this.state!==f.State.WAITING_TRACK||this.waitForCdnTuneIn(i)||(this.state=f.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+e)}},r._handleFragmentLoadProgress=function(t){var e,r,i,n,s=t.frag,a=t.part,t=t.payload,o=this.config,l=this.trackId,u=this.levels;u?(e=(u=u[l]).details,o=o.defaultAudioCodec||u.audioCodec||"mp4a.40.2",u=(u=this.transmuxer)||(this.transmuxer=new h.default(this.hls,d.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))),r=this.initPTS[s.cc],i=null==(i=s.initSegment)?void 0:i.data,void 0!==r?(n=a?a.index:-1,n=new m.ChunkMetadata(s.level,s.sn,s.stats.chunkCount,t.byteLength,n,-1!==n),u.push(t,i,o,"",s,a,e.totalduration,!1,n,r)):(this.log("Unknown video PTS for cc "+s.cc+", waiting for video PTS before demuxing audio frag "+s.sn+" of ["+e.startSN+" ,"+e.endSN+"],track "+l),(this.waitingData=this.waitingData||{frag:s,part:a,cache:new c.default,complete:!1}).cache.push(new Uint8Array(t)),this.waitingVideoCC=this.videoTrackCC,this.state=f.State.WAITING_INIT_PTS)):this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered")},r._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,t)},r.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},r.onBufferCreated=function(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)},r.onFragBuffered=function(t,e){var r,i=e.frag,e=e.part;i.type!==d.PlaylistLevelType.AUDIO?this.loadedmetadata||i.type!==d.PlaylistLevelType.MAIN||null!=(r=this.videoBuffer||this.media)&&r.buffered.length&&(this.loadedmetadata=!0):this.fragContextChanged(i)?this.warn("Fragment "+i.sn+(e?" p: "+e.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch)&&(this.audioSwitch=!1,this.hls.trigger(g.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.fragBufferedComplete(i,e))},r.onError=function(t,e){if(e.type===v.ErrorTypes.KEY_SYSTEM_ERROR)this.onFragmentOrKeyLoadError(d.PlaylistLevelType.AUDIO,e);else switch(e.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.FRAG_PARSING_ERROR:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(d.PlaylistLevelType.AUDIO,e);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==f.State.ERROR&&this.state!==f.State.STOPPED&&(this.state=e.fatal?f.State.ERROR:f.State.IDLE,this.warn(e.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:var r,i;"audio"!==e.parent||this.state!==f.State.PARSING&&this.state!==f.State.PARSED||(r=!0,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,d.PlaylistLevelType.AUDIO))&&.5{"use strict";r.r(e),r.d(e,{default:()=>i});var l=r("./src/events.ts"),s=r("./src/errors.ts"),e=r("./src/controller/base-playlist-controller.ts"),a=r("./src/types/loader.ts");function o(t,e){for(var r=0;r=o.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),e=o[this.trackId],this.log("Now switching to audio-track index "+t),r=(o=o[t]).id,i=void 0===(i=o.groupId)?"":i,n=o.name,s=o.type,a=o.url,this.trackId=t,this.trackName=n,this.selectDefaultTrack=!1,this.hls.trigger(l.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:i,name:n,type:s,url:a}),o.details&&!o.details.live||(t=this.switchParams(o.url,null==e?void 0:e.details),this.loadPlaylist(t)))},i.selectInitialTrack=function(){this.tracksInGroup;var t=this.trackName,t=this.findTrackId(t)||this.findTrackId();-1!==t?this.setAudioTrack(t):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(l.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},i.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r{"use strict";r.r(e),r.d(e,{default:()=>n});var o=r("./src/types/level.ts"),p=r("./src/controller/level-helper.ts"),l=r("./src/utils/logger.ts"),i=r("./src/errors.ts"),n=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=l.logger.log.bind(l.logger,e+":"),this.warn=l.logger.warn.bind(l.logger,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.onError=function(t,e){!e.fatal||e.type!==i.ErrorTypes.NETWORK_ERROR&&e.type!==i.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r)for(var i=0;ie.partTarget&&(s+=1),new o.HlsUrlParameters(a,0<=s?s:void 0,o.HlsSkip.No)}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},e.playlistLoaded=function(t,e,r){var i=this,n=e.details,s=e.stats,a=self.performance.now(),o=s.loading.first?Math.max(0,a-s.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&0r.tuneInGoal?(this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+h+" with playlist age: "+n.age),h=0):(o+=f=Math.floor(h/n.targetduration),void 0!==u&&(u+=Math.round(h%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+c.toFixed(2)+"s goal: "+h+" skip sn "+f+" to part "+u)),n.tuneInGoal=h),l=this.getDeliveryDirectives(n,e.deliveryDirectives,o,u),d||!g)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,e.deliveryDirectives,o,u);r=this.hls.mainForwardBufferInfo,c=r?r.end-r.len:0,f=1e3*(n.edge-c),h=(0,p.computeReloadInterval)(n,f),d=(n.updated?a>this.requestScheduled+h&&(this.requestScheduled=s.loading.start):this.requestScheduled=-1,void 0!==o&&n.canBlockReload?this.requestScheduled=s.loading.first+h-(1e3*n.partTarget||1e3):this.requestScheduled=(-1===this.requestScheduled?a:this.requestScheduled)+h,this.requestScheduled-a),d=Math.max(0,d);this.log("reload live playlist "+t+" in "+Math.round(d)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(l)},d)}}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,i){var n=(0,o.getSkipValue)(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,n=o.HlsSkip.No),new o.HlsUrlParameters(r,i,n)},e.retryLoadingOrFail=function(t){var e,r=this,i=this.hls.config,n=this.retryCount{"use strict";r.r(e),r.d(e,{State:()=>b,default:()=>i});var d=r("./src/polyfills/number.ts"),e=r("./src/task-loop.ts"),u=r("./src/controller/fragment-tracker.ts"),a=r("./src/utils/buffer-helper.ts"),o=r("./src/utils/logger.ts"),c=r("./src/events.ts"),n=r("./src/errors.ts"),l=r("./src/types/transmuxer.ts"),h=r("./src/utils/mp4-tools.ts"),f=r("./src/utils/discontinuities.ts"),g=r("./src/controller/fragment-finders.ts"),p=r("./src/controller/level-helper.ts"),m=r("./src/loader/fragment-loader.ts"),v=r("./src/crypt/decrypter.ts"),y=r("./src/utils/time-ranges.ts"),E=r("./src/types/loader.ts");function T(t,e){for(var r=0;ri.end)&&(n=n buffer:"+(r?y.default.toString(a.BufferHelper.getBuffered(r)):"(detached)")+")"),this.state=b.IDLE,r&&(!this.loadedmetadata&&t.type==E.PlaylistLevelType.MAIN&&r.buffered.length&&(null==(e=this.fragCurrent)?void 0:e.sn)===(null==(t=this.fragPrevious)?void 0:t.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var e,r,i=this.transmuxer;i&&(r=t.frag,e=t.part,t=!(t=t.partsLoaded)||0===t.length||t.some(function(t){return!t}),r=new l.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,e?e.index:-1,!t),i.flush(r))},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(e,t,r,i){var n=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");var s=null;if(!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&t.encryptedFragments.length&&this.keyLoader.loadClear(e,t.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=b.KEY_LOADING,this.fragCurrent=e,s=this.keyLoader.load(e).then(function(t){if(!n.fragContextChanged(t.frag))return n.hls.trigger(c.Events.KEY_LOADED,t),n.state===b.KEY_LOADING&&(n.state=b.IDLE),t}),this.hls.trigger(c.Events.KEY_LOADING,{frag:e}),this.throwIfFragContextChanged("KEY_LOADING")),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var a=t.partList;if(a&&i){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var o,l=this.getNextPart(a,e,r);if(-1r&&this.flushMainBuffer(i,t.start)):this.flushMainBuffer(0,t.start))},i.getFwdBufferInfo=function(t,e){var r=this.config,i=this.getLoadPosition();if(!(0,d.isFiniteNumber)(i))return null;var n=a.BufferHelper.bufferInfo(t,i,r.maxBufferHole);if(0===n.len&&void 0!==n.nextStart){e=this.fragmentTracker.getBufferedFrag(i,e);if(e&&n.nextStart=t&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},i.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var n,s=this.config,a=r[0].start;if(e.live){var o=s.initialLiveManifestSize;if(it.start&&t.loaded},i.getInitialLiveFragment=function(t,e){var r,i=this.fragPrevious,n=null;return i?(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),n=(0,g.findFragmentByPDT)(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),n||((r=i.sn+1)>=t.startSN&&r<=t.endSN&&(r=e[r-t.startSN],i.cc===r.cc)&&this.log("Live playlist, switching playlist, load frag with next SN: "+(n=r).sn),n)||(n=(0,g.findFragWithCC)(e,i.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)):null!==(r=this.hls.liveSyncPosition)&&(n=this.getFragmentAtPosition(r,this.bitrateTest?t.fragmentEnd:t.edge,t)),n},i.getFragmentAtPosition=function(t,e,r){var i=this.config,n=this.fragPrevious,s=r.fragments,a=r.endSN,o=r.fragmentHint,l=i.maxFragLookUpTolerance,i=!!(i.lowLatencyMode&&r.partList&&o);return i&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),(o=t=n-s.maxFragLookUpTolerance&&r<=i,null!==e)&&a.duration>e&&(r"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+a),n):r):(this.warn("No fragments in live playlist"),0)},i.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},i.setStartPosition=function(t,e){var r,i=this.startPosition;-1!==(i=i"+t))}}])&&T(e.prototype,i),r&&T(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(e.default)},"./src/controller/buffer-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var u=r("./src/polyfills/number.ts"),m=r("./src/events.ts"),v=r("./src/utils/logger.ts"),y=r("./src/errors.ts"),E=r("./src/utils/buffer-helper.ts"),e=r("./src/utils/mediasource-helper.ts"),a=r("./src/loader/fragment.ts"),i=r("./src/controller/buffer-operation-queue.ts"),n=(0,e.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,s=function(){function t(t){var r=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=r.media,e=r.mediaSource;v.logger.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",r._onMediaEmptied),r.updateMediaElementDuration(),r.hls.trigger(m.Events.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){v.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){v.logger.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var t=r.media,e=r._objectUrl;t&&t.src!==e&&v.logger.error("Media element src was set while attaching MediaSource ("+e+" > "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return 0r.config.appendErrorMaxRetry&&(v.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0,r.stopLoad())),r.trigger(m.Events.ERROR,e)}},o)},e.onBufferFlushing=function(t,r){function e(e){return{execute:i.removeExecutor.bind(i,e,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(m.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){v.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}}var i=this,n=this.operationQueue;r.type?n.append(e(r.type),r.type):this.getSourceBufferTypes().forEach(function(t){n.append(e(t),t)})},e.onFragParsed=function(t,e){var r=this,i=e.frag,n=e.part,e=[],s=(n||i).elementaryStreams;s[a.ElementaryStreamTypes.AUDIOVIDEO]?e.push("audiovideo"):(s[a.ElementaryStreamTypes.AUDIO]&&e.push("audio"),s[a.ElementaryStreamTypes.VIDEO]&&e.push("video"));0===e.length&&v.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var t=self.performance.now(),t=(i.stats.buffering.end=t,n&&(n.stats.buffering.end=t),(n||i).stats);r.hls.trigger(m.Events.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})},e)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,i){var n=this;this.getSourceBufferTypes().reduce(function(t,e){var r=n.sourceBuffer[e];return!r||i.type&&i.type!==e||(r.ending=!0,r.ended)||(r.ended=!0,v.logger.log("[buffer-controller]: "+e+" sourceBuffer now EOS")),t&&!(r&&!r.ended)},!0)&&(v.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){n.getSourceBufferTypes().forEach(function(t){t=n.sourceBuffer[t];t&&(t.ending=!1)});var t=n.mediaSource;t&&"open"===t.readyState?(v.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&v.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)}))},e.onLevelUpdated=function(t,e){e=e.details;e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t,e,i,n,s,a=this.hls,o=this.details,r=this.media,l=this.sourceBuffer;r&&null!==o&&(t=this.getSourceBufferTypes()).length&&(e=o.live&&null!==a.config.liveBackBufferLength?a.config.liveBackBufferLength:a.config.backBufferLength,!(0,u.isFiniteNumber)(e)||e<0||(i=r.currentTime,n=o.levelTargetDuration,r=Math.max(e,n),s=Math.floor(i/n)*n-r,t.forEach(function(t){var e=l[t];if(e){var r=E.BufferHelper.getBuffered(e);if(0r.start(0)){if(a.trigger(m.Events.BACK_BUFFER_REACHED,{bufferEnd:s}),o.live)a.trigger(m.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(e.ended&&r.end(r.length-1)-i<2*n)return void v.logger.info("[buffer-controller]: Cannot flush "+t+" back buffer while SourceBuffer is in ended state");a.trigger(m.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:t})}}})))},e.updateMediaElementDuration=function(){var t,e,r,i,n,s;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&(t=this.details,e=this.hls,n=this.media,r=this.mediaSource,i=t.fragments[0].start+t.totalduration,n=n.duration,s=(0,u.isFiniteNumber)(r.duration)?r.duration:0,t.live&&e.config.liveDurationInfinity?(v.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(s{"use strict";r.r(e),r.d(e,{default:()=>i});var s=r("./src/utils/logger.ts"),i=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise(function(t){e=t}),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(e){var r=this.buffers,i=this.queues,r=r[e],i=i[e];if(i.length){var n=i[0];try{n.execute()}catch(t){s.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),n.onError(t),r&&r.updating||(i.shift(),this.executeNext(e))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=r("./src/events.ts");function s(t,e){for(var r=0;rthis.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping)},r.getMaxLevel=function(r){var i=this,t=this.hls.levels;return t.length?(t=t.filter(function(t,e){return n.isLevelAllowed(e,i.restrictedLevels)&&e<=r}),this.clientRect=null,n.getMaxLevelByMediaSize(t,this.mediaWidth,this.mediaHeight)):-1},r.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},r.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},r.getDimensions=function(){var t,e,r;return this.clientRect||(e={width:0,height:0},(t=this.media)&&(r=t.getBoundingClientRect(),e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)),this.clientRect=e)},n.isLevelAllowed=function(t,e){return-1===(e=void 0===e?[]:e).indexOf(t)},n.getMaxLevelByMediaSize=function(t,e,r){if(!t||!t.length)return-1;for(var i,n=t.length-1,s=0;s=e||a.height>=r)&&(a=a,!(i=t[s+1])||a.width!==i.width||a.height!==i.height)){n=s;break}}return n},r=n,(t=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}])&&s(r.prototype,t),e&&s(r,e),Object.defineProperty(r,"prototype",{writable:!1}),n}()},"./src/controller/cmcd-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d});var i=r("./src/events.ts"),a=r("./src/types/cmcd.ts"),n=r("./src/utils/buffer-helper.ts"),o=r("./src/utils/logger.ts");function s(t,e){for(var r=0;r=t.length?{done:!0}:{done:!1,value:t[r++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);re&&(e=n.bitrate)}return 0{"use strict";r.r(e),r.d(e,{default:()=>E});var i=r("./src/events.ts"),d=r("./src/errors.ts"),s=r("./src/utils/logger.ts"),g=r("./src/utils/mediakeys-helper.ts"),c=r("./src/utils/keysystem-util.ts"),p=r("./src/utils/numeric-encoding-utils.ts"),m=r("./src/loader/level-key.ts"),v=r("./src/utils/hex.ts"),y=r("./src/utils/mp4-tools.ts"),e=r("./node_modules/eventemitter3/index.js"),h=r.n(e);function n(t){var r="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return a(t,arguments,l(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function a(t,e,r){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(t){}}()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);e=new(Function.bind.apply(t,i));return r&&o(e,r.prototype),e}).apply(null,arguments)}function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u="[eme]",r=function(){function n(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=n.CDMCleanupPromise?[n.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=s.logger.debug.bind(s.logger,u),this.log=s.logger.log.bind(s.logger,u),this.warn=s.logger.warn.bind(s.logger,u),this.error=s.logger.error.bind(s.logger,u),this.hls=t,this.config=t.config,this.registerListeners()}var t=n.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},t.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},t.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},t.getLicenseServerUrl=function(t){var e=this.config,r=e.drmSystems,e=e.widevineLicenseUrl,r=r[t];if(r)return r.licenseUrl;if(t===g.KeySystems.WIDEVINE&&e)return e;throw new Error('no license server URL configured for key-system "'+t+'"')},t.getServerCertificateUrl=function(t){var e=this.config.drmSystems[t];if(e)return e.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},t.attemptKeySystemAccess=function(t){function e(t,e,r){return!!t&&r.indexOf(t)===e}var a=this,r=this.hls.levels,o=r.map(function(t){return t.audioCodec}).filter(e),l=r.map(function(t){return t.videoCodec}).filter(e);return o.length+l.length===0&&l.push("avc1.42e01e"),new Promise(function(n,s){(function e(r){var i=r.shift();a.getMediaKeysPromise(i,o,l).then(function(t){return n({keySystem:i,mediaKeys:t})}).catch(function(t){r.length?e(r):t instanceof f?s(t):s(new f({type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})})(t)})},t.requestMediaKeySystemAccess=function(t,e){var r,i=this.config.requestMediaKeySystemAccessFunc;return"function"!=typeof i?(r="Configured requestMediaKeySystemAccess is not a function "+i,null===g.requestMediaKeySystemAccess&&"http:"===self.location.protocol&&(r="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(r))):i(t,e)},t.getMediaKeysPromise=function(i,t,e){var n,s=this,t=(0,g.getSupportedMediaKeySystemConfigurations)(i,t,e,this.config.drmSystemOptions),r=this.keySystemAccessPromises[i],e=null==r?void 0:r.keySystemAccess;return e?e.then(function(){return r.mediaKeys}):(this.log('Requesting encrypted media "'+i+'" key-system access with config: '+JSON.stringify(t)),e=this.requestMediaKeySystemAccess(i,t),n=this.keySystemAccessPromises[i]={keySystemAccess:e},e.catch(function(t){s.log('Failed to obtain access to key-system "'+i+'": '+t)}),e.then(function(t){s.log('Access for key-system "'+t.keySystem+'" obtained');var r=s.fetchServerCertificate(i);return s.log('Create media-keys for "'+i+'"'),n.mediaKeys=t.createMediaKeys().then(function(e){return s.log('Media-keys created for "'+i+'"'),r.then(function(t){return t?s.setMediaKeysServerCertificate(e,i,t):e})}),n.mediaKeys.catch(function(t){s.error('Failed to create media-keys for "'+i+'"}: '+t)}),n.mediaKeys}))},t.createMediaKeySessionContext=function(t){var e=t.decryptdata,r=t.keySystem,t=t.mediaKeys,i=(this.log('Creating key-system session "'+r+'" keyId: '+v.default.hexDump(e.keyId||[])),t.createSession()),e={decryptdata:e,keySystem:r,mediaKeys:t,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(e),e},t.renewKeySession=function(t){var e,r,i=t.decryptdata;i.pssh?(e=this.createMediaKeySessionContext(t),r=this.getKeyIdString(i),this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(e,"cenc",i.pssh,"expired")):this.warn("Could not renew expired session. Missing pssh initData."),this.removeSession(t)},t.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return v.default.hexDump(t.keyId)},t.updateKeySession=function(t,e){var r=t.mediaKeysSession;return this.log('Updating key-session "'+r.sessionId+'" for keyID '+v.default.hexDump((null==(t=t.decryptdata)?void 0:t.keyId)||[])+"\n } (data length: "+(e&&e.byteLength)+")"),r.update(e)},t.selectKeySystemFormat=function(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise},t.getKeyFormatPromise=function(n){var s=this;return new Promise(function(r,i){var e=(0,g.getKeySystemsForConfig)(s.config),t=n.map(g.keySystemFormatToKeySystemDomain).filter(function(t){return!!t&&-1!==e.indexOf(t)});return s.getKeySystemSelectionPromise(t).then(function(t){var t=t.keySystem,e=(0,g.keySystemDomainToKeySystemFormat)(t);e?r(e):i(new Error('Unable to find format for key-system "'+t+'"'))}).catch(i)})},t.loadKey=function(i){var n=this,s=i.keyInfo.decryptdata,t=this.getKeyIdString(s),a="(keyId: "+t+' format: "'+s.keyFormat+'" method: '+s.method+" uri: "+s.uri+")",e=(this.log("Starting session for key "+a),this.keyIdToKeySessionPromise[t]);return e||(e=this.keyIdToKeySessionPromise[t]=this.getKeySystemForKeyPromise(s).then(function(t){var e=t.keySystem,r=t.mediaKeys;return n.throwIfDestroyed(),n.log("Handle encrypted media sn: "+i.frag.sn+" "+i.frag.type+": "+i.frag.level+" using key "+a),n.attemptSetMediaKeys(e,r).then(function(){n.throwIfDestroyed();var t=n.createMediaKeySessionContext({keySystem:e,mediaKeys:r,decryptdata:s});return n.generateRequestWithPreferredKeySession(t,"cenc",s.pssh,"playlist-key")})})).catch(function(t){return n.handleError(t)}),e},t.throwIfDestroyed=function(t){if(void 0===t&&(t="Invalid state"),!this.hls)throw new Error("invalid state")},t.handleError=function(t){this.hls&&(this.error(t.message),t instanceof f?this.hls.trigger(i.Events.ERROR,t.data):this.hls.trigger(i.Events.ERROR,{type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},t.getKeySystemForKeyPromise=function(t){var e=this.getKeyIdString(t),e=this.keyIdToKeySessionPromise[e];return e||(t=(e=(0,g.keySystemFormatToKeySystemDomain)(t.keyFormat))?[e]:(0,g.getKeySystemsForConfig)(this.config),this.attemptKeySystemAccess(t))},t.getKeySystemSelectionPromise=function(t){if(0===(t=t.length?t:(0,g.getKeySystemsForConfig)(this.config)).length)throw new f({type:d.ErrorTypes.KEY_SYSTEM_ERROR,details:d.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},t._onMediaEncrypted=function(t){var n,e,s=this,a=t.initDataType,o=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+a+'"'),null!==o){if("sinf"===a&&this.config.drmSystems[g.KeySystems.FAIRPLAY]){t=(0,y.bin2str)(new Uint8Array(o));try{var r=(0,p.base64Decode)(JSON.parse(t).sinf),i=(0,y.parseSinf)(new Uint8Array(r));if(!i)return;n=i.subarray(8,24),e=g.KeySystems.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{t=(0,y.parsePssh)(o);if(null===t)return;0===t.version&&t.systemId===g.KeySystemIds.WIDEVINE&&t.data&&(n=t.data.subarray(8,24)),e=(0,g.keySystemIdToKeySystemDomain)(t.systemId)}if(e&&n){for(var l=v.default.hexDump(n),u=this.keyIdToKeySessionPromise,d=this.mediaKeySessions,c=u[l],h=0;h{"use strict";r.r(e),r.d(e,{default:()=>i});var l=r("./src/events.ts"),u=r("./src/utils/logger.ts");const i=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(l.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(l.Events.MEDIA_ATTACHING,this.onMediaAttaching)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;r.capLevelOnFPSDrop&&(e=e.media instanceof self.HTMLVideoElement?e.media:null,(this.media=e)&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod))},e.checkFPS=function(t,e,r){var i,n,s,a,o=performance.now();e&&(this.lastTime&&(a=o-this.lastTime,i=r-this.lastDroppedFrames,n=e-this.lastDecodedFrames,a=1e3*i/a,(s=this.hls).trigger(l.Events.FPS_DROP,{currentDropped:i,currentDecoded:n,totalDroppedFrames:r}),0s.config.fpsDroppedMonitoringThreshold*n&&(a=s.currentLevel,u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),0=a)&&(s.trigger(l.Events.FPS_DROP_LEVEL_CAPPING,{level:a-=1,droppedLevel:s.currentLevel}),s.autoLevelCapping=a,this.streamController.nextLevelSwitch()),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=e)},e.checkFPSInterval=function(){var t,e=this.media;e&&(this.isVideoPlaybackQualityAvailable?(t=e.getVideoPlaybackQuality(),this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)):this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount))},t}()},"./src/controller/fragment-finders.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{findFragWithCC:()=>function(t,e){return s.default.search(t,function(t){return t.cce?-1:0})},findFragmentByPDT:()=>function(t,e,r){if(null!==e&&Array.isArray(t)&&t.length&&(0,a.isFiniteNumber)(e)){var i=t[0].programDateTime;if(!(e<(i||0))){i=t[t.length-1].endProgramDateTime;if(!((i||0)<=e)){r=r||0;for(var n=0;nfunction(t,e,r,i){void 0===r&&(r=0);void 0===i&&(i=0);var n=null;t?n=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(n=e[0]);if(n&&0===o(r,i,n))return n;e=s.default.search(e,o.bind(null,r,i));return!e||e===t&&n?n:e},fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>l});var a=r("./src/polyfills/number.ts"),s=r("./src/utils/binary-search.ts");function o(t,e,r){return void 0===e&&(e=0),r.start<=(t=void 0===t?0:t)&&r.start+r.duration>t?0:(e=Math.min(e,r.duration+(r.deltaPTS||0)),r.start+r.duration-e<=t?1:r.start-e>t&&r.start?-1:0)}function l(t,e,r){e=1e3*Math.min(e,r.duration+(r.deltaPTS||0));return t<(r.endProgramDateTime||0)-e}},"./src/controller/fragment-tracker.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{FragmentState:()=>i,FragmentTracker:()=>s});var i,n=r("./src/events.ts"),u=r("./src/types/loader.ts"),s=((e=i=i||{}).NOT_LOADED="NOT_LOADED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK",function(){function t(t){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},e.getAppendedFrag=function(t,e){if(e===u.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],a=s?s.end:r.appendedPTS;if(s.start<=t&&void 0!==a&&t<=a)return 9r.startPTS?a.appendedPTS=Math.max(n,a.appendedPTS||0):a.appendedPTS=r.endPTS}}})},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){t=d(t);return!!this.fragments[t]},e.removeFragmentsInRange=function(e,r,i){var n=this;Object.keys(this.fragments).forEach(function(t){var t=n.fragments[t];t&&t.buffered&&(t=t.body).type===i&&t.starte&&n.removeFragment(t)})},e.removeFragment=function(t){var e=d(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),t.appendedPTS=void 0,delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}());function l(t){var e;return t.buffered&&((null==(e=t.range.video)?void 0:e.partial)||(null==(e=t.range.audio)?void 0:e.partial))}function d(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{MAX_START_GAP_JUMP:()=>g,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>p,SKIP_BUFFER_RANGE_START:()=>m,STALL_MINIMUM_DURATION_MS:()=>f,default:()=>i});var u=r("./src/utils/buffer-helper.ts"),d=r("./src/errors.ts"),c=r("./src/events.ts"),h=r("./src/utils/logger.ts"),f=250,g=2,p=.1,m=.05,i=function(){function t(t,e,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,i=this.media,n=this.stalled;if(null!==i){var s=i.currentTime,a=i.seeking,o=this.seeking&&!a,l=!this.seeking&&a;if(this.seeking=a,s!==t)this.moved=!0,null!==n&&(this.stallReported&&(t=self.performance.now()-n,h.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(t)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0);else if((l||o)&&(this.stalled=null),!(i.paused&&!a||i.ended||0===i.playbackRate)&&u.BufferHelper.getBuffered(i).length){t=u.BufferHelper.bufferInfo(i,s,0),l=0g,e=!o||e&&e.start<=s||gr.maxBufferHole&&e>1e3*r.highBufferWatchdogPeriod&&(h.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function(t){var e=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,h.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")"),e.trigger(c.Events.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t.len}))},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(null!==i)for(var n=i.currentTime,s=0,a=u.BufferHelper.getBuffered(i),o=0;o=s&&n{"use strict";r.r(e),r.d(e,{default:()=>n});var o=r("./src/polyfills/number.ts"),i=r("./src/events.ts"),l=r("./src/utils/texttrack-utils.ts"),p=r("./src/demux/id3.ts"),T=r("./src/loader/date-range.ts"),S=r("./src/types/demuxer.ts");function b(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var L=function(){var t=b();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function D(t,e){return t.getTime()/1e3-e}const n=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._registerListeners=function(){var t=this.hls;t.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e._unregisterListeners=function(){var t=this.hls;t.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(i.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(i.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&((0,l.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){t=this.getID3Track(t.textTracks);return t.mode="hidden",t},e.getID3Track=function(t){if(this.media){for(var e=0;ei.startDate&&t.push(r),t},[]).sort(function(t,e){return t.startDate.getTime()-e.startDate.getTime()})[0])&&(o=D(l.startDate,y),s=!0),Object.keys(i.attr)),d=0;d{"use strict";r.r(e),r.d(e,{default:()=>i});var n=r("./src/errors.ts"),s=r("./src/events.ts"),a=r("./src/utils/logger.ts");function o(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{default:()=>i});var f=r("./src/types/level.ts"),g=r("./src/events.ts"),p=r("./src/errors.ts"),m=r("./src/utils/codecs.ts"),v=r("./src/controller/level-helper.ts"),e=r("./src/controller/base-playlist-controller.ts"),d=r("./src/types/loader.ts");function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):l&&t.height!==e.height?t.height-e.height:0}),this._levels=n;for(var c=0;cthis.hls.config.fragLoadingMaxRetry))&&(n=s);break;case p.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var l=i.attrs["HDCP-LEVEL"];l&&(this.hls.maxHdcpLevel=f.HdcpLevels[f.HdcpLevels.indexOf(l)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case p.ErrorDetails.FRAG_PARSING_ERROR:case p.ErrorDetails.KEY_SYSTEM_NO_SESSION:n=(null==(s=e.frag)?void 0:s.type)===d.PlaylistLevelType.MAIN?e.frag.level:this.currentLevelIndex,e.levelRetry=!1;break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(o=!1),n=r.level),a=!0;break;case p.ErrorDetails.REMUX_ALLOC_ERROR:n=null!=(l=e.level)?l:this.currentLevelIndex,a=!0}void 0!==n&&this.recoverLevel(e,n,a,o)}}},i.recoverLevel=function(t,e,r,i){var n=t.details,s=this._levels[e];if(s.loadError++,r){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(i){r=s.url.length;if(1=e.length){var r=t<0;if(this.hls.trigger(g.Events.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:r,reason:"invalid level idx"}),r)return;t=Math.min(t,e.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=e[r],e=e[t],r=(this.log("switching to level "+t+" from "+r),n({},e,{level:this.currentLevelIndex=t,maxBitrate:e.maxBitrate,uri:e.uri,urlId:e.urlId})),t=(delete r._urlId,this.hls.trigger(g.Events.LEVEL_SWITCHING,r),e.details);t&&!t.live||(r=this.switchParams(e.uri,null==i?void 0:i.details),this.loadPlaylist(r))}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){var t;return void 0===this._startLevel?void 0!==(t=this.hls.config.startLevel)?t:this._firstLevel:this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&s(e.prototype,i),r&&s(e,r),Object.defineProperty(e,"prototype",{writable:!1}),t}(e.default)},"./src/controller/level-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{addGroupId:()=>function(t,e,r){switch(e){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(r);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(r)}},addSliding:()=>i,adjustSliding:()=>S,assignTrackIdsByGroup:()=>function(t){var r={};t.forEach(function(t){var e=t.groupId||"";t.id=r[e]=r[e]||0,r[e]++})},computeReloadInterval:()=>function(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;t.updated?(t=t.fragments,t.length&&e<4*r&&(e=1e3*t[t.length-1].duration)function(t,e,r){if(t&&t.details){var t=t.details,i=t.fragments[e-t.startSN];if(i)return i;if((i=t.fragmentHint)&&i.sn===e)return i;if(efunction(t,e,r){if(t&&t.details){var i=t.details.partList;if(i)for(var n=i.length;n--;){var s=i[n];if(s.index===r&&s.fragment.sn===e)return s}}return null},mapFragmentIntersection:()=>T,mapPartIntersection:()=>E,mergeDetails:()=>function(t,r){for(var i=null,e=t.fragments,n=e.length-1;0<=n;n--){var s=e[n].initSegment;if(s){i=s;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var a,o=0;T(t,r,function(t,e){t.relurl&&(o=t.cc-e.cc),(0,f.isFiniteNumber)(t.startPTS)&&(0,f.isFiniteNumber)(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.appendedPTS=t.appendedPTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(a=e),r.PTSKnown=r.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,e.urlId=t.urlId,t.initSegment&&(e.initSegment=t.initSegment,i=t.initSegment)}),i&&(r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments).forEach(function(t){var e;t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)});if(r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(function(t){return!t}),r.deltaUpdateFailed){g.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var l=r.skippedSegments;l--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(t,r,e){var i=m({},t);e&&e.forEach(function(t){delete i[t]});return Object.keys(r).forEach(function(t){var e=new p.DateRange(r[t].attr,i[t]);e.isValid?i[t]=e:g.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(r[t].attr)+'"')}),i}(t.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var u=r.fragments;if(o){g.logger.warn("discontinuity sliding from playlist, take drift into account");for(var d=0;dy,updatePTS:()=>function(t,e,r){e=t[e],t=t[r];v(e,t)}});var f=r("./src/polyfills/number.ts"),g=r("./src/utils/logger.ts"),p=r("./src/loader/date-range.ts");function m(){return(m=Object.assign?Object.assign.bind():function(t){for(var e=1;et.sn?(r=i-t.start,t):(r=t.start-i,e)).duration!==r&&(i.duration=r)):e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function y(t,e,r,i,n,s){i-r<=0&&(g.logger.warn("Fragment should have a positive duration",e),i=r+e.duration,s=n+e.duration);var a,o=r,l=i,u=e.startPTS,d=e.endPTS,c=((0,f.isFiniteNumber)(u)&&(c=Math.abs(u-r),(0,f.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(c,e.deltaPTS):e.deltaPTS=c,o=Math.max(r,u),r=Math.min(r,u),n=Math.min(n,e.startDTS),l=Math.min(i,d),i=Math.max(i,d),s=Math.max(s,e.endDTS)),e.duration=i-r,r-e.start),u=(e.start=e.startPTS=r,e.maxStartPTS=o,e.startDTS=n,e.endPTS=i,e.minEndPTS=l,e.endDTS=s,e.sn);if(!t||ut.endSN)return 0;var d=u-t.startSN,h=t.fragments;for(h[d]=e,a=d;0=t.length||i(e,t[r].start)}function i(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i{"use strict";r.r(e),r.d(e,{default:()=>i});var m=r("./src/polyfills/number.ts"),v=r("./src/controller/base-stream-controller.ts"),s=r("./src/is-supported.ts"),y=r("./src/events.ts"),a=r("./src/utils/buffer-helper.ts"),o=r("./src/controller/fragment-tracker.ts"),c=r("./src/types/loader.ts"),E=r("./src/loader/fragment.ts"),h=r("./src/demux/transmuxer-interface.ts"),f=r("./src/types/transmuxer.ts"),l=r("./src/controller/gap-controller.ts"),u=r("./src/errors.ts");function d(t,e){for(var r=0;ri.end&&(this.backtrackFragment=null),t=this.backtrackFragment?this.backtrackFragment.start:i.end,s=this.getNextFragment(t,n),this.couldBacktrack&&!this.fragPrevious&&s&&"initSegment"!==s.sn&&this.fragmentTracker.getState(s)!==o.FragmentState.OK?(r=(null!=(e=this.backtrackFragment)?e:s).sn-n.startSN,(e=n.fragments[r-1])&&s.cc===e.cc&&this.fragmentTracker.removeFragment(s=e)):this.backtrackFragment&&i.len&&(this.backtrackFragment=null),s&&this.fragmentTracker.getState(s)===o.FragmentState.OK&&this.nextLoadPosition>t&&((e=((r=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO)===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media)&&this.afterBufferFlushed(e,r,c.PlaylistLevelType.MAIN),s=this.getNextFragment(this.nextLoadPosition,n)),s&&(!s.initSegment||s.initSegment.data||this.bitrateTest||(s=s.initSegment),this.loadFragment(s,n,t))))))},i.loadFragment=function(t,e,r){var i=this.fragmentTracker.getState(t);this.fragCurrent=t,i===o.FragmentState.NOT_LOADED?"initSegment"===t.sn?this._loadInitSegment(t,e):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,t,e,r)):i===o.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null==(e=this.media)?void 0:e.buffered.length)&&this.fragmentTracker.removeAllFragments()},i.getAppendedFrag=function(t){t=this.fragmentTracker.getAppendedFrag(t,c.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,c.PlaylistLevelType.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t,e=this.levels,r=this.media;null!=r&&r.readyState&&((t=this.getAppendedFrag(r.currentTime))&&1{"use strict";r.r(e),r.d(e,{SubtitleStreamController:()=>i});var a=r("./src/events.ts"),l=r("./src/utils/buffer-helper.ts"),u=r("./src/controller/fragment-finders.ts"),o=r("./src/utils/discontinuities.ts"),d=r("./src/controller/level-helper.ts"),c=r("./src/controller/fragment-tracker.ts"),h=r("./src/controller/base-stream-controller.ts"),f=r("./src/types/loader.ts"),s=r("./src/types/level.ts");function g(t,e){for(var r=0;r=i[a].start&&s<=i[a].end){n=i[a];break}e=r.start+r.duration;n?n.end=e:i.push(n={start:s,end:e}),this.fragmentTracker.fragBuffered(r)}}},n.onBufferFlushing=function(t,e){var r,i,n,s=e.startOffset,a=e.endOffset;0===s&&a!==Number.POSITIVE_INFINITY&&(r=this.currentTrackId,(i=this.levels).length)&&i[r]&&i[r].details&&((n=a-i[r].details.targetduration)<=0||(e.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(function(t){for(var e=0;e=n.length||e!==i)&&s){this.mediaBuffer=this.mediaBufferTimeRanges;n=0;if(r.live||null!=(i=s.details)&&i.live){i=this.mainDetails;if(r.deltaUpdateFailed||!i)return;var a=i.fragments[0];s.details?0===(n=this.alignPlaylists(r,s.details))&&a&&(n=a.start,(0,d.addSliding)(r,n)):r.hasProgramDateTime&&i.hasProgramDateTime?((0,o.alignMediaPlaylistByPDT)(r,i),n=r.fragments[0].start):a&&(n=a.start,(0,d.addSliding)(r,n))}s.details=r,this.levelLastLoaded=e,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(s.details,n),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===h.State.IDLE&&!(0,u.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)&&(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}},n._handleFragmentLoadComplete=function(t){var r,e=this,i=t.frag,t=t.payload,n=i.decryptdata,s=this.hls;this.fragContextChanged(i)||t&&0>>=0))throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+e+") is greater than the maximum bound ("+r+")");return i[e][t]}this.buffered={get length(){return i.length},end:function(t){return e("end",t,i.length)},start:function(t){return e("start",t,i.length)}}}},"./src/controller/subtitle-track-controller.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var l=r("./src/events.ts"),s=r("./src/utils/texttrack-utils.ts"),e=r("./src/controller/base-playlist-controller.ts"),a=r("./src/types/loader.ts");function o(t,e){for(var r=0;r=o.length||(this.clearTimer(),r=o[t],this.log("Switching to subtitle track "+t),this.trackId=t,r?(o=r.id,i=r.groupId,n=r.name,s=r.type,a=r.url,this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:o,groupId:void 0===i?"":i,name:n,type:s,url:a}),o=this.switchParams(r.url,null==e?void 0:e.details),this.loadPlaylist(o)):this.hls.trigger(l.Events.SUBTITLE_TRACK_SWITCH,{id:t}))):this.queuedDefaultTrack=t},i.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=d(this.media.textTracks),r=0;r{"use strict";r.r(e),r.d(e,{TimelineController:()=>i});var l=r("./src/polyfills/number.ts"),h=r("./src/events.ts"),s=r("./src/utils/cea-608-parser.ts"),a=r("./src/utils/output-filter.ts"),o=r("./src/utils/webvtt-parser.ts"),u=r("./src/utils/texttrack-utils.ts"),d=r("./src/utils/imsc1-ttml-parser.ts"),c=r("./src/utils/mp4-tools.ts"),f=r("./src/types/loader.ts"),g=r("./src/utils/logger.ts"),i=function(){function t(t){var e,r,i,n;this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=p(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions&&(e=new a.default(this,"textTrack1"),r=new a.default(this,"textTrack2"),i=new a.default(this,"textTrack3"),n=new a.default(this,"textTrack4"),this.cea608Parser1=new s.default(1,e,r),this.cea608Parser2=new s.default(3,i,n)),t.on(h.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(h.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(h.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(h.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(h.Events.FRAG_LOADING,this.onFragLoading,this),t.on(h.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(h.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(h.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(h.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(h.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(h.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(h.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(h.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(h.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(h.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(h.Events.FRAG_LOADING,this.onFragLoading,this),t.off(h.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(h.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(h.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(h.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(h.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(h.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,r,i,n){for(var s,a,o,l=!1,u=n.length;u--;){var d=n[u],c=(s=d[0],c=d[1],a=e,Math.min(c,r)-Math.max(s,a));if(0<=c&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],r),l=!0,.5{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}()},"./src/crypt/aes-decryptor.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n,removePadding:()=>function(t){var e=t.byteLength,r=e&&new DataView(t.buffer).getUint8(e-1);if(r)return(0,i.sliceUint8)(t,0,e-r);return t}});var i=r("./src/utils/typed-array.ts");var n=function(){function t(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var e=t.prototype;return e.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},e.initTable=function(){for(var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],r=this.invSubMix,o=r[0],l=r[1],u=r[2],d=r[3],c=new Uint32Array(256),h=0,f=0,g=0,g=0;g<256;g++)c[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=f^f<<1^f<<2^f<<3^f<<4,m=(t[h]=p=p>>>8^255&p^99,c[e[p]=h]),v=c[m],y=c[v],E=257*c[p]^16843008*p;i[h]=E<<24|E>>>8,n[h]=E<<16|E>>>16,s[h]=E<<8|E>>>24,a[h]=E,o[p]=(E=16843009*y^65537*v^257*m^16843008*h)<<24|E>>>8,l[p]=E<<16|E>>>16,u[p]=E<<8|E>>>24,d[p]=E,h?(h=m^c[c[c[y^m]]],f^=c[c[f]]):h=f=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i{"use strict";r.r(e),r.d(e,{default:()=>i});var a=r("./src/crypt/aes-crypto.ts"),o=r("./src/crypt/fast-aes-key.ts"),l=r("./src/crypt/aes-decryptor.ts"),u=r("./src/utils/logger.ts"),d=r("./src/utils/mp4-tools.ts"),c=r("./src/utils/typed-array.ts"),i=function(){function t(t,e){e=(void 0===e?{}:e).removePKCS7Padding,e=void 0===e||e;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e)try{var r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var e=t.prototype;return e.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},e.isSync=function(){return this.useSoftware},e.flush=function(){var t=this.currentResult,e=this.remainderData;return!t||e?(this.reset(),null):(e=new Uint8Array(t),this.reset(),this.removePKCS7Padding?(0,l.removePadding)(e):e)},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(i,n,s){var a=this;return this.useSoftware?new Promise(function(t,e){a.softwareDecrypt(new Uint8Array(i),n,s);var r=a.flush();r?t(r.buffer):e(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(i),n,s)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,n=this.currentResult,s=this.remainderData,s=(this.logOnce("JS AES decrypt"),s&&(t=(0,d.appendUint8Array)(s,t),this.remainderData=null),this.getValidChunk(t));if(!s.length)return null;i&&(r=i);t=this.softwareDecrypter,(t=t||(this.softwareDecrypter=new l.default)).expandKey(e),i=n;return this.currentResult=t.decrypt(s.buffer,0,r),this.currentIV=(0,c.sliceUint8)(s,-16).buffer,i||null},e.webCryptoDecrypt=function(e,r,i){var n=this,s=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new o.default(s,r)),this.fastAesKey.expandKey().then(function(t){return s?(n.logOnce("WebCrypto AES decrypt"),new a.default(s,new Uint8Array(i)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(t){return u.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+t.name+": "+t.message),n.onWebCryptoError(e,r,i)})},e.onWebCryptoError=function(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);t=this.flush();if(t)return t.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},e.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=(0,c.sliceUint8)(t,0,r),this.remainderData=(0,c.sliceUint8)(t,r)),e},e.logOnce=function(t){this.logEnabled&&(u.logger.log("[decrypter]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var e=r("./src/demux/base-audio-demuxer.ts"),i=r("./src/demux/adts.ts"),s=r("./src/utils/logger.ts"),a=r("./src/demux/id3.ts");function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}const n=function(n){var t;function e(t,e){var r=n.call(this)||this;return r.observer=void 0,r.config=void 0,r.observer=t,r.config=e,r}t=n,(r=e).prototype=Object.create(t.prototype),o(r.prototype.constructor=r,t);var r=e.prototype;return r.resetInitSegment=function(t,e,r,i){n.prototype.resetInitSegment.call(this,t,e,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(t)for(var e=(a.getID3Data(t,0)||[]).length,r=t.length;e{"use strict";r.r(e),r.d(e,{appendFrame:()=>function(t,e,r,i,n){var s,a=u(t.samplerate),i=i+n*a,n=d(e,r);{var o;if(n)return a=n.frameLength,n=n.headerLength,a=n+a,(o=Math.max(0,r+a-e.length))?(s=new Uint8Array(a-n)).set(e.subarray(r+n,e.length),0):s=e.subarray(r+n,r+a),n={unit:s,pts:i},o||t.samples.push(n),{sample:n,length:a,missing:o}}t=e.length-r;return(s=new Uint8Array(t)).set(e.subarray(r,e.length),0),{sample:{unit:s,pts:i},length:t,missing:-1}},canGetFrameLength:()=>o,canParse:()=>function(t,e){return o(t,e)&&i(t,e)&&a(t,e)<=t.length-e},getAudioConfig:()=>s,getFrameDuration:()=>u,getFullFrameLength:()=>a,getHeaderLength:()=>n,initTrackConfig:()=>function(t,e,r,i,n){t.samplerate||(e=s(e,r,i,n))&&(t.config=e.config,t.samplerate=e.samplerate,t.channelCount=e.channelCount,t.codec=e.codec,t.manifestCodec=e.manifestCodec,c.logger.log("parsed codec:"+t.codec+", rate:"+e.samplerate+", channels:"+e.channelCount))},isHeader:()=>l,isHeaderPattern:()=>i,parseFrameHeader:()=>d,probe:()=>function(t,e){{var r,i;if(l(t,e))return i=n(t,e),!(e+i>=t.length||(r=a(t,e))<=i)&&((i=e+r)===t.length||l(t,i))}return!1}});var c=r("./src/utils/logger.ts"),h=r("./src/errors.ts"),f=r("./src/events.ts");function s(t,e,r,i){var n,s,a=navigator.userAgent.toLowerCase(),o=i,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],u=1+((192&e[r+2])>>>6),d=(60&e[r+2])>>>2;if(!(l.length-1>>6,c.logger.log("manifest codec:"+i+", ADTS type:"+u+", samplingIndex:"+d),e=/firefox/i.test(a)?6<=d?(u=5,s=new Array(4),d-3):(u=2,s=new Array(2),d):-1!==a.indexOf("android")?(u=2,s=new Array(2),d):(u=5,s=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==n||/vivaldi/i.test(a))||!i&&1==n)&&(u=2,s=new Array(2)),d)),s[0]=u<<3,s[0]|=(14&d)>>1,s[1]|=(1&d)<<7,s[1]|=n<<3,5===u&&(s[1]|=(14&e)>>1,s[2]=(1&e)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:l[d],channelCount:n,codec:"mp4a.40."+u,manifestCodec:o};t.trigger(f.Events.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}function i(t,e){return 255===t[e]&&240==(246&t[e+1])}function n(t,e){return 1&t[e+1]?7:9}function a(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function o(t,e){return e+5{"use strict";r.r(e),r.d(e,{default:()=>i,initPTSFn:()=>m});var d=r("./src/polyfills/number.ts"),c=r("./src/demux/id3.ts"),h=r("./src/types/demuxer.ts"),f=r("./src/demux/dummy-demuxed-track.ts"),g=r("./src/utils/mp4-tools.ts"),p=r("./src/utils/typed-array.ts"),m=function(t,e,r){return(0,d.isFiniteNumber)(t)?90*t:9e4*e+(r||0)};const i=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},e.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=(0,g.appendUint8Array)(this.cachedData,t),this.cachedData=null);var r,i,n=c.getID3Data(t,0),s=n?n.length:0,a=this._audioTrack,o=this._id3Track,l=n?c.getTimeStamp(n):void 0,u=t.length;for((null===this.basePTS||0===this.frameIndex&&(0,d.isFiniteNumber)(l))&&(this.basePTS=m(l,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&0{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t=this.chunks,e=this.dataLength;return t.length?(t=1===t.length?t[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n{"use strict";r.r(e),r.d(e,{dummyTrack:()=>function(t,e){void 0===t&&(t="");void 0===e&&(e=9e4);return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}})},"./src/demux/exp-golomb.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var i=r("./src/utils/logger.ts");const n=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),e=Math.min(4,e);if(0===e)throw new Error("no bytes available");i.set(t.subarray(r,r+e)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e},e.skipBits=function(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t||(t=(t-=this.bitsAvailable)-((e=t>>3)<<3),this.bytesAvailable-=e,this.loadWord()),this.word<<=t,this.bitsAvailable-=t},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(32>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i{"use strict";r.r(e),r.d(e,{canParse:()=>n,decodeFrame:()=>h,getID3Data:()=>i,getID3Frames:()=>o,getTimeStamp:()=>s,isFooter:()=>u,isHeader:()=>l,isTimeStampFrame:()=>a,testables:()=>y,utf8ArrayToStr:()=>v});var d,l=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},u=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},i=function(t,e){for(var r=e,i=0;l(t,e);){i=(i+=10)+c(t,e+6);u(t,e+10)&&(i+=10),e+=i}if(0>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:s=t[u++],l+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=t[u++],a=t[u++],l+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&a)<<0)}}return l},y={decodeTextFrame:g}},"./src/demux/mp3demuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});var e=r("./src/demux/base-audio-demuxer.ts"),i=r("./src/demux/id3.ts"),s=r("./src/utils/logger.ts"),a=r("./src/demux/mpegaudio.ts");function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}const n=function(n){var t;function e(){return n.apply(this,arguments)||this}t=n,(r=e).prototype=Object.create(t.prototype),o(r.prototype.constructor=r,t);var r=e.prototype;return r.resetInitSegment=function(t,e,r,i){n.prototype.resetInitSegment.call(this,t,e,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(t)for(var e=(i.getID3Data(t,0)||[]).length,r=t.length;e{"use strict";r.r(e),r.d(e,{default:()=>i});var s=r("./src/polyfills/number.ts"),a=r("./src/types/demuxer.ts"),d=r("./src/utils/mp4-tools.ts"),c=r("./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;const i=function(){function t(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}var e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(t,e,r,i){var n,s,a,o=this.videoTrack=(0,c.dummyTrack)("video",1),l=this.audioTrack=(0,c.dummyTrack)("audio",1),u=this.txtTrack=(0,c.dummyTrack)("text",1);this.id3Track=(0,c.dummyTrack)("id3",1),this.timeOffset=0,t&&t.byteLength&&((t=(0,d.parseInitSegment)(t)).video&&(n=(a=t.video).id,s=a.timescale,a=a.codec,o.id=n,o.timescale=u.timescale=s,o.codec=a),t.audio&&(s=(n=t.audio).id,a=n.timescale,t=n.codec,l.id=s,l.timescale=a,l.codec=t),u.id=d.RemuxerTrackIdConfig.text,o.sampleDuration=0,o.duration=l.duration=i)},e.resetContiguity=function(){},t.probe=function(t){return t=16384{"use strict";r.r(e),r.d(e,{appendFrame:()=>function(t,e,r,i,n){if(!(r+24>e.length)){var s,a=o(e,r);if(a&&r+a.frameLength<=e.length)return s=9e4*a.samplesPerFrame/a.sampleRate,i=i+n*s,n={unit:e.subarray(r,r+a.frameLength),pts:i,dts:i},t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(n),{sample:n,length:a.frameLength,missing:0}}},canParse:()=>function(t,e){return n(t,e)&&4<=t.length-e},isHeader:()=>s,isHeaderPattern:()=>n,parseHeader:()=>o,probe:()=>function(t,e){{var r,i;if(e+1>3&3,l=t[e+1]>>1&3,u=t[e+2]>>4&15,d=t[e+2]>>2&3;if(1!=o&&0!=u&&15!=u&&3!=d)return a=t[e+2]>>1&1,r=t[e+3]>>6,u=1e3*h[14*(3==o?3-l:3==l?3:4)+u-1],d=f[3*(3==o?0:2==o?1:2)+d],i=3==r?1:2,s=8*(o=g[o][l])*(n=p[l]),o=Math.floor(o*u/d+a)*n,null===c&&(a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),c=a?parseInt(a[1]):0),!!c&&c<=87&&2==l&&224e3<=u&&0==r&&(t[e+3]=128|t[e+3]),{sampleRate:d,channelCount:i,frameLength:o,samplesPerFrame:s}}function n(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function s(t,e){return e+1{"use strict";r.r(e),r.d(e,{default:()=>n});var i=r("./src/crypt/decrypter.ts"),l=r("./src/utils/mp4-tools.ts");const n=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function(e,r,i){var t,n=this,s=e[r].unit;s.length<=16||(t=(t=s.subarray(16,s.length-s.length%16)).buffer.slice(t.byteOffset,t.byteOffset+t.length),this.decryptBuffer(t).then(function(t){t=new Uint8Array(t);s.set(t,16),n.decrypter.isSync()||n.decryptAacSamples(e,r+1,i)}))},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(t,e,r,i,s),this.decrypter.isSync())))return}}},t}()},"./src/demux/transmuxer-interface.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var l=r("./src/demux/webworkify-webpack.js"),u=r("./src/events.ts"),b=r("./src/demux/transmuxer.ts"),L=r("./src/utils/logger.ts"),d=r("./src/errors.ts"),e=r("./src/utils/mediasource-helper.ts"),c=r("./node_modules/eventemitter3/index.js"),h=(0,e.getMediaSource)()||{isTypeSupported:function(){return!1}},i=function(){function t(e,r,i,t){function n(t,e){(e=e||{}).frag=a.frag,e.id=a.id,a.hls.trigger(t,e)}var s,a=this,o=(this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,e.config),e=(this.hls=e,this.id=r,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=t,this.observer=new c.EventEmitter,this.observer.on(u.Events.FRAG_DECRYPTED,n),this.observer.on(u.Events.ERROR,n),{mp4:h.isTypeSupported("video/mp4"),mpeg:h.isTypeSupported("audio/mpeg"),mp3:h.isTypeSupported('audio/mp4; codecs="mp3"')}),i=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){L.logger.log("demuxing in webworker");try{s=this.worker=(0,l.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),s.addEventListener("message",this.onwmsg),s.onerror=function(t){a.useWorker=!1,L.logger.warn("Exception in webworker, fallback to inline"),a.hls.trigger(u.Events.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(t.message+" ("+t.filename+":"+t.lineno+")")})},s.postMessage({cmd:"init",typeSupported:e,vendor:i,id:r,config:JSON.stringify(o)})}catch(t){L.logger.warn("Error in worker:",t),L.logger.error("Error while initializing DemuxerWorker, fallback to inline"),s&&self.URL.revokeObjectURL(s.objectURL),this.transmuxer=new b.default(this.observer,e,o,i,r),this.worker=null}}else this.transmuxer=new b.default(this.observer,e,o,i,r)}var e=t.prototype;return e.destroy=function(){var t=this.worker,t=(t?(t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null,this.onwmsg=void 0):(t=this.transmuxer)&&(t.destroy(),this.transmuxer=null),this.observer);t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},e.push=function(t,e,r,i,n,s,a,o,l,u){var d=this,c=(l.transmuxing.start=self.performance.now(),this.transmuxer),h=this.worker,f=(s||n).start,g=n.decryptdata,p=this.frag,m=!(p&&n.cc===p.cc),v=!(p&&l.level===p.level),y=p?l.sn-p.sn:-1,E=this.part?l.part-this.part.index:-1,T=0==y&&1{"use strict";r.r(e),r.d(e,{default:()=>function(n){function s(t,e){n.postMessage({event:t,data:e})}function a(){for(var t in d.logger)!function(e){d.logger[e]=function(t){s("workerLog",{logType:e,message:t})}}(t)}var o=new i.EventEmitter;o.on(u.Events.FRAG_DECRYPTED,s),o.on(u.Events.ERROR,s);n.addEventListener("message",function(t){var e=t.data;switch(e.cmd){case"init":var r=JSON.parse(e.config);n.transmuxer=new l.default(o,e.typeSupported,r,e.vendor,e.id),(0,d.enableLogs)(r.debug,e.id),a(),s("init",null);break;case"configure":n.transmuxer.configure(e.config);break;case"demux":r=n.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);(0,l.isPromise)(r)?(n.transmuxer.async=!0,r.then(function(t){h(n,t)}).catch(function(t){s(u.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:e.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})})):(n.transmuxer.async=!1,h(n,r));break;case"flush":var i=e.chunkMeta,r=n.transmuxer.flush(i);(0,l.isPromise)(r)||n.transmuxer.async?(r=(0,l.isPromise)(r)?r:Promise.resolve(r)).then(function(t){f(n,t,i)}).catch(function(t){s(u.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:e.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})}):f(n,r,i)}})}});var l=r("./src/demux/transmuxer.ts"),u=r("./src/events.ts"),d=r("./src/utils/logger.ts"),i=r("./node_modules/eventemitter3/index.js"),c=r("./src/errors.ts");function h(t,e){var r,i,n;return!!((r=e.remuxResult).audio||r.video||r.text||r.id3||r.initSegment)&&(r=[],i=(n=e.remuxResult).audio,n=n.video,i&&s(r,i),n&&s(r,n),t.postMessage({event:"transmuxComplete",data:e},r),!0)}function s(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function f(r,t,e){t.reduce(function(t,e){return h(r,e)||t},!1)||r.postMessage({event:"transmuxComplete",data:t[0]}),r.postMessage({event:"flush",data:e})}},"./src/demux/transmuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{TransmuxConfig:()=>c,TransmuxState:()=>m,default:()=>u,isPromise:()=>d});var E,o=r("./src/events.ts"),l=r("./src/errors.ts"),i=r("./src/crypt/decrypter.ts"),e=r("./src/demux/aacdemuxer.ts"),h=r("./src/demux/mp4demuxer.ts"),n=r("./src/demux/tsdemuxer.ts"),s=r("./src/demux/mp3demuxer.ts"),a=r("./src/remux/mp4-remuxer.ts"),f=r("./src/remux/passthrough-remuxer.ts"),g=r("./src/utils/logger.ts");try{E=self.performance.now.bind(self.performance)}catch(t){g.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var p=[{demux:h.default,remux:f.default},{demux:n.default,remux:a.default},{demux:e.default,remux:a.default},{demux:s.default,remux:a.default}],u=function(){function t(t,e,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,i){var n=this,s=r.transmuxing,t=(s.executeStart=E(),new Uint8Array(t)),a=this.currentTransmuxState,o=this.transmuxConfig,i=(i&&(this.currentTransmuxState=i),i||a),a=i.contiguous,l=i.discontinuity,u=i.trackSwitch,d=i.accurateTimeOffset,c=i.timeOffset,i=i.initSegmentChange,h=o.audioCodec,f=o.videoCodec,g=o.defaultInitPts,p=o.duration,o=o.initSegmentData,m=function(t,e){var r=null;0{"use strict";r.r(e),r.d(e,{default:()=>a});var g=r("./src/demux/adts.ts"),l=r("./src/demux/mpegaudio.ts"),f=r("./src/demux/exp-golomb.ts"),i=r("./src/demux/sample-aes.ts"),_=r("./src/events.ts"),w=r("./src/utils/mp4-tools.ts"),O=r("./src/utils/logger.ts"),P=r("./src/errors.ts"),n=r("./src/types/demuxer.ts");function s(){return(s=Object.assign?Object.assign.bind():function(t){for(var e=1;et.size-6)return null;var o=h[7],l=(192&o&&(r=536870912*(14&h[9])+4194304*(255&h[10])+16384*(254&h[11])+128*(255&h[12])+(254&h[13])/2,64&o?54e5>4,k=void 0;if(1{"use strict";h.r(e),h.d(e,{default:()=>function(t,e){e=e||{};var r={main:h.m},i=e.all?{main:Object.keys(r.main)}:function(t,e){var r={main:[e]},i={main:[]},n={main:{}};for(;function(r){return Object.keys(r).reduce(function(t,e){return t||0/);if(e){for(var s,e=e[1],a=new RegExp("(\\\\n|\\W)"+p(e)+g,"g");s=a.exec(n);)"dll-reference"!==s[3]&&i[r].push(s[3]);for(a=new RegExp("\\("+p(e)+'\\("(dll-reference\\s('+f+'))"\\)\\)'+g,"g");s=a.exec(n);)t[s[2]]||(i[r].push(s[1]),t[s[2]]=h(s[1]).m),i[s[2]]=i[s[2]]||[],i[s[2]].push(s[4]);for(var o=Object.keys(i),l=0;l{"use strict";var i,n;r.r(e),r.d(e,{ErrorDetails:()=>n,ErrorTypes:()=>i}),(r=i=i||{}).NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",(e=n=n||{}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"},"./src/events.ts":(t,e,r)=>{"use strict";var i;r.r(e),r.d(e,{Events:()=>i}),(r=i=i||{}).MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached"},"./src/hls.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var n=r("./node_modules/url-toolkit/src/url-toolkit.js"),h=r("./src/loader/playlist-loader.ts"),f=r("./src/controller/id3-track-controller.ts"),g=r("./src/controller/latency-controller.ts"),p=r("./src/controller/level-controller.ts"),m=r("./src/controller/fragment-tracker.ts"),v=r("./src/loader/key-loader.ts"),y=r("./src/controller/stream-controller.ts"),i=r("./src/is-supported.ts"),E=r("./src/utils/logger.ts"),T=r("./src/config.ts"),S=r("./node_modules/eventemitter3/index.js"),s=r("./src/events.ts"),a=r("./src/errors.ts"),o=r("./src/types/level.ts");function l(t,e){for(var r=0;r=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,e=this.autoLevelCapping,r=this.maxHdcpLevel,e=-1===e&&t&&t.length?t.length-1:e;if(r)for(var i=e;i--;){var n=t[i].attrs["HDCP-LEVEL"];if(n&&n<=r)return i}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&l(r.prototype,t),e&&l(r,e),Object.defineProperty(r,"prototype",{writable:!1}),c}();u.defaultConfig=void 0},"./src/is-supported.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{changeTypeSupported:()=>function(){var t=n();return"function"==typeof(null==t||null==(t=t.prototype)?void 0:t.changeType)},isSupported:()=>function(){var t,e=(0,i.getMediaSource)();return!!e&&(t=n(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove,!!e)&&!!t}});var i=r("./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}},"./src/loader/date-range.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{DateRange:()=>i,DateRangeAttribute:()=>n});var n,s=r("./src/polyfills/number.ts"),a=r("./src/utils/attr-list.ts"),o=r("./src/utils/logger.ts");function l(){return(l=Object.assign?Object.assign.bind():function(t){for(var e=1;e{"use strict";r.r(e),r.d(e,{LoadError:()=>p,default:()=>l});var a=r("./src/polyfills/number.ts"),h=r("./src/errors.ts");function i(t){var r="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return n(t,arguments,s(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function n(t,e,r){return(n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(t){}}()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);e=new(Function.bind.apply(t,i));return r&&o(e,r.prototype),e}).apply(null,arguments)}function o(t,e){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var f=Math.pow(2,17),l=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(a,o){var l=this,t=a.url;if(!t)return Promise.reject(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var r=this.config,u=r.fLoader,d=r.loader;return new Promise(function(n,i){l.loader&&l.loader.destroy();var s=l.loader=a.loader=new(u||d)(r),t=g(a),e={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===a.sn?1/0:f};a.stats=s.stats,s.load(t,e,{onSuccess:function(t,e,r,i){l.resetLoader(a,s);t=t.data;r.resetIV&&a.decryptdata&&(a.decryptdata.iv=new Uint8Array(t.slice(0,16)),t=t.slice(16)),n({frag:a,part:null,payload:t,networkDetails:i})},onError:function(t,e,r){l.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,response:t,networkDetails:r}))},onAbort:function(t,e,r){l.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,networkDetails:r}))},onTimeout:function(t,e,r){l.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,networkDetails:r}))},onProgress:function(t,e,r,i){o&&o({frag:a,part:null,payload:r,networkDetails:i})}})})},e.loadPart=function(a,o,l){var u=this,r=(this.abort(),this.config),d=r.fLoader,c=r.loader;return new Promise(function(n,i){u.loader&&u.loader.destroy();var s=u.loader=a.loader=new(d||c)(r),t=g(a,o),e={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:f};o.stats=s.stats,s.load(t,e,{onSuccess:function(t,e,r,i){u.resetLoader(a,s),u.updateStatsFromPart(a,o);t={frag:a,part:o,payload:t.data,networkDetails:i};l(t),n(t)},onError:function(t,e,r){u.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:a,part:o,response:t,networkDetails:r}))},onAbort:function(t,e,r){a.stats.aborted=o.stats.aborted,u.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:a,part:o,networkDetails:r}))},onTimeout:function(t,e,r){u.resetLoader(a,s),i(new p({type:h.ErrorTypes.NETWORK_ERROR,details:h.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:a,part:o,networkDetails:r}))}})})},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total,t=(r.loaded+=i.loaded,n?(n=((t=Math.round(t.duration/e.duration))-(e=Math.min(Math.round(r.loaded/n),t)))*Math.round(r.loaded/e),r.total=r.loaded+n):r.total=Math.max(r.loaded,r.total),r.loading),e=i.loading;t.start?t.first+=e.first-e.start:(t.start=e.start,t.first=e.first),t.end=e.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function g(t,e){var r,i,n=(e=void 0===e?null:e)||t,e={frag:t,part:e,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,n=n.byteRangeEndOffset;return(0,a.isFiniteNumber)(s)&&(0,a.isFiniteNumber)(n)&&(r=s,i=n,"initSegment"===t.sn&&"AES-128"===(null==(t=t.decryptdata)?void 0:t.method)&&((t=n-s)%16&&(i=n+(16-t%16)),0!==s)&&(e.resetIV=!0,r=s-16),e.rangeStart=r,e.rangeEnd=i),e}var p=function(s){var t,e;function r(t){for(var e,r=arguments.length,i=new Array(1{"use strict";r.r(e),r.d(e,{BaseSegment:()=>c,ElementaryStreamTypes:()=>i,Fragment:()=>h,Part:()=>f});var i,n=r("./src/polyfills/number.ts"),s=r("./node_modules/url-toolkit/src/url-toolkit.js"),a=r("./src/loader/load-stats.ts");function o(t,e){t.prototype=Object.create(e.prototype),l(t.prototype.constructor=t,e)}function l(t,e){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{default:()=>i});var u=r("./src/errors.ts"),n=r("./src/loader/fragment-loader.ts"),i=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(){for(var t in this.keyUriToKeyInfo){t=this.keyUriToKeyInfo[t].loader;t&&t.abort()}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){t=this.keyUriToKeyInfo[t].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,i){return void 0===e&&(e=u.ErrorDetails.KEY_LOAD_ERROR),new n.LoadError({type:u.ErrorTypes.NETWORK_ERROR,details:e,fatal:!1,frag:t,networkDetails:r})},e.loadClear=function(t,r){var i=this;if(this.emeController&&this.config.emeEnabled)for(var n=t.sn,s=t.cc,e=0;e{"use strict";r.r(e),r.d(e,{LevelDetails:()=>i});var n=r("./src/polyfills/number.ts");function s(t,e){for(var r=0;rt.endSN||0{"use strict";r.r(e),r.d(e,{LevelKey:()=>i});var a=r("./src/utils/keysystem-util.ts"),o=r("./src/utils/mediakeys-helper.ts"),l=r("./src/utils/mp4-tools.ts"),u=r("./src/utils/logger.ts"),d=r("./src/utils/numeric-encoding-utils.ts"),c={},i=function(){function s(t,e,r,i,n){void 0===i&&(i=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}s.clearKeyUriToKeyIdMap=function(){c={}};var t=s.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;switch(this.keyFormat){case"identity":return"SAMPLE-AES"===this.method;case o.KeySystemFormats.FAIRPLAY:case o.KeySystemFormats.WIDEVINE:case o.KeySystemFormats.PLAYREADY:case o.KeySystemFormats.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv)return"number"!=typeof t&&("AES-128"!==this.method||this.iv||u.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0),t=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e}(t),new s(this.method,this.uri,"identity",this.keyFormatVersions,t);var e,r=(0,a.convertDataUriToArrayBytes)(this.uri);if(r)switch(this.keyFormat){case o.KeySystemFormats.WIDEVINE:22<=(this.pssh=r).length&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case o.KeySystemFormats.PLAYREADY:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]),i=(this.pssh=(0,l.mp4pssh)(i,null,r),new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2)),i=String.fromCharCode.apply(null,Array.from(i)),i=i.substring(i.indexOf("<"),i.length),i=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];i&&(i=i.childNodes[0]?i.childNodes[0].nodeValue:i.getAttribute("VALUE"))&&(i=(0,d.base64Decode)(i).subarray(0,16),(0,a.changeEndianness)(i),this.keyId=i);break;default:var n,i=r.subarray(0,16);16!==i.length&&((n=new Uint8Array(16)).set(i,16-i.length),i=n),this.keyId=i}return this.keyId&&16===this.keyId.byteLength||((t=c[this.uri])||(e=Object.keys(c).length%Number.MAX_SAFE_INTEGER,t=new Uint8Array(16),new DataView(t.buffer,12,4).setUint32(0,e),c[this.uri]=t),this.keyId=t),this},s}()},"./src/loader/load-stats.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{LoadStats:()=>i});var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>u});var M=r("./src/polyfills/number.ts"),i=r("./node_modules/url-toolkit/src/url-toolkit.js"),N=r("./src/loader/date-range.ts"),U=r("./src/loader/fragment.ts"),B=r("./src/loader/level-details.ts"),o=r("./src/loader/level-key.ts"),G=r("./src/utils/attr-list.ts"),K=r("./src/utils/logger.ts"),h=r("./src/utils/codecs.ts");function H(){return(H=Object.assign?Object.assign.bind():function(t){for(var e=1;e{"use strict";r.r(e),r.d(e,{default:()=>i});var d=r("./src/polyfills/number.ts"),h=r("./src/events.ts"),c=r("./src/errors.ts"),f=r("./src/utils/logger.ts"),g=r("./src/loader/m3u8-parser.ts"),p=r("./src/types/loader.ts"),m=r("./src/utils/attr-list.ts");function v(t,e){t=t.url;return t=void 0!==t&&0!==t.indexOf("data:")?t:e.url}const i=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.registerListeners=function(){var t=this.hls;t.on(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(h.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(h.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(h.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(h.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(h.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(h.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(h.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,r=new(r||i)(e);return t.loader=r,this.loaders[t.type]=r},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){e=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:p.PlaylistContextType.MANIFEST,url:e,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.url,e=e.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:p.PlaylistContextType.LEVEL,url:n,deliveryDirectives:e})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,e=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:p.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:e})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,e=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:p.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:e})},e.load=function(t){var e,r,i,n,s=this.hls.config;if(o=this.getInternalLoader(t)){var a=o.context;if(a&&a.url===t.url)return void f.logger.trace("[playlist-loader]: playlist request ongoing");f.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),o.abort()}switch(t.type){case p.PlaylistContextType.MANIFEST:e=s.manifestLoadingMaxRetry,r=s.manifestLoadingTimeOut,i=s.manifestLoadingRetryDelay,n=s.manifestLoadingMaxRetryTimeout;break;case p.PlaylistContextType.LEVEL:case p.PlaylistContextType.AUDIO_TRACK:case p.PlaylistContextType.SUBTITLE_TRACK:e=0,r=s.levelLoadingTimeOut;break;default:e=s.levelLoadingMaxRetry,r=s.levelLoadingTimeOut,i=s.levelLoadingRetryDelay,n=s.levelLoadingMaxRetryTimeout}var o=this.createInternalLoader(t),a={timeout:r=null!=(a=t.deliveryDirectives)&&a.part&&(t.type===p.PlaylistContextType.LEVEL&&null!==t.level?l=this.hls.levels[t.level].details:t.type===p.PlaylistContextType.AUDIO_TRACK&&null!==t.id?l=this.hls.audioTracks[t.id].details:t.type===p.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(l=this.hls.subtitleTracks[t.id].details),l)&&(a=l.partTarget,l=l.targetduration,a)&&l?Math.min(1e3*Math.max(3*a,.8*l),r):r,maxRetry:e,retryDelay:i,maxRetryDelay:n,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(t,a,l)},e.loadsuccess=function(t,e,r,i){void 0===i&&(i=null),this.resetInternalLoader(r.type);var n=t.data;0!==n.indexOf("#EXTM3U")?this.handleManifestParsingError(t,r,"no EXTM3U delimiter",i):(e.parsing.start=performance.now(),0{"use strict";r.r(e),r.d(e,{MAX_SAFE_INTEGER:()=>n,isFiniteNumber:()=>i});var i=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i=function(){function t(){}return t.getSilentFrame=function(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},t}()},"./src/remux/mp4-generator.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var s=Math.pow(2,32)-1,r=function(){function c(){}return c.init=function(){for(var t in c.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]})c.types.hasOwnProperty(t)&&(c.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var e=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]),r=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]),e=(c.HDLR_TYPES={video:e,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(c.STTS=c.STSC=c.STCO=r,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);c.FTYP=c.box(c.types.ftyp,r,n,r,i),c.DINF=c.box(c.types.dinf,c.box(c.types.dref,e))},c.box=function(t){for(var e=8,r=arguments.length,i=new Array(1>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),s=0,e=8;s>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,85,196,0,0]))},c.mdia=function(t){return c.box(c.types.mdia,c.mdhd(t.timescale,t.duration),c.hdlr(t.type),c.minf(t))},c.mfhd=function(t){return c.box(c.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},c.minf=function(t){return"audio"===t.type?c.box(c.types.minf,c.box(c.types.smhd,c.SMHD),c.DINF,c.stbl(t)):c.box(c.types.minf,c.box(c.types.vmhd,c.VMHD),c.DINF,c.stbl(t))},c.moof=function(t,e,r){return c.box(c.types.moof,c.mfhd(t),c.traf(r,e))},c.moov=function(t){for(var e=t.length,r=[];e--;)r[e]=c.trak(t[e]);return c.box.apply(null,[c.types.moov,c.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(c.mvex(t)))},c.mvex=function(t){for(var e=t.length,r=[];e--;)r[e]=c.trex(t[e]);return c.box.apply(null,[c.types.mvex].concat(r))},c.mvhd=function(t,e){e*=t;var r=Math.floor(e/(1+s)),e=Math.floor(e%(1+s)),t=new Uint8Array([1,0,0,0,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,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,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 c.box(c.types.mvhd,t)},c.sdtp=function(t){for(var e,r=t.samples||[],i=new Uint8Array(4+r.length),n=0;n>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(e));for(s=0;s>>8&255),n.push(255&r),n=n.concat(Array.prototype.slice.call(e));var a=c.box(c.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(n))),o=t.width,l=t.height,u=t.pixelRatio[0],d=t.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,o>>8&255,255&o,l>>8&255,255&l,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]),a,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([u>>24,u>>16&255,u>>8&255,255&u,d>>24,d>>16&255,d>>8&255,255&d])))},c.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},c.mp4a=function(t){var e=t.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,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),c.box(c.types.esds,c.esds(t)))},c.mp3=function(t){var e=t.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,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},c.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?c.box(c.types.stsd,c.STSD,c.mp3(t)):c.box(c.types.stsd,c.STSD,c.mp4a(t)):c.box(c.types.stsd,c.STSD,c.avc1(t))},c.tkhd=function(t){var e=t.id,r=t.duration*t.timescale,i=t.width,t=t.height,n=Math.floor(r/(1+s)),r=Math.floor(r%(1+s));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,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,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,t>>8&255,255&t,0,0]))},c.traf=function(t,e){var r=c.sdtp(t),i=t.id,n=Math.floor(e/(1+s)),e=Math.floor(e%(1+s));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,n>>24,n>>16&255,n>>8&255,255&n,e>>24,e>>16&255,e>>8&255,255&e])),c.trun(t,r.length+16+20+8+16+8+8),r)},c.trak=function(t){return t.duration=t.duration||4294967295,c.box(c.types.trak,c.tkhd(t),c.mdia(t))},c.trex=function(t){t=t.id;return c.box(c.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},c.trun=function(t,e){var r,i,n,s,a,o=t.samples||[],l=o.length,u=12+16*l,d=new Uint8Array(u);for(d.set(["video"===t.type?1:0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,(e+=8+u)>>>24&255,e>>>16&255,e>>>8&255,255&e],0),r=0;r>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*r);return c.box(c.types.trun,d)},c.initSegment=function(t){c.types||c.init();var t=c.moov(t),e=new Uint8Array(c.FTYP.byteLength+t.byteLength);return e.set(c.FTYP),e.set(t,c.FTYP.byteLength),e},c}();r.types=void 0,r.HDLR_TYPES=void 0,r.STTS=void 0,r.STSC=void 0,r.STCO=void 0,r.STSZ=void 0,r.VMHD=void 0,r.SMHD=void 0,r.STSD=void 0,r.FTYP=void 0,r.DINF=void 0;const i=r},"./src/remux/mp4-remuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i,flushTextTrackMetadataCueSamples:()=>L,flushTextTrackUserdataCueSamples:()=>D,normalizePts:()=>at});var h=r("./src/polyfills/number.ts"),N=r("./src/remux/aac-helper.ts"),J=r("./src/remux/mp4-generator.ts"),Z=r("./src/events.ts"),tt=r("./src/errors.ts"),et=r("./src/utils/logger.ts"),b=r("./src/types/loader.ts"),rt=r("./src/utils/timescale-conversion.ts");function it(){return(it=Object.assign?Object.assign.bind():function(t){for(var e=1;es[0].pts)&&(v=u,A=s[0].pts-e,s[0].dts=v,s[0].pts=A,et.logger.log("Video: First PTS/DTS adjusted: "+(0,rt.toMsFromMpegTsClock)(A,!0)+"/"+(0,rt.toMsFromMpegTsClock)(v,!0)+", delta: "+(0,rt.toMsFromMpegTsClock)(e,!0)+" ms")),v=Math.max(0,v),0),M=0,T=0;T{"use strict";r.r(e),r.d(e,{default:()=>i});var c=r("./src/polyfills/number.ts"),h=r("./src/remux/mp4-remuxer.ts"),f=r("./src/utils/mp4-tools.ts"),s=r("./src/loader/fragment.ts"),g=r("./src/utils/logger.ts");function a(t,e){t=null==t?void 0:t.codec;return t&&4{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!(!this._tickInterval||(self.clearInterval(this._tickInterval),this._tickInterval=null))},e.clearNextTick=function(){return!(!this._tickTimer||(self.clearTimeout(this._tickTimer),this._tickTimer=null))},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1{"use strict";r.r(e),r.d(e,{CMCDObjectType:()=>i,CMCDStreamType:()=>s,CMCDStreamingFormat:()=>n,CMCDVersion:()=>a});var i,n,s,a=1;(r=i=i||{}).MANIFEST="m",r.AUDIO="a",r.VIDEO="v",r.MUXED="av",r.INIT="i",r.CAPTION="c",r.TIMED_TEXT="tt",r.KEY="k",r.OTHER="o",(e=n=n||{}).DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o",(r=s=s||{}).VOD="v",r.LIVE="l"},"./src/types/demuxer.ts":(t,e,r)=>{"use strict";var i;r.r(e),r.d(e,{MetadataSchema:()=>i}),(r=i=i||{}).audioId3="org.id3",r.dateRange="com.apple.quicktime.HLS",r.emsg="https://aomedia.org/emsg/ID3"},"./src/types/level.ts":(t,e,r)=>{"use strict";function n(t,e){for(var r=0;ri,HlsSkip:()=>s,HlsUrlParameters:()=>a,Level:()=>o,getSkipValue:()=>function(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,t=t.endSN,e=void 0!==e?e-t:0;if(r&&e{"use strict";var i,n;r.r(e),r.d(e,{PlaylistContextType:()=>i,PlaylistLevelType:()=>n}),(r=i=i||{}).MANIFEST="manifest",r.LEVEL="level",r.AUDIO_TRACK="audioTrack",r.SUBTITLE_TRACK="subtitleTrack",(e=n=n||{}).MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"},"./src/types/transmuxer.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{ChunkMetadata:()=>i});var i=function(t,e,r,i,n,s){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===s&&(s=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=a(),this.buffering={audio:a(),video:a(),audiovideo:a()},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=n,this.partial=s};function a(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{AttrList:()=>s});var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function r(t){for(var e in t="string"==typeof t?r.parseAttrList(t):t)t.hasOwnProperty(e)&&(this[e]=t[e])}var t=r.prototype;return t.decimalInteger=function(t){t=parseInt(this[t],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(t){if(this[t]){for(var e=(1&(e=(this[t]||"0x").slice(2)).length?"0":"")+e,r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(t){return parseFloat(this[t])},t.optionalFloat=function(t,e){t=this[t];return t?parseFloat(t):e},t.enumeratedString=function(t){return this[t]},t.bool=function(t){return"YES"===this[t]},t.decimalResolution=function(t){t=i.exec(this[t]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},r.parseAttrList=function(t){var e,r={};for(n.lastIndex=0;null!==(e=n.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},r}()},"./src/utils/binary-search.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i={search:function(t,e){for(var r=0,i=t.length-1;r<=i;){var n,s,a=e(s=t[n=(r+i)/2|0]);if(0{"use strict";r.r(e),r.d(e,{BufferHelper:()=>s});var i=r("./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function a(){}return a.isBuffered=function(t,e){try{if(t)for(var r=a.getBuffered(t),i=0;i=r.start(i)&&e<=r.end(i))return!0}catch(t){}return!1},a.bufferInfo=function(t,e,r){try{if(t){for(var i=a.getBuffered(t),n=[],s=0;ss&&(i[a-1].end=t[n].end):i.push(t[n])}else i=t;for(var o,l=0,u=e,d=e,c=0;c{"use strict";r.r(e),r.d(e,{CaptionScreen:()=>v,Row:()=>m,default:()=>b});function s(t){var e=t;return n.hasOwnProperty(t)&&(e=n[t]),String.fromCharCode(e)}function l(t){for(var e=[],r=0;r=t&&(e="function"==typeof e?e():e,i.logger.log(this.time+" ["+t+"] "+e))},t}()),g=function(){function t(t,e,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var e=t.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],r=0;r ("+l([a,o])+")"),(r=(r=(r=(r=this.parseCmd(a,o))||this.parseMidrow(a,o))||this.parsePAC(a,o))||this.parseBackgroundAttributes(a,o))||(i=this.parseChars(a,o))&&((s=this.currentChannel)&&0{"use strict";r.r(e),r.d(e,{isCodecSupportedInMp4:()=>function(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')},isCodecType:()=>function(t,e){e=i[e];return!!e&&!0===e[t.slice(0,4)]}});var i={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,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,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!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},text:{stpp:!0,wvtt:!0}}},"./src/utils/cues.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var g=r("./src/utils/vttparser.ts"),p=r("./src/utils/webvtt-parser.ts"),m=r("./src/utils/texttrack-utils.ts"),v=/\s/;const i={newCue:function(e,t,r,i){for(var n,s,a,o,l=[],u=self.VTTCue||self.TextTrackCue,d=0;d{"use strict";r.r(e),r.d(e,{adjustSlidingStart:()=>h,alignMediaPlaylistByPDT:()=>function(t,e){var r,i,n;t.hasProgramDateTime&&e.hasProgramDateTime&&(i=t.fragments,e=e.fragments,i.length)&&e.length&&(r=Math.round(e.length/2)-1,e=e[r],r=l(i,e.cc)||i[Math.round(i.length/2)-1],i=e.programDateTime,n=r.programDateTime,null!==i)&&null!==n&&h((n-i)/1e3-(r.start-e.start),t)},alignPDT:()=>f,alignStream:()=>function(t,e,r){var i,n;e&&(u(t=t,n=e,i=r)&&(t=d(n.details,i))&&(0,s.isFiniteNumber)(t.start)&&(a.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),h(t.start,i)),!r.alignedSliding&&e.details&&f(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||(0,o.adjustSliding)(e.details,r))},findDiscontinuousReferenceFrag:()=>d,findFirstFragWithCC:()=>l,shouldAlignOnDiscontinuities:()=>u});var s=r("./src/polyfills/number.ts"),a=r("./src/utils/logger.ts"),o=r("./src/controller/level-helper.ts");function l(t,e){for(var r=null,i=0,n=t.length;ir.startCC||t&&t.cc{"use strict";r.r(e),r.d(e,{default:()=>i});var n=r("./src/utils/ewma.ts");const i=function(){function t(t,e,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(t),this.fast_=new n.default(e)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,i=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new n.default(t,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==e&&(this.fast_=new n.default(e,i.getEstimate(),i.getTotalWeight()))},e.sample=function(t,e){t=(t=Math.max(t,this.minDelayMs_))/1e3,e=8*e/t;this.fast_.sample(t,e),this.slow_.sample(t,e)},e.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.destroy=function(){},t}()},"./src/utils/ewma.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}()},"./src/utils/fetch-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>d,fetchSupported:()=>function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}});var c=r("./src/polyfills/number.ts"),i=r("./src/loader/load-stats.ts"),u=r("./src/demux/chunk-cache.ts");function n(t){var r="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return s(t,arguments,o(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,t)}(t)}function s(t,e,r){return(s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return;if(Reflect.construct.sham)return;if("function"==typeof Proxy)return 1;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),1}catch(t){}}()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);e=new(Function.bind.apply(t,i));return r&&a(e,r.prototype),e}).apply(null,arguments)}function a(t,e){return(a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(){return(h=Object.assign?Object.assign.bind():function(t){for(var e=1;e=a&&o(n,s,l.flush(),i)):o(n,s,t,i),r())}).catch(function(){return Promise.reject()})}()},t}();function l(t,e){return new self.Request(t.url,e)}var f=function(i){var t,e;function r(t,e,r){t=i.call(this,t)||this;return t.code=void 0,t.details=void 0,t.code=e,t.details=r,t}return e=i,(t=r).prototype=Object.create(e.prototype),a(t.prototype.constructor=t,e),r}(n(Error));const d=e},"./src/utils/hex.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i={hexDump:function(t){for(var e="",r=0;r{"use strict";r.r(e),r.d(e,{IMSC1_CODEC:()=>i,parseIMSC1:()=>function(t,e,r,i,n){t=(0,a.findBox)(new Uint8Array(t),["mdat"]);if(0===t.length)n(new Error("Could not parse IMSC1 mdat"));else{var t=t.map(function(t){return(0,l.utf8ArrayToStr)(t)}),s=(0,u.toTimescaleFromScale)(e,1,r);try{t.forEach(function(t){return i(function(t,s){var r,a,o,l,u,i=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(i)return r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(r).reduce(function(t,e){return t[e]=i.getAttribute("ttp:"+e)||r[e],t},{}),o="preserve"!==i.getAttribute("xml:space"),l=v(m(i,"styling","style")),u=v(m(i,"layout","region")),t=m(i,"body","[begin]"),[].map.call(t,function(t){var e=function i(t,n){return[].slice.call(t.childNodes).reduce(function(t,e,r){return"br"===e.nodeName&&r?t+"\n":null!=(r=e.childNodes)&&r.length?i(e,n):n?t+e.textContent.trim().replace(/\s+/g," "):t+e.textContent},"")}(t,o);if(!e||!t.hasAttribute("begin"))return null;var r=T(t.getAttribute("begin"),a),i=T(t.getAttribute("dur"),a),n=T(t.getAttribute("end"),a);if(null===r)throw E(t);if(null===n){if(null===i)throw E(t);n=r+i}i=new d.default(r-s,n-s,e);i.id=(0,c.generateCueId)(i.startTime,i.endTime,i.text);r=function(i,n,t){var s="http://www.w3.org/ns/ttml#styling",a=null,e=null!=i&&i.hasAttribute("style")?i.getAttribute("style"):null;e&&t.hasOwnProperty(e)&&(a=t[e]);return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(t,e){var r=y(n,s,e)||y(i,s,e)||y(a,s,e);return r&&(t[e]=r),t},{})}(u[t.getAttribute("region")],l[t.getAttribute("style")],l),n=r.textAlign;return n&&((e=p[n])&&(i.lineAlign=e),i.align=n),h(i,r),i}).filter(function(t){return null!==t});throw new Error("Invalid ttml")}(t,s))})}catch(t){n(t)}}}});var a=r("./src/utils/mp4-tools.ts"),o=r("./src/utils/vttparser.ts"),d=r("./src/utils/vttcue.ts"),l=r("./src/demux/id3.ts"),u=r("./src/utils/timescale-conversion.ts"),c=r("./src/utils/webvtt-parser.ts");function h(){return(h=Object.assign?Object.assign.bind():function(t){for(var e=1;e{"use strict";r.r(e),r.d(e,{changeEndianness:()=>function(t){function e(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)},convertDataUriToArrayBytes:()=>function(t){var t=t.split(":"),e=null;{var r,i;"data"===t[0]&&2===t.length&&(t=t[1].split(";"),2===(i=t[t.length-1].split(",")).length)&&(r="base64"===i[0],i=i[1],e=(r?(t.splice(-1,1),n.base64Decode):function(t){var t=s(t).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e})(i))}return e},strToUtf8array:()=>s});var n=r("./src/utils/numeric-encoding-utils.ts");function s(t){return Uint8Array.from(unescape(encodeURIComponent(t)),function(t){return t.charCodeAt(0)})}},"./src/utils/logger.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{enableLogs:()=>function(t,e){if(self.console&&!0===t||"object"==typeof t){!function(e){for(var t=arguments.length,r=new Array(1");return n}(t)})}(t,"debug","log","info","warn","error");try{s.log('Debug logs enabled for "'+e+'"')}catch(t){s=i}}else s=i},logger:()=>a});function n(){}var i={trace:n,debug:n,log:n,warn:n,info:n,error:n},s=i;var a=s},"./src/utils/mediakeys-helper.ts":(t,e,r)=>{"use strict";var s,i,n;r.r(e),r.d(e,{KeySystemFormats:()=>i,KeySystemIds:()=>n,KeySystems:()=>s,getKeySystemsForConfig:()=>function(t){var e=t.drmSystems,t=t.widevineLicenseUrl,r=e?[s.FAIRPLAY,s.WIDEVINE,s.PLAYREADY,s.CLEARKEY].filter(function(t){return!!e[t]}):[];!r[s.WIDEVINE]&&t&&r.push(s.WIDEVINE);return r},getSupportedMediaKeySystemConfigurations:()=>function(t,e,r,i){var n;switch(t){case s.FAIRPLAY:n=["cenc","sinf"];break;case s.WIDEVINE:case s.PLAYREADY:n=["cenc"];break;case s.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}return function(t,e,r,i){return[{initDataTypes:t,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}}),videoCapabilities:r.map(function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}})}]}(n,e,r,i)},keySystemDomainToKeySystemFormat:()=>function(t){switch(t){case s.FAIRPLAY:return i.FAIRPLAY;case s.PLAYREADY:return i.PLAYREADY;case s.WIDEVINE:return i.WIDEVINE;case s.CLEARKEY:return i.CLEARKEY}},keySystemFormatToKeySystemDomain:()=>function(t){switch(t){case i.FAIRPLAY:return s.FAIRPLAY;case i.PLAYREADY:return s.PLAYREADY;case i.WIDEVINE:return s.WIDEVINE;case i.CLEARKEY:return s.CLEARKEY}},keySystemIdToKeySystemDomain:()=>function(t){if(t===n.WIDEVINE)return s.WIDEVINE},requestMediaKeySystemAccess:()=>a}),(r=s=s||{}).CLEARKEY="org.w3.clearkey",r.FAIRPLAY="com.apple.fps",r.PLAYREADY="com.microsoft.playready",r.WIDEVINE="com.widevine.alpha",(e=i=i||{}).CLEARKEY="org.w3.clearkey",e.FAIRPLAY="com.apple.streamingkeydelivery",e.PLAYREADY="com.microsoft.playready",e.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",(n=n||{}).WIDEVINE="edef8ba979d64acea3c827dcd51d21ed";var a="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{getMediaSource:()=>function(){return self.MediaSource||self.WebKitMediaSource}})},"./src/utils/mp4-tools.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{RemuxerTrackIdConfig:()=>l,appendUint8Array:()=>function(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r},bin2str:()=>c,computeRawDurationFromSamples:()=>b,discardEPB:()=>A,findBox:()=>w,getDuration:()=>function(t,e){for(var r=0,i=0,n=0,s=w(t,["moof","traf"]),a=0;afunction(s,t){return w(t,["moof","traf"]).reduce(function(t,e){var i=w(e,["tfdt"])[0],n=i[0],e=w(e,["tfhd"]).reduce(function(t,e){e=C(e,4),e=s[e];if(e){var r=C(i,4),e=(1===n&&(r=(r*=Math.pow(2,32))+C(i,8)),e.timescale||9e4),r=r/e;if(isFinite(r)&&(null===t||rh,mp4pssh:()=>function(t,e,r){if(16!==t.byteLength)throw new RangeError("Invalid system id");var i,n,s;if(e){i=1,n=new Uint8Array(16*e.length);for(var a=0;afunction(r,t,n){w(t,["moof","traf"]).forEach(function(e){w(e,["tfhd"]).forEach(function(t){var i,t=C(t,4),t=r[t];t&&(i=t.timescale||9e4,w(e,["tfdt"]).forEach(function(t){var e=t[0],r=C(t,4);0===e?(r-=n*i,u(t,4,r=Math.max(r,0))):(r=(r=(r*=Math.pow(2,32))+C(t,8))-n*i,r=Math.max(r,0),e=Math.floor(r/(s+1)),r=Math.floor(r%(s+1)),u(t,4,e),u(t,8,r))}))})})},parseEmsg:()=>function(t){var e=t[0],r="",i="",n=0,s=0,a=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==c(t.subarray(u,u+1));)r+=c(t.subarray(u,u+1)),u+=1;for(r+=c(t.subarray(u,u+1)),u+=1;"\0"!==c(t.subarray(u,u+1));)i+=c(t.subarray(u,u+1)),u+=1;i+=c(t.subarray(u,u+1)),u+=1,n=C(t,12),s=C(t,16),o=C(t,20),l=C(t,24),u=28}else if(1===e){n=C(t,u+=4);var e=C(t,u+=4),d=C(t,u+=4);for(u+=4,a=Math.pow(2,32)*e+d,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER),o=C(t,u),l=C(t,u+=4),u+=4;"\0"!==c(t.subarray(u,u+1));)r+=c(t.subarray(u,u+1)),u+=1;for(r+=c(t.subarray(u,u+1)),u+=1;"\0"!==c(t.subarray(u,u+1));)i+=c(t.subarray(u,u+1)),u+=1;i+=c(t.subarray(u,u+1)),u+=1}e=t.subarray(u,t.byteLength);return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e}},parseInitSegment:()=>function(t){for(var r=[],e=w(t,["moov","trak"]),i=0;ifunction(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var e={version:0,systemId:"",kids:null,data:null},r=new DataView(t),i=r.getUint32(0);if(t.byteLength!==i&&44>>24,1O,parseSamples:()=>function(b,L){var D=[],A=L.samples,k=L.timescale,s=L.id,R=!1;return w(A,["moof"]).map(function(t){var S=t.byteOffset-8;w(t,["traf"]).map(function(n){var t=w(n,["tfdt"]).map(function(t){var e=t[0],r=C(t,4);return(r=1===e?(r*=Math.pow(2,32))+C(t,8):r)/k})[0];return void 0!==t&&(b=t),w(n,["tfhd"]).map(function(t){var e=C(t,4),r=16777215&C(t,0),E=0,T=0,i=8;e===s&&(0!=(1&r)&&(i+=8),0!=(2&r)&&(i+=4),0!=(8&r)&&(E=C(t,i),i+=4),0!=(16&r)&&(T=C(t,i),i+=4),0!=(32&r)&&(i+=4),"video"===L.type&&(e=L.codec,R=!!e&&("hvc1"===(e=(t=e.indexOf("."))<0?e:e.substring(0,t))||"hev1"===e||"dvh1"===e||"dvhe"===e)),w(n,["trun"]).map(function(t){for(var e,r,i=t[0],n=16777215&C(t,0),s=0,a=0!=(256&n),o=0,l=0!=(512&n),u=0,d=0!=(1024&n),c=0!=(2048&n),h=0,f=C(t,4),g=8,p=(0!=(1&n)&&(s=C(t,g),g+=4),0!=(4&n)&&(g+=4),s+S),m=0;m>1&63)||40==e:6==(31&r))&&O(A.subarray(p,p+y),R?2:1,b+h/k,D),p+=y,v+=y+4}b+=o/k}}))})})}),D},parseSegmentIndex:()=>S,parseSinf:()=>d,patchEncyptionData:()=>function(t,e){var i;return t&&e&&(i=e.keyId)&&e.isCommonEncryption&&w(t,["moov","trak"]).forEach(function(t){var t=w(t,["mdia","minf","stbl","stsd"])[0].subarray(8),e=w(t,["enca"]),r=0sinf>>tenc' box: "+a.default.hexDump(e)+" -> "+a.default.hexDump(i)),t.set(i,8))})})}),t},readSint32:()=>_,readUint16:()=>D,readUint32:()=>C,segmentValidRange:()=>function(t){var e={valid:null,remainder:null},r=w(t,["moof"]);if(r){if(r.length<2)return e.remainder=t,e;r=r[r.length-1];e.valid=(0,i.sliceUint8)(t,0,r.byteOffset-8),e.remainder=(0,i.sliceUint8)(t,r.byteOffset-8)}return e},writeUint32:()=>u});var I=r("./src/loader/fragment.ts"),i=r("./src/utils/typed-array.ts"),L=r("./src/demux/id3.ts"),n=r("./src/utils/logger.ts"),a=r("./src/utils/hex.ts"),s=Math.pow(2,32)-1,o=[].push,l={video:1,audio:2,id3:3,text:4};function c(t){return String.fromCharCode.apply(null,t)}function D(t,e){t=t[e]<<8|t[e+1];return t<0?65536+t:t}function C(t,e){t=_(t,e);return t<0?4294967296+t:t}function _(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function u(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function w(t,e){var r=[];if(e.length)for(var i=t.byteLength,n=0;n>>31)return null;u=C(t,l+=4);l+=4,e.push({referenceSize:d,subsegmentDuration:u,info:{duration:u/n,start:s,end:s+d-1}}),s+=d,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:a,references:e}}function d(t){var e=w(t,["schm"])[0];if(e){e=c(e.subarray(4,8));if("cbcs"===e||"cenc"===e)return w(t,["schi","tenc"])[0]}return n.logger.error("[eme] missing 'schm' box"),null}function b(t){for(var e=C(t,0),r=8,i=(1&e&&(r+=4),4&e&&(r+=4),0),n=C(t,4),s=0;s=n.length)&&(a+=u=n[s++],255===u););for(o=0;!(s>=n.length)&&(o+=u=n[s++],255===u););var d=n.length-s;if(!l&&4===a&&s>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=255&s,o.set(t,4),a=0,s=8;a{"use strict";function i(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function n(t){return btoa(String.fromCharCode.apply(String,t))}r.r(e),r.d(e,{base64Decode:()=>function(t){return Uint8Array.from(atob(t),function(t){return t.charCodeAt(0)})},base64DecodeToStr:()=>function(t){return atob(t)},base64Encode:()=>n,base64ToBase64Url:()=>i,base64UrlEncode:()=>function(t){return i(n(t))},strToBase64Encode:()=>function(t){return btoa(t)}})},"./src/utils/output-filter.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});var i=function(){function t(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}var e=t.prototype;return e.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},e.newCue=function(t,e,r){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[],this.startTime=null},t}()},"./src/utils/texttrack-utils.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{addCueToTrack:()=>function(e,r){var t=e.mode;"disabled"===t&&(e.mode="hidden");if(e.cues&&!e.cues.getCueById(r.id))try{if(e.addCue(r),!e.cues.getCueById(r.id))throw new Error("addCue is failed for: "+r)}catch(t){n.logger.debug("[texttrack-utils]: "+t);var i=new self.TextTrackCue(r.startTime,r.endTime,r.text);i.id=r.id,e.addCue(i)}"disabled"===t&&(e.mode=t)},clearCurrentCues:()=>function(t){var e=t.mode;"disabled"===e&&(t.mode="hidden");if(t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)},getCuesInRange:()=>o,removeCuesInRange:()=>function(t,e,r,i){var n=t.mode;"disabled"===n&&(t.mode="hidden");if(t.cues&&0function(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}});var n=r("./src/utils/logger.ts");function o(t,e,r){var i=[],n=function(t,e){if(et[r].endTime)return-1;for(var i=0,n=r;i<=n;){var s=Math.floor((n+i)/2);if(et[s].startTime&&i=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i={toString:function(t){for(var e="",r=t.length,i=0;i{"use strict";r.r(e),r.d(e,{toMpegTsClockFromTimescale:()=>function(t,e){void 0===e&&(e=1);return n(t,i,1/e)},toMsFromMpegTsClock:()=>function(t,e){void 0===e&&(e=!1);return n(t,1e3,1/i,e)},toTimescaleFromBase:()=>n,toTimescaleFromScale:()=>function(t,e,r,i){void 0===r&&(r=1);void 0===i&&(i=!1);return n(t,e,1/r,i)}});var i=9e4;function n(t,e,r,i){t=t*e*(r=void 0===r?1:r);return(i=void 0===i?!1:i)?Math.round(t):t}},"./src/utils/typed-array.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{sliceUint8:()=>function(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}})},"./src/utils/vttcue.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>i});const i="undefined"!=typeof self&&self.VTTCue?self.VTTCue:(b=["","lr","rl"],s=["start","middle","end","left","right"],n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n);function E(t,e){return"string"==typeof e&&!!Array.isArray(t)&&(e=e.toLowerCase(),!!~t.indexOf(e))&&e}function T(t){return E(s,t)}function S(t){for(var e=arguments.length,r=new Array(1{"use strict";r.r(e),r.d(e,{VTTParser:()=>n,fixLineBreaks:()=>f,parseTimeStamp:()=>l});var o=r("./src/utils/vttcue.ts"),i=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function l(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}t=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?59/gi,"\n")}var n=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new i,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var i=this;function e(){for(var t=0,e=f(e=i.buffer);t{"use strict";r.r(e),r.d(e,{generateCueId:()=>L,parseWebVTT:()=>function(t,e,r,n,s,a,i,o){var l,u=new m.VTTParser,t=(0,v.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(T,"\n").split("\n"),d=[],c=(0,y.toMpegTsClockFromTimescale)(e,r),h="00:00.000",f=0,g=0,p=!0;u.oncue=function(t){var e=n[s],r=n.ccOffset,i=(f-c)/9e4,e=(null!=e&&e.new&&(void 0!==g?r=n.ccOffset=e.start:D(n,s,i)),i&&(r=i-n.presentationOffset),t.endTime-t.startTime),i=(0,E.normalizePts)(9e4*(t.startTime+r-g),9e4*a)/9e4,r=(t.startTime=Math.max(i,0),t.endTime=Math.max(i+e,0),t.text.trim());t.text=decodeURIComponent(encodeURIComponent(r)),t.id||(t.id=L(t.startTime,t.endTime,r)),0>>0).toString()};function L(t,e,r){return i(t.toString())+i(e.toString())+i(r)}var D=function(t,e,r){var i,n=t[e],s=t[n.prevCC];if(!s||!s.new&&n.new)t.ccOffset=t.presentationOffset=n.start,n.new=!1;else{for(;null!=(i=s)&&i.new;)t.ccOffset+=n.start-s.start,n.new=!1,s=t[(n=s).prevCC];t.presentationOffset=r}}},"./src/utils/xhr-loader.ts":(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>s});var o=r("./src/utils/logger.ts"),i=r("./src/loader/load-stats.ts"),n=/^age:\s*[\d.]+\s*$/m;const s=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new i.LoadStats,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState)&&(this.stats.aborted=!0,t.abort())},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.retryDelay=e.retryDelay,this.loadInternal()},e.loadInternal=function(){var t=this.config,e=this.context;if(t){var r=this.loader=new self.XMLHttpRequest,i=this.stats,i=(i.loading.first=0,i.loaded=0,this.xhrSetup);try{if(i)try{i(r,e.url)}catch(t){r.open("GET",e.url,!0),i(r,e.url)}r.readyState||r.open("GET",e.url,!0);var n=this.context.headers;if(n)for(var s in n)r.setRequestHeader(s,n[s])}catch(t){return void this.callbacks.onError({code:r.status,text:t.message},e,r)}e.rangeEnd&&r.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=e.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),r.send()}},e.readystatechange=function(){var t,e,r,i,n=this.context,s=this.loader,a=this.stats;n&&s&&(e=s.readyState,t=this.config,a.aborted||2<=e&&(self.clearTimeout(this.requestTimeout),0===a.loading.first&&(a.loading.first=Math.max(self.performance.now(),a.loading.start)),4===e?(s.onreadystatechange=null,s.onprogress=null,e=s.status,i="arraybuffer"===s.responseType,200<=e&&e<300&&(i&&s.response||null!==s.responseText)?(a.loading.end=Math.max(self.performance.now(),a.loading.first),i=i?(r=s.response).byteLength:(r=s.responseText).length,a.loaded=a.total=i,this.callbacks&&((i=this.callbacks.onProgress)&&i(a,n,r,s),this.callbacks)&&(i={url:s.responseURL,data:r},this.callbacks.onSuccess(i,a,n,s))):a.retry>=t.maxRetry||400<=e&&e<499?(o.logger.error(e+" while loading "+n.url),this.callbacks.onError({code:e,text:s.statusText},n,s)):(o.logger.warn(e+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,t.maxRetryDelay),a.retry++)):(self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout))))},e.loadtimeout=function(){o.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t,e=null;return e=this.loader&&n.test(this.loader.getAllResponseHeaders())?(t=this.loader.getResponseHeader("age"))?parseFloat(t):null:e},t}()},"./node_modules/eventemitter3/index.js":t=>{"use strict";var i=Object.prototype.hasOwnProperty,f="~";function r(){}function s(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function n(t,e,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new s(r,i||t,n),i=f?f+e:e;return t._events[i]?t._events[i].fn?t._events[i]=[t._events[i],r]:t._events[i].push(r):(t._events[i]=r,t._eventsCount++),t}function l(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function e(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(f=!1)),e.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)i.call(t,e)&&r.push(f?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},e.prototype.listeners=function(t){var t=f?f+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,i=e.length,n=new Array(i);r{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i("./src/hls.ts").default;function i(t){var e=n[t];return void 0!==e||(e=n[t]={exports:{}},r[t].call(e.exports,e,e.exports,i)),e.exports}var r,n},t.exports=i())}]);if (typeof module === 'object' && module.exports) { module.exports = window.hlsSourceHandler; } From 74b20c223a49aa5e00b25e8d6914bb9ecded9323 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Thu, 7 Sep 2023 17:06:45 +0200 Subject: [PATCH 06/55] workon videojs 8 plugin - ok for logo, quality selector, p2p, remove seek plugin, ok for note and playlist --- pod/package.json | 5 +-- pod/video/static/js/video-show.js | 8 ++--- .../static/js/videojs-logo-controlbar.js | 1 - pod/video/templates/videos/video-header.html | 22 +++++-------- pod/video/templates/videos/video-script.html | 33 ++++++++++--------- 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/pod/package.json b/pod/package.json index aebf6cf604..642eecb1b3 100644 --- a/pod/package.json +++ b/pod/package.json @@ -11,17 +11,14 @@ "js-cookie": "^3.0.5", "spark-md5": "^3.0.2", "video.js": "^8.5.2", - "videojs-contrib-quality-levels": "^4.0.0", - "videojs-hls-quality-selector": "^1.1.4", "videojs-quality-selector-hls": "^1.1.1", "videojs-overlay": "^3.1.0", - "videojs-seek-buttons": "latest7", "videojs-vr": "^2.0.0", "videojs-vtt-thumbnails": "^0.0.13", "videojs-wavesurfer": "^3.9.0", "wavesurfer.js": "^6.6.4", "waypoints": "^4.0.1", - "@silvermine/videojs-quality-selector": "^1.2.5", + "@silvermine/videojs-quality-selector": "^1.3.0", "@peertube/p2p-media-loader-core": "^1.0.14", "@peertube/p2p-media-loader-hlsjs": "^1.0.14" }, diff --git a/pod/video/static/js/video-show.js b/pod/video/static/js/video-show.js index c6599a4380..5b45ca586c 100644 --- a/pod/video/static/js/video-show.js +++ b/pod/video/static/js/video-show.js @@ -1,8 +1,7 @@ var translationDone = false; - -document - .getElementById("podvideoplayer_html5_api") - .addEventListener("play", function () { +var video_player = document.getElementById("podvideoplayer_html5_api") +if(video_player) { + video_player.addEventListener("play", function () { if (!translationDone) { const elementToTranslateList = [ [".skip-back", gettext("Seek back 10 seconds in the video")], @@ -26,6 +25,7 @@ document } } }); +} /** * Translate the title of the video player button. diff --git a/pod/video/static/js/videojs-logo-controlbar.js b/pod/video/static/js/videojs-logo-controlbar.js index 4ab63f6f28..74ef2ffb8e 100644 --- a/pod/video/static/js/videojs-logo-controlbar.js +++ b/pod/video/static/js/videojs-logo-controlbar.js @@ -21,7 +21,6 @@ class LogoMenuLink extends MenuLink { constructor(player, options) { var aElement = document.createElement("a"); - console.log(options.link); if (options.link && options.link !== "") { aElement.href = options.link; } else { diff --git a/pod/video/templates/videos/video-header.html b/pod/video/templates/videos/video-header.html index d4e6468a51..bf1e1d4581 100644 --- a/pod/video/templates/videos/video-header.html +++ b/pod/video/templates/videos/video-header.html @@ -12,22 +12,16 @@ -{% comment %} - - - - - + + + + - - - - - {% if not video.is_video and event is None or playlist_in_get %} @@ -78,6 +72,8 @@ + +{% comment %} diff --git a/pod/video/templates/videos/video-script.html b/pod/video/templates/videos/video-script.html index 6dbfbd8dfd..a5349f1b92 100644 --- a/pod/video/templates/videos/video-script.html +++ b/pod/video/templates/videos/video-script.html @@ -123,6 +123,14 @@ html5: { hlsjsConfig: VideoHlsjsConfig }, + controlBar: { + {% if event is None %} + skipButtons: { + forward: seektime, + backward: seektime + } + {% endif %} + }, userActions: { hotkeys: function(event) { // `this` is the player in this context @@ -159,16 +167,10 @@ } } }, - plugins: {/* - {% if event is None %} - seekButtons: { - forward: seektime, - back: seektime - } - {% endif %} + plugins: { {% if not video.is_video and event is None %} // enable videojs-wavesurfer plugin - ,wavesurfer: { + wavesurfer: { backend: 'MediaElement', displayMilliseconds: true, debug: false, @@ -177,7 +179,7 @@ cursorColor: 'var(--pod-primary)', hideScrollbar: false } - {% endif %}*/ + {% endif %} } } @@ -213,11 +215,9 @@ //Add source to player player.src(srcOptions); //add quality selector to player - /* - player.hlsQualitySelector({ + player.qualitySelectorHls({ displayCurrentQuality: true, }); - */ player.on("error", function(e) { e.stopImmediatePropagation(); var error = player.error(); @@ -225,23 +225,25 @@ if(error.code == 3 || error.code == 4) { //console.log('error!', error.code, error.type , error.message); if(player.src()=="" || player.src().indexOf("m3u8")!=-1){ - player.controlBar.addChild('QualitySelector'); + //player.controlBar.addChild('QualitySelector'); player.play(); } } }); {% else %} player.src(mp4_sources); - player.controlBar.addChild('QualitySelector'); + //player.controlBar.addChild('QualitySelector'); {% endif %} {% if video.overview %} //add overview + /* player.vttThumbnails({ src: '{% if request.is_secure %}https://{% else %}http://{% endif %}{{request.get_host}}{{video.overview.url}}?date={{video.overview|file_date_created}}' }); player.vttThumbnails({ src: '{% if request.is_secure %}https://{% else %}http://{% endif %}{{request.get_host}}{{video.overview.url}}?date={{video.overview|file_date_created}}' }); + */ {% endif %} {% if video.overlay_set.all %} @@ -292,12 +294,13 @@ }); {% endif %} {% endif %} - + /* {% if video.chapter_set.all %} player.videoJsChapters(); document.querySelector('.vjs-big-play-button').style.zIndex = '2'; document.querySelector('.vjs-control-bar').style.zIndex = '3'; {% endif %} + */ {% if video_event_tracking %} {# Be sure to define _paq in a tracking script in TEMPLATE_VISIBLE_SETTINGS:TRACKING_TEMPLATE pref. #} From d310993b87290f70edce4d6233103e1aaf873503 Mon Sep 17 00:00:00 2001 From: Ptitloup Date: Fri, 8 Sep 2023 12:20:01 +0200 Subject: [PATCH 07/55] remove chapter plugin from videojs and use video text track in webvtt format direct in player - create get video chapter in video views and call it in track --- pod/video/templates/videos/video-element.html | 7 ++++ pod/video/templates/videos/video-header.html | 4 +- pod/video/urls.py | 11 +++++ pod/video/views.py | 40 ++++++++++++++++++- requirements-encode.txt | 2 +- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/pod/video/templates/videos/video-element.html b/pod/video/templates/videos/video-element.html index bb6ebf85aa..6470d532c0 100644 --- a/pod/video/templates/videos/video-element.html +++ b/pod/video/templates/videos/video-element.html @@ -18,6 +18,13 @@ {% for track in video.track_set.all%} {%endfor%} + {% if video.chapter_set.all %} + {% if video.get_hashkey in request.url %} + + {% else %} + + {% endif %} + {% endif %}