LocalCDN-Firefox-Chrome-Brave/resources/p2p-media-loader-hlsjs/0.6.2/p2p-media-loader-hlsjs.min.jsm

2 lines
26 KiB
JavaScript
Raw Normal View History

require=function t(e,s,i){function n(r,o){if(!s[r]){if(!e[r]){var u="function"==typeof require&&require;if(!o&&u)return u(r,!0);if(a)return a(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var g=s[r]={exports:{}};e[r][0].call(g.exports,function(t){return n(e[r][1][t]||t)},g,g.exports,t,e,s,i)}return s[r].exports}for(var a="function"==typeof require&&require,r=0;r<i.length;r++)n(i[r]);return n}({1:[function(t,e,s){window.p2pml||(window.p2pml={}),window.p2pml.hlsjs=t("p2p-media-loader-hlsjs")},{"p2p-media-loader-hlsjs":"p2p-media-loader-hlsjs"}],2:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const i=t("events"),n=t("p2p-media-loader-core"),a=t("./segment-manager"),r=t("./hlsjs-loader"),o=t("./hlsjs-loader-class");s.Engine=class extends i.EventEmitter{constructor(t={}){super(),this.loader=new n.HybridLoader(t.loader),this.segmentManager=new a.SegmentManager(this.loader,t.segments),Object.keys(n.Events).map(t=>n.Events[t]).forEach(t=>this.loader.on(t,(...e)=>this.emit(t,...e)))}static isSupported(){return n.HybridLoader.isSupported()}createLoaderClass(){return o.createHlsJsLoaderClass(r.HlsJsLoader,this)}async destroy(){await this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}setPlayingSegment(t,e,s,i){this.segmentManager.setPlayingSegment(t,e,s,i)}setPlayingSegmentByCurrentTime(t){this.segmentManager.setPlayingSegmentByCurrentTime(t)}}},{"./hlsjs-loader":4,"./hlsjs-loader-class":3,"./segment-manager":5,events:"events","p2p-media-loader-core":"p2p-media-loader-core"}],3:[function(t,e,s){e.exports.createHlsJsLoaderClass=function(t,e){function s(){this.impl=new t(e.segmentManager),this.stats=this.impl.stats}return s.prototype.load=function(t,e,s){this.context=t,this.impl.load(t,e,s)},s.prototype.abort=function(){this.impl.abort(this.context)},s.prototype.destroy=function(){this.context&&this.impl.abort(this.context)},s.getEngine=function(){return e},s}},{}],4:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const i=1,n=12500;s.HlsJsLoader=class{constructor(t){this.stats={},this.segmentManager=t}async load(t,e,s){if(t.type)try{const e=await this.segmentManager.loadPlaylist(t.url);this.successPlaylist(e,t,s)}catch(e){this.error(e,t,s)}else if(t.frag)try{const e=await this.segmentManager.loadSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart});void 0!==e.content&&setTimeout(()=>this.successSegment(e.content,e.downloadBandwidth,t,s),0)}catch(e){setTimeout(()=>this.error(e,t,s),0)}else console.warn("Unknown load request",t)}abort(t){this.segmentManager.abortSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart})}successPlaylist(t,e,s){const i=performance.now();this.stats.trequest=i-300,this.stats.tfirst=i-200,this.stats.tload=i,this.stats.loaded=t.response.length,s.onSuccess({url:t.responseURL,data:t.response},this.stats,e)}successSegment(t,e,s,a){const r=performance.now(),o=t.byteLength/(void 0===e||e<=0?n:e);this.stats.trequest=r-i-o,this.stats.tfirst=r-o,this.stats.tload=r,this.stats.loaded=t.byteLength,a.onSuccess({url:s.url,data:t},this.stats,s)}error(t,e,s){s.onError(t,e)}}},{}],5:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const i=t("p2p-media-loader-core"),n=t("m3u8-parser"),a={forwardSegmentCount:20,swarmId:void 0,assetsStorage:void 0};s.SegmentManager=class{constructor(t,e={}){this.masterPlaylist=null,this.variantPlaylists=new Map,this.segmentRequest=null,this.playQueue=[],this.onSegmentLoaded=t=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onSuccess(t.data.slice(0),t.downloadBandwidth),this.segmentRequest=null)},this.onSegmentError=(t,e)=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.s