p2p-media-loader-hlsjs
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -263,3 +263,3 @@ require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
}; | ||
this.settings = Object.assign(defaultSettings, settings); | ||
this.settings = Object.assign({}, defaultSettings, settings); | ||
this.loader = loader; | ||
@@ -1859,3 +1859,3 @@ this.loader.on(p2p_media_loader_core_1.Events.SegmentLoaded, this.onSegmentLoaded); | ||
clearInterval(iid); | ||
player.hls.config = Object.assign(player.hls.config, hlsjsConfig); | ||
Object.assign(player.hls.config, hlsjsConfig); | ||
initHlsJsPlayer(player.hls); | ||
@@ -1866,3 +1866,3 @@ } | ||
exports.initJwPlayer = initJwPlayer; | ||
exports.version = typeof (__P2PML_VERSION__) === "undefined" ? "0.4.0" : __P2PML_VERSION__; | ||
exports.version = typeof (__P2PML_VERSION__) === "undefined" ? "0.5.0" : __P2PML_VERSION__; | ||
function initHlsJsEvents(player, engine) { | ||
@@ -1869,0 +1869,0 @@ player.on("hlsFragChanged", function (event_unused, data) { |
@@ -1,1 +0,1 @@ | ||
require=function(){return function t(e,s,n){function i(a,o){if(!s[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(r)return r(a,!0);var g=new Error("Cannot find module '"+a+"'");throw g.code="MODULE_NOT_FOUND",g}var l=s[a]={exports:{}};e[a][0].call(l.exports,function(t){return i(e[a][1][t]||t)},l,l.exports,t,e,s,n)}return s[a].exports}for(var r="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}}()({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 n=t("events"),i=t("p2p-media-loader-core"),r=t("./segment-manager"),a=t("./hlsjs-loader"),o=t("./hlsjs-loader-class");s.Engine=class extends n.EventEmitter{static isSupported(){return i.HybridLoader.isSupported()}constructor(t={}){super(),this.loader=new i.HybridLoader(t.loader),this.segmentManager=new r.SegmentManager(this.loader,t.segments),Object.keys(i.Events).map(t=>i.Events[t]).forEach(t=>this.loader.on(t,(...e)=>this.emit(t,...e)))}createLoaderClass(){return o.createHlsJsLoaderClass(a.HlsJsLoader,this)}destroy(){this.loader.destroy(),this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}setPlayingSegment(t,e){this.segmentManager.setPlayingSegment(t,e)}}},{"./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 n=1,i=12500;s.HlsJsLoader=class{constructor(t){this.stats={},this.segmentManager=t}load(t,e,s){t.type?this.segmentManager.loadPlaylist(t.url).then(e=>this.successPlaylist(e,t,s)).catch(e=>this.error(e,t,s)):t.frag?this.segmentManager.loadSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart},(e,n)=>setTimeout(()=>this.successSegment(e,n,t,s),0),e=>setTimeout(()=>this.error(e,t,s),0)):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 n=performance.now();this.stats.trequest=n-300,this.stats.tfirst=n-200,this.stats.tload=n,this.stats.loaded=t.response.length,s.onSuccess({url:t.responseURL,data:t.response},this.stats,e)}successSegment(t,e,s,r){const a=performance.now(),o=t.byteLength/(e<=0?i:e);this.stats.trequest=a-n-o,this.stats.tfirst=a-o,this.stats.tload=a,this.stats.loaded=t.byteLength,r.onSuccess({url:s.url,data:t},this.stats,s)}error(t,e,s){s.onError(t,e)}}},{}],5:[function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))(function(i,r){function a(t){try{u(n.next(t))}catch(t){r(t)}}function o(t){try{u(n.throw(t))}catch(t){r(t)}}function u(t){t.done?i(t.value):new s(function(e){e(t.value)}).then(a,o)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=t("p2p-media-loader-core"),r=t("m3u8-parser"),a={forwardSegmentCount:20,swarmId: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.downloadSpeed),this.segmentRequest=null)}),this.onSegmentError=((t,e)=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError(e),this.segmentRequest=null)}),this.onSegmentAbort=(t=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError("Loading aborted: internal abort"),this.segmentRequest=null)}),this.settings=Object.assign(a,e),this.loader=t,this.loader.on(i.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(i.Events.SegmentError,this.onSegmentError),this.loader.on(i.Events.SegmentAbort,this.onSegmentAbort)}getSettings(){return this.settings}processPlaylist(t,e,s){const n=new r.Parser;n.push(e),n.end();const i=new o(t,s,n.manifest);if(i.manifest.playlists){this.masterPlaylist=i;for(const[t,e]of this.variantPlaylists){const{swarmId:s,found:n}=this.getSwarmId(e.requestUrl);n?e.swarmId=s:this.variantPlaylists.delete(t)}}else{const{swarmId:e,found:s}=this.getSwarmId(t);!s&&this.masterPlaylist||(i.swarmId=e,this.variantPlaylists.set(t,i),this.updateSegments())}}loadPlaylist(t){return n(this,void 0,void 0,function*(){const e=yield this.loadContent(t,"text");return this.processPlaylist(t,e.response,e.responseURL),e})}loadSegment(t,e,s,n){const i=this.getSegmentLocation(t,e);if(!i)return void this.loadContent(t,"arraybuffer",l(e)).then(t=>s(t.response,0)).catch(t=>n(t));const r=(i.playlist.manifest.mediaSequence?i.playlist.manifest.mediaSequence:0)+i.segmentIndex;this.playQueue.length>0&&this.playQueue[this.playQueue.length-1].segmentSequence!==r-1&&(this.playQueue=[]),this.segmentRequest&&this.segmentRequest.onError("Cancel segment request: simultaneous segment requests are not supported"),this.segmentRequest=new u(t,e,r,i.playlist.requestUrl,s,n),this.playQueue.push({segmentUrl:t,segmentByterange:e,segmentSequence:r}),this.loadSegments(i.playlist,i.segmentIndex,!0)}setPlayingSegment(t,e){const s=this.playQueue.findIndex(s=>s.segmentUrl==t&&g(s.segmentByterange,e));s>=0&&(this.playQueue=this.playQueue.slice(s),this.updateSegments())}abortSegment(t,e){this.segmentRequest&&this.segmentRequest.segmentUrl===t&&g(this.segmentRequest.segmentByterange,e)&&(this.segmentRequest=null)}destroy(){this.loader.destroy(),this.segmentRequest&&(this.segmentRequest.onError("Loading aborted: object destroyed"),this.segmentRequest=null),this.masterPlaylist=null,this.variantPlaylists.clear(),this.playQueue=[]}updateSegments(){if(!this.segmentRequest)return;const t=this.getSegmentLocation(this.segmentRequest.segmentUrl,this.segmentRequest.segmentByterange);if(t)this.loadSegments(t.playlist,t.segmentIndex,!1);else{const t=this.variantPlaylists.get(this.segmentRequest.playlistRequestUrl);t&&this.loadSegments(t,0,!1,{url:this.segmentRequest.segmentUrl,byterange:this.segmentRequest.segmentByterange,sequence:this.segmentRequest.segmentSequence})}}getSegmentLocation(t,e){for(const s of this.variantPlaylists.values()){const n=s.getSegmentIndex(t,e);if(n>=0)return{playlist:s,segmentIndex:n}}}loadSegments(t,e,s,n){const r=[],a=t.manifest.segments,o=t.manifest.mediaSequence?t.manifest.mediaSequence:0;let u=null,g=Math.max(0,this.playQueue.length-1);if(n){const e=t.getSegmentAbsoluteUrl(n.url),a=this.getSegmentId(t,n.sequence);r.push(new i.Segment(a,e,l(n.byterange),g++)),s&&(u=a)}for(let n=e;n<a.length&&r.length<this.settings.forwardSegmentCount;++n){const e=t.manifest.segments[n],a=t.getSegmentAbsoluteUrl(e.uri),d=e.byterange,c=this.getSegmentId(t,o+n);r.push(new i.Segment(c,a,l(d),g++)),s&&!u&&(u=c)}if(this.loader.load(r,t.swarmId),u){const t=this.loader.getSegment(u);t&&this.onSegmentLoaded(t)}}getSegmentId(t,e){return`${t.swarmId}+${e}`}getSwarmId(t){const e=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:void 0;if(this.masterPlaylist){const s=e||this.masterPlaylist.requestUrl.split("?")[0];for(let e=0;e<this.masterPlaylist.manifest.playlists.length;++e)if(new URL(this.masterPlaylist.manifest.playlists[e].uri,this.masterPlaylist.responseUrl).toString()===t)return{swarmId:`${s}+V${e}`,found:!0}}return{swarmId:e||t,found:!1}}loadContent(t,e,s){return n(this,void 0,void 0,function*(){return new Promise((n,i)=>{const r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,s&&r.setRequestHeader("Range",s),r.addEventListener("readystatechange",()=>{4===r.readyState&&(r.status>=200&&r.status<300?n(r):i(r.statusText))});const a=this.loader.getSettings().xhrSetup;a&&a(r,t),r.send()})})}};class o{constructor(t,e,s){this.requestUrl=t,this.responseUrl=e,this.manifest=s,this.swarmId=""}getSegmentIndex(t,e){for(let s=0;s<this.manifest.segments.length;++s){const n=this.manifest.segments[s];if(t===this.getSegmentAbsoluteUrl(n.uri)&&g(n.byterange,e))return s}return-1}getSegmentAbsoluteUrl(t){return new URL(t,this.responseUrl).toString()}}class u{constructor(t,e,s,n,i,r){this.segmentUrl=t,this.segmentByterange=e,this.segmentSequence=s,this.playlistRequestUrl=n,this.onSuccess=i,this.onError=r}}function g(t,e){return void 0===t?void 0===e:void 0!==e&&t.length===e.length&&t.offset===e.offset}function l(t){if(void 0===t)return;const e=t.offset+t.length-1;return`bytes=${t.offset}-${e}`}},{"m3u8-parser":6,"p2p-media-loader-core":"p2p-media-loader-core"}],6:[function(t,e,s){"use strict";function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t}).apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}Object.defineProperty(s,"__esModule",{value:!0});var a=function(){function t(){this.listeners={}}var e=t.prototype;return e.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},e.off=function(t,e){if(!this.listeners[t])return!1;var s=this.listeners[t].indexOf(e);return this.listeners[t].splice(s,1),s>-1},e.trigger=function(t){var e,s,n,i=this.listeners[t];if(i)if(2===arguments.length)for(s=i.length,e=0;e<s;++e)i[e].call(this,arguments[1]);else for(n=Array.prototype.slice.call(arguments,1),s=i.length,e=0;e<s;++e)i[e].apply(this,n)},e.dispose=function(){this.listeners={}},e.pipe=function(t){this.on("data",function(e){t.push(e)})},t}(),o=function(t){function e(){var e;return(e=t.call(this)||this).buffer="",e}return i(e,t),e.prototype.push=function(t){var e;for(this.buffer+=t,e=this.buffer.indexOf("\n");e>-1;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)},e}(a),u=function(t){for(var e,s=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},i=s.length;i--;)""!==s[i]&&((e=/([^=]*)=(.*)/.exec(s[i]).slice(1))[0]=e[0].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^['"](.*)['"]$/g,"$1"),n[e[0]]=e[1]);return n},g=function(t){function e(){var e;return(e=t.call(this)||this).customParsers=[],e.tagMappers=[],e}i(e,t);var s=e.prototype;return s.push=function(t){var e,s,n=this;0!==(t=t.trim()).length&&("#"===t[0]?this.tagMappers.reduce(function(e,s){var n=s(t);return n===t?e:e.concat([n])},[t]).forEach(function(t){for(var i=0;i<n.customParsers.length;i++)if(n.customParsers[i].call(n,t))return;if(0===t.indexOf("#EXT"))if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t))n.trigger("data",{type:"tag",tagType:"m3u"});else{if(e=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(t))return s={type:"tag",tagType:"inf"},e[1]&&(s.duration=parseFloat(e[1])),e[2]&&(s.title=e[2]),void n.trigger("data",s);if(e=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"targetduration"},e[1]&&(s.duration=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"totalduration"},e[1]&&(s.duration=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"version"},e[1]&&(s.version=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return s={type:"tag",tagType:"media-sequence"},e[1]&&(s.number=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return s={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(s.number=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(t))return s={type:"tag",tagType:"playlist-type"},e[1]&&(s.playlistType=e[1]),void n.trigger("data",s);if(e=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"byterange"},e[1]&&(s.length=parseInt(e[1],10)),e[2]&&(s.offset=parseInt(e[2],10)),void n.trigger("data",s);if(e=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(t))return s={type:"tag",tagType:"allow-cache"},e[1]&&(s.allowed=!/NO/.test(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-MAP:?(.*)$/.exec(t)){if(s={type:"tag",tagType:"map"},e[1]){var r=u(e[1]);if(r.URI&&(s.uri=r.URI),r.BYTERANGE){var a=r.BYTERANGE.split("@"),o=a[0],g=a[1];s.byterange={},o&&(s.byterange.length=parseInt(o,10)),g&&(s.byterange.offset=parseInt(g,10))}}n.trigger("data",s)}else if(e=/^#EXT-X-STREAM-INF:?(.*)$/.exec(t)){if(s={type:"tag",tagType:"stream-inf"},e[1]){if(s.attributes=u(e[1]),s.attributes.RESOLUTION){var l=s.attributes.RESOLUTION.split("x"),d={};l[0]&&(d.width=parseInt(l[0],10)),l[1]&&(d.height=parseInt(l[1],10)),s.attributes.RESOLUTION=d}s.attributes.BANDWIDTH&&(s.attributes.BANDWIDTH=parseInt(s.attributes.BANDWIDTH,10)),s.attributes["PROGRAM-ID"]&&(s.attributes["PROGRAM-ID"]=parseInt(s.attributes["PROGRAM-ID"],10))}n.trigger("data",s)}else{if(e=/^#EXT-X-MEDIA:?(.*)$/.exec(t))return s={type:"tag",tagType:"media"},e[1]&&(s.attributes=u(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-ENDLIST/.exec(t))n.trigger("data",{type:"tag",tagType:"endlist"});else if(e=/^#EXT-X-DISCONTINUITY/.exec(t))n.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(e=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(t))return s={type:"tag",tagType:"program-date-time"},e[1]&&(s.dateTimeString=e[1],s.dateTimeObject=new Date(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-KEY:?(.*)$/.exec(t))return s={type:"tag",tagType:"key"},e[1]&&(s.attributes=u(e[1]),s.attributes.IV&&("0x"===s.attributes.IV.substring(0,2).toLowerCase()&&(s.attributes.IV=s.attributes.IV.substring(2)),s.attributes.IV=s.attributes.IV.match(/.{8}/g),s.attributes.IV[0]=parseInt(s.attributes.IV[0],16),s.attributes.IV[1]=parseInt(s.attributes.IV[1],16),s.attributes.IV[2]=parseInt(s.attributes.IV[2],16),s.attributes.IV[3]=parseInt(s.attributes.IV[3],16),s.attributes.IV=new Uint32Array(s.attributes.IV))),void n.trigger("data",s);if(e=/^#EXT-X-START:?(.*)$/.exec(t))return s={type:"tag",tagType:"start"},e[1]&&(s.attributes=u(e[1]),s.attributes["TIME-OFFSET"]=parseFloat(s.attributes["TIME-OFFSET"]),s.attributes.PRECISE=/YES/.test(s.attributes.PRECISE)),void n.trigger("data",s);if(e=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-out-cont"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);if(e=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-out"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);if(e=/^#EXT-X-CUE-IN:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-in"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);n.trigger("data",{type:"tag",data:t.slice(4)})}}}else n.trigger("data",{type:"comment",text:t.slice(1)})}):this.trigger("data",{type:"uri",uri:t}))},s.addParser=function(t){var e=this,s=t.expression,n=t.customType,i=t.dataParser,r=t.segment;"function"!=typeof i&&(i=function(t){return t}),this.customParsers.push(function(t){if(s.exec(t))return e.trigger("data",{type:"custom",data:i(t),customType:n,segment:r}),!0})},s.addTagMapper=function(t){var e=t.expression,s=t.map;this.tagMappers.push(function(t){return e.test(t)?s(t):t})},e}(a),l=function(t){function e(){var e;(e=t.call(this)||this).lineStream=new o,e.parseStream=new g,e.lineStream.pipe(e.parseStream);var s,i,a=r(r(e)),u=[],l={},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},c=0;return e.manifest={allowCache:!0,discontinuityStarts:[],segments:[]},e.parseStream.on("data",function(t){var e,r;({tag:function(){({"allow-cache":function(){this.manifest.allowCache=t.allowed,"allowed"in t||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function(){var e={};"length"in t&&(l.byterange=e,e.length=t.length,"offset"in t||(this.trigger("info",{message:"defaulting offset to zero"}),t.offset=0)),"offset"in t&&(l.byterange=e,e.offset=t.offset)},endlist:function(){this.manifest.endList=!0},inf:function(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),t.duration>0&&(l.duration=t.duration),0===t.duration&&(l.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=u},key:function(){t.attributes?"NONE"!==t.attributes.METHOD?t.attributes.URI?(t.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),i={method:t.attributes.METHOD||"AES-128",uri:t.attributes.URI},void 0!==t.attributes.IV&&(i.iv=t.attributes.IV)):this.trigger("warn",{message:"ignoring key declaration without URI"}):i=null:this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){isFinite(t.number)?this.manifest.mediaSequence=t.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+t.number})},"discontinuity-sequence":function(){isFinite(t.number)?(this.manifest.discontinuitySequence=t.number,c=t.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+t.number})},"playlist-type":function(){/VOD|EVENT/.test(t.playlistType)?this.manifest.playlistType=t.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+t.playlist})},map:function(){s={},t.uri&&(s.uri=t.uri),t.byterange&&(s.byterange=t.byterange)},"stream-inf":function(){this.manifest.playlists=u,this.manifest.mediaGroups=this.manifest.mediaGroups||d,t.attributes?(l.attributes||(l.attributes={}),n(l.attributes,t.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,t.attributes&&t.attributes.TYPE&&t.attributes["GROUP-ID"]&&t.attributes.NAME){var s=this.manifest.mediaGroups[t.attributes.TYPE];s[t.attributes["GROUP-ID"]]=s[t.attributes["GROUP-ID"]]||{},e=s[t.attributes["GROUP-ID"]],(r={default:/yes/i.test(t.attributes.DEFAULT)}).default?r.autoselect=!0:r.autoselect=/yes/i.test(t.attributes.AUTOSELECT),t.attributes.LANGUAGE&&(r.language=t.attributes.LANGUAGE),t.attributes.URI&&(r.uri=t.attributes.URI),t.attributes["INSTREAM-ID"]&&(r.instreamId=t.attributes["INSTREAM-ID"]),t.attributes.CHARACTERISTICS&&(r.characteristics=t.attributes.CHARACTERISTICS),t.attributes.FORCED&&(r.forced=/yes/i.test(t.attributes.FORCED)),e[t.attributes.NAME]=r}else this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity:function(){c+=1,l.discontinuity=!0,this.manifest.discontinuityStarts.push(u.length)},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=t.dateTimeString,this.manifest.dateTimeObject=t.dateTimeObject),l.dateTimeString=t.dateTimeString,l.dateTimeObject=t.dateTimeObject},targetduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+t.duration}):this.manifest.targetDuration=t.duration},totalduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+t.duration}):this.manifest.totalDuration=t.duration},start:function(){t.attributes&&!isNaN(t.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:t.attributes["TIME-OFFSET"],precise:t.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out":function(){l.cueOut=t.data},"cue-out-cont":function(){l.cueOutCont=t.data},"cue-in":function(){l.cueIn=t.data}}[t.tagType]||function(){}).call(a)},uri:function(){l.uri=t.uri,u.push(l),!this.manifest.targetDuration||"duration"in l||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),l.duration=this.manifest.targetDuration),i&&(l.key=i),l.timeline=c,s&&(l.map=s),l={}},comment:function(){},custom:function(){t.segment?(l.custom=l.custom||{},l.custom[t.customType]=t.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[t.customType]=t.data)}})[t.type].call(a)}),e}i(e,t);var s=e.prototype;return s.push=function(t){this.lineStream.push(t)},s.end=function(){this.lineStream.push("\n")},s.addParser=function(t){this.parseStream.addParser(t)},s.addTagMapper=function(t){this.parseStream.addTagMapper(t)},e}(a);s.LineStream=o,s.ParseStream=g,s.Parser=l},{}],"p2p-media-loader-hlsjs":[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const n=t("./engine");function i(t){t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&r(t,t.config.loader.getEngine())}function r(t,e){t.on("hlsFragChanged",function(t,s){const n=s.frag,i=2!==n.byteRange.length?void 0:{offset:n.byteRange[0],length:n.byteRange[1]-n.byteRange[0]};e.setPlayingSegment(n.url,i)}),t.on("hlsDestroying",function(){e.destroy()})}s.Engine=n.Engine,s.initHlsJsPlayer=i,s.initClapprPlayer=function(t){t.on("play",()=>{const e=t.core.getCurrentPlayback();e._hls&&!e._hls._p2pm_linitialized&&(e._hls._p2pm_linitialized=!0,i(t.core.getCurrentPlayback()._hls))})},s.initFlowplayerHlsJsPlayer=function(t){t.on("ready",()=>i(t.engine.hlsjs?t.engine.hlsjs:t.engine.hls))},s.initVideoJsContribHlsJsPlayer=function(t){t.ready(()=>{const e=t.tech_.options_;e&&e.hlsjsConfig&&e.hlsjsConfig.loader&&"function"==typeof e.hlsjsConfig.loader.getEngine&&r(t.tech_,e.hlsjsConfig.loader.getEngine())})},s.initMediaElementJsPlayer=function(t){t.addEventListener("hlsFragChanged",e=>{const s=t.hlsPlayer;if(s&&s.config&&s.config.loader&&"function"==typeof s.config.loader.getEngine){const t=s.config.loader.getEngine();if(e.data&&e.data.length>1){const s=e.data[1].frag,n=2!==s.byteRange.length?void 0:{offset:s.byteRange[0],length:s.byteRange[1]-s.byteRange[0]};t.setPlayingSegment(s.url,n)}}}),t.addEventListener("hlsDestroying",()=>{const e=t.hlsPlayer;e&&e.config&&e.config.loader&&"function"==typeof e.config.loader.getEngine&&e.config.loader.getEngine().destroy()})},s.initJwPlayer=function(t,e){const s=setInterval(()=>{t.hls&&t.hls.config&&(clearInterval(s),t.hls.config=Object.assign(t.hls.config,e),i(t.hls))},200)},s.version="undefined"==typeof __P2PML_VERSION__?"0.4.0":__P2PML_VERSION__},{"./engine":2}]},{},[1]); | ||
require=function(){return function t(e,s,n){function i(a,o){if(!s[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(r)return r(a,!0);var g=new Error("Cannot find module '"+a+"'");throw g.code="MODULE_NOT_FOUND",g}var l=s[a]={exports:{}};e[a][0].call(l.exports,function(t){return i(e[a][1][t]||t)},l,l.exports,t,e,s,n)}return s[a].exports}for(var r="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}}()({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 n=t("events"),i=t("p2p-media-loader-core"),r=t("./segment-manager"),a=t("./hlsjs-loader"),o=t("./hlsjs-loader-class");s.Engine=class extends n.EventEmitter{static isSupported(){return i.HybridLoader.isSupported()}constructor(t={}){super(),this.loader=new i.HybridLoader(t.loader),this.segmentManager=new r.SegmentManager(this.loader,t.segments),Object.keys(i.Events).map(t=>i.Events[t]).forEach(t=>this.loader.on(t,(...e)=>this.emit(t,...e)))}createLoaderClass(){return o.createHlsJsLoaderClass(a.HlsJsLoader,this)}destroy(){this.loader.destroy(),this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}setPlayingSegment(t,e){this.segmentManager.setPlayingSegment(t,e)}}},{"./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 n=1,i=12500;s.HlsJsLoader=class{constructor(t){this.stats={},this.segmentManager=t}load(t,e,s){t.type?this.segmentManager.loadPlaylist(t.url).then(e=>this.successPlaylist(e,t,s)).catch(e=>this.error(e,t,s)):t.frag?this.segmentManager.loadSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart},(e,n)=>setTimeout(()=>this.successSegment(e,n,t,s),0),e=>setTimeout(()=>this.error(e,t,s),0)):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 n=performance.now();this.stats.trequest=n-300,this.stats.tfirst=n-200,this.stats.tload=n,this.stats.loaded=t.response.length,s.onSuccess({url:t.responseURL,data:t.response},this.stats,e)}successSegment(t,e,s,r){const a=performance.now(),o=t.byteLength/(e<=0?i:e);this.stats.trequest=a-n-o,this.stats.tfirst=a-o,this.stats.tload=a,this.stats.loaded=t.byteLength,r.onSuccess({url:s.url,data:t},this.stats,s)}error(t,e,s){s.onError(t,e)}}},{}],5:[function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))(function(i,r){function a(t){try{u(n.next(t))}catch(t){r(t)}}function o(t){try{u(n.throw(t))}catch(t){r(t)}}function u(t){t.done?i(t.value):new s(function(e){e(t.value)}).then(a,o)}u((n=n.apply(t,e||[])).next())})};Object.defineProperty(s,"__esModule",{value:!0});const i=t("p2p-media-loader-core"),r=t("m3u8-parser"),a={forwardSegmentCount:20,swarmId: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.downloadSpeed),this.segmentRequest=null)}),this.onSegmentError=((t,e)=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError(e),this.segmentRequest=null)}),this.onSegmentAbort=(t=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&l(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError("Loading aborted: internal abort"),this.segmentRequest=null)}),this.settings=Object.assign({},a,e),this.loader=t,this.loader.on(i.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(i.Events.SegmentError,this.onSegmentError),this.loader.on(i.Events.SegmentAbort,this.onSegmentAbort)}getSettings(){return this.settings}processPlaylist(t,e,s){const n=new r.Parser;n.push(e),n.end();const i=new o(t,s,n.manifest);if(i.manifest.playlists){this.masterPlaylist=i;for(const[t,e]of this.variantPlaylists){const{swarmId:s,found:n}=this.getSwarmId(e.requestUrl);n?e.swarmId=s:this.variantPlaylists.delete(t)}}else{const{swarmId:e,found:s}=this.getSwarmId(t);!s&&this.masterPlaylist||(i.swarmId=e,this.variantPlaylists.set(t,i),this.updateSegments())}}loadPlaylist(t){return n(this,void 0,void 0,function*(){const e=yield this.loadContent(t,"text");return this.processPlaylist(t,e.response,e.responseURL),e})}loadSegment(t,e,s,n){const i=this.getSegmentLocation(t,e);if(!i)return void this.loadContent(t,"arraybuffer",l(e)).then(t=>s(t.response,0)).catch(t=>n(t));const r=(i.playlist.manifest.mediaSequence?i.playlist.manifest.mediaSequence:0)+i.segmentIndex;this.playQueue.length>0&&this.playQueue[this.playQueue.length-1].segmentSequence!==r-1&&(this.playQueue=[]),this.segmentRequest&&this.segmentRequest.onError("Cancel segment request: simultaneous segment requests are not supported"),this.segmentRequest=new u(t,e,r,i.playlist.requestUrl,s,n),this.playQueue.push({segmentUrl:t,segmentByterange:e,segmentSequence:r}),this.loadSegments(i.playlist,i.segmentIndex,!0)}setPlayingSegment(t,e){const s=this.playQueue.findIndex(s=>s.segmentUrl==t&&g(s.segmentByterange,e));s>=0&&(this.playQueue=this.playQueue.slice(s),this.updateSegments())}abortSegment(t,e){this.segmentRequest&&this.segmentRequest.segmentUrl===t&&g(this.segmentRequest.segmentByterange,e)&&(this.segmentRequest=null)}destroy(){this.loader.destroy(),this.segmentRequest&&(this.segmentRequest.onError("Loading aborted: object destroyed"),this.segmentRequest=null),this.masterPlaylist=null,this.variantPlaylists.clear(),this.playQueue=[]}updateSegments(){if(!this.segmentRequest)return;const t=this.getSegmentLocation(this.segmentRequest.segmentUrl,this.segmentRequest.segmentByterange);if(t)this.loadSegments(t.playlist,t.segmentIndex,!1);else{const t=this.variantPlaylists.get(this.segmentRequest.playlistRequestUrl);t&&this.loadSegments(t,0,!1,{url:this.segmentRequest.segmentUrl,byterange:this.segmentRequest.segmentByterange,sequence:this.segmentRequest.segmentSequence})}}getSegmentLocation(t,e){for(const s of this.variantPlaylists.values()){const n=s.getSegmentIndex(t,e);if(n>=0)return{playlist:s,segmentIndex:n}}}loadSegments(t,e,s,n){const r=[],a=t.manifest.segments,o=t.manifest.mediaSequence?t.manifest.mediaSequence:0;let u=null,g=Math.max(0,this.playQueue.length-1);if(n){const e=t.getSegmentAbsoluteUrl(n.url),a=this.getSegmentId(t,n.sequence);r.push(new i.Segment(a,e,l(n.byterange),g++)),s&&(u=a)}for(let n=e;n<a.length&&r.length<this.settings.forwardSegmentCount;++n){const e=t.manifest.segments[n],a=t.getSegmentAbsoluteUrl(e.uri),d=e.byterange,c=this.getSegmentId(t,o+n);r.push(new i.Segment(c,a,l(d),g++)),s&&!u&&(u=c)}if(this.loader.load(r,t.swarmId),u){const t=this.loader.getSegment(u);t&&this.onSegmentLoaded(t)}}getSegmentId(t,e){return`${t.swarmId}+${e}`}getSwarmId(t){const e=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:void 0;if(this.masterPlaylist){const s=e||this.masterPlaylist.requestUrl.split("?")[0];for(let e=0;e<this.masterPlaylist.manifest.playlists.length;++e)if(new URL(this.masterPlaylist.manifest.playlists[e].uri,this.masterPlaylist.responseUrl).toString()===t)return{swarmId:`${s}+V${e}`,found:!0}}return{swarmId:e||t,found:!1}}loadContent(t,e,s){return n(this,void 0,void 0,function*(){return new Promise((n,i)=>{const r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,s&&r.setRequestHeader("Range",s),r.addEventListener("readystatechange",()=>{4===r.readyState&&(r.status>=200&&r.status<300?n(r):i(r.statusText))});const a=this.loader.getSettings().xhrSetup;a&&a(r,t),r.send()})})}};class o{constructor(t,e,s){this.requestUrl=t,this.responseUrl=e,this.manifest=s,this.swarmId=""}getSegmentIndex(t,e){for(let s=0;s<this.manifest.segments.length;++s){const n=this.manifest.segments[s];if(t===this.getSegmentAbsoluteUrl(n.uri)&&g(n.byterange,e))return s}return-1}getSegmentAbsoluteUrl(t){return new URL(t,this.responseUrl).toString()}}class u{constructor(t,e,s,n,i,r){this.segmentUrl=t,this.segmentByterange=e,this.segmentSequence=s,this.playlistRequestUrl=n,this.onSuccess=i,this.onError=r}}function g(t,e){return void 0===t?void 0===e:void 0!==e&&t.length===e.length&&t.offset===e.offset}function l(t){if(void 0===t)return;const e=t.offset+t.length-1;return`bytes=${t.offset}-${e}`}},{"m3u8-parser":6,"p2p-media-loader-core":"p2p-media-loader-core"}],6:[function(t,e,s){"use strict";function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t}).apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}Object.defineProperty(s,"__esModule",{value:!0});var a=function(){function t(){this.listeners={}}var e=t.prototype;return e.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},e.off=function(t,e){if(!this.listeners[t])return!1;var s=this.listeners[t].indexOf(e);return this.listeners[t].splice(s,1),s>-1},e.trigger=function(t){var e,s,n,i=this.listeners[t];if(i)if(2===arguments.length)for(s=i.length,e=0;e<s;++e)i[e].call(this,arguments[1]);else for(n=Array.prototype.slice.call(arguments,1),s=i.length,e=0;e<s;++e)i[e].apply(this,n)},e.dispose=function(){this.listeners={}},e.pipe=function(t){this.on("data",function(e){t.push(e)})},t}(),o=function(t){function e(){var e;return(e=t.call(this)||this).buffer="",e}return i(e,t),e.prototype.push=function(t){var e;for(this.buffer+=t,e=this.buffer.indexOf("\n");e>-1;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)},e}(a),u=function(t){for(var e,s=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},i=s.length;i--;)""!==s[i]&&((e=/([^=]*)=(.*)/.exec(s[i]).slice(1))[0]=e[0].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^['"](.*)['"]$/g,"$1"),n[e[0]]=e[1]);return n},g=function(t){function e(){var e;return(e=t.call(this)||this).customParsers=[],e.tagMappers=[],e}i(e,t);var s=e.prototype;return s.push=function(t){var e,s,n=this;0!==(t=t.trim()).length&&("#"===t[0]?this.tagMappers.reduce(function(e,s){var n=s(t);return n===t?e:e.concat([n])},[t]).forEach(function(t){for(var i=0;i<n.customParsers.length;i++)if(n.customParsers[i].call(n,t))return;if(0===t.indexOf("#EXT"))if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t))n.trigger("data",{type:"tag",tagType:"m3u"});else{if(e=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(t))return s={type:"tag",tagType:"inf"},e[1]&&(s.duration=parseFloat(e[1])),e[2]&&(s.title=e[2]),void n.trigger("data",s);if(e=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"targetduration"},e[1]&&(s.duration=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"totalduration"},e[1]&&(s.duration=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"version"},e[1]&&(s.version=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return s={type:"tag",tagType:"media-sequence"},e[1]&&(s.number=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return s={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(s.number=parseInt(e[1],10)),void n.trigger("data",s);if(e=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(t))return s={type:"tag",tagType:"playlist-type"},e[1]&&(s.playlistType=e[1]),void n.trigger("data",s);if(e=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(t))return s={type:"tag",tagType:"byterange"},e[1]&&(s.length=parseInt(e[1],10)),e[2]&&(s.offset=parseInt(e[2],10)),void n.trigger("data",s);if(e=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(t))return s={type:"tag",tagType:"allow-cache"},e[1]&&(s.allowed=!/NO/.test(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-MAP:?(.*)$/.exec(t)){if(s={type:"tag",tagType:"map"},e[1]){var r=u(e[1]);if(r.URI&&(s.uri=r.URI),r.BYTERANGE){var a=r.BYTERANGE.split("@"),o=a[0],g=a[1];s.byterange={},o&&(s.byterange.length=parseInt(o,10)),g&&(s.byterange.offset=parseInt(g,10))}}n.trigger("data",s)}else if(e=/^#EXT-X-STREAM-INF:?(.*)$/.exec(t)){if(s={type:"tag",tagType:"stream-inf"},e[1]){if(s.attributes=u(e[1]),s.attributes.RESOLUTION){var l=s.attributes.RESOLUTION.split("x"),d={};l[0]&&(d.width=parseInt(l[0],10)),l[1]&&(d.height=parseInt(l[1],10)),s.attributes.RESOLUTION=d}s.attributes.BANDWIDTH&&(s.attributes.BANDWIDTH=parseInt(s.attributes.BANDWIDTH,10)),s.attributes["PROGRAM-ID"]&&(s.attributes["PROGRAM-ID"]=parseInt(s.attributes["PROGRAM-ID"],10))}n.trigger("data",s)}else{if(e=/^#EXT-X-MEDIA:?(.*)$/.exec(t))return s={type:"tag",tagType:"media"},e[1]&&(s.attributes=u(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-ENDLIST/.exec(t))n.trigger("data",{type:"tag",tagType:"endlist"});else if(e=/^#EXT-X-DISCONTINUITY/.exec(t))n.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(e=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(t))return s={type:"tag",tagType:"program-date-time"},e[1]&&(s.dateTimeString=e[1],s.dateTimeObject=new Date(e[1])),void n.trigger("data",s);if(e=/^#EXT-X-KEY:?(.*)$/.exec(t))return s={type:"tag",tagType:"key"},e[1]&&(s.attributes=u(e[1]),s.attributes.IV&&("0x"===s.attributes.IV.substring(0,2).toLowerCase()&&(s.attributes.IV=s.attributes.IV.substring(2)),s.attributes.IV=s.attributes.IV.match(/.{8}/g),s.attributes.IV[0]=parseInt(s.attributes.IV[0],16),s.attributes.IV[1]=parseInt(s.attributes.IV[1],16),s.attributes.IV[2]=parseInt(s.attributes.IV[2],16),s.attributes.IV[3]=parseInt(s.attributes.IV[3],16),s.attributes.IV=new Uint32Array(s.attributes.IV))),void n.trigger("data",s);if(e=/^#EXT-X-START:?(.*)$/.exec(t))return s={type:"tag",tagType:"start"},e[1]&&(s.attributes=u(e[1]),s.attributes["TIME-OFFSET"]=parseFloat(s.attributes["TIME-OFFSET"]),s.attributes.PRECISE=/YES/.test(s.attributes.PRECISE)),void n.trigger("data",s);if(e=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-out-cont"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);if(e=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-out"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);if(e=/^#EXT-X-CUE-IN:?(.*)?$/.exec(t))return s={type:"tag",tagType:"cue-in"},e[1]?s.data=e[1]:s.data="",void n.trigger("data",s);n.trigger("data",{type:"tag",data:t.slice(4)})}}}else n.trigger("data",{type:"comment",text:t.slice(1)})}):this.trigger("data",{type:"uri",uri:t}))},s.addParser=function(t){var e=this,s=t.expression,n=t.customType,i=t.dataParser,r=t.segment;"function"!=typeof i&&(i=function(t){return t}),this.customParsers.push(function(t){if(s.exec(t))return e.trigger("data",{type:"custom",data:i(t),customType:n,segment:r}),!0})},s.addTagMapper=function(t){var e=t.expression,s=t.map;this.tagMappers.push(function(t){return e.test(t)?s(t):t})},e}(a),l=function(t){function e(){var e;(e=t.call(this)||this).lineStream=new o,e.parseStream=new g,e.lineStream.pipe(e.parseStream);var s,i,a=r(r(e)),u=[],l={},d={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},c=0;return e.manifest={allowCache:!0,discontinuityStarts:[],segments:[]},e.parseStream.on("data",function(t){var e,r;({tag:function(){({"allow-cache":function(){this.manifest.allowCache=t.allowed,"allowed"in t||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function(){var e={};"length"in t&&(l.byterange=e,e.length=t.length,"offset"in t||(this.trigger("info",{message:"defaulting offset to zero"}),t.offset=0)),"offset"in t&&(l.byterange=e,e.offset=t.offset)},endlist:function(){this.manifest.endList=!0},inf:function(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),t.duration>0&&(l.duration=t.duration),0===t.duration&&(l.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=u},key:function(){t.attributes?"NONE"!==t.attributes.METHOD?t.attributes.URI?(t.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),i={method:t.attributes.METHOD||"AES-128",uri:t.attributes.URI},void 0!==t.attributes.IV&&(i.iv=t.attributes.IV)):this.trigger("warn",{message:"ignoring key declaration without URI"}):i=null:this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){isFinite(t.number)?this.manifest.mediaSequence=t.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+t.number})},"discontinuity-sequence":function(){isFinite(t.number)?(this.manifest.discontinuitySequence=t.number,c=t.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+t.number})},"playlist-type":function(){/VOD|EVENT/.test(t.playlistType)?this.manifest.playlistType=t.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+t.playlist})},map:function(){s={},t.uri&&(s.uri=t.uri),t.byterange&&(s.byterange=t.byterange)},"stream-inf":function(){this.manifest.playlists=u,this.manifest.mediaGroups=this.manifest.mediaGroups||d,t.attributes?(l.attributes||(l.attributes={}),n(l.attributes,t.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||d,t.attributes&&t.attributes.TYPE&&t.attributes["GROUP-ID"]&&t.attributes.NAME){var s=this.manifest.mediaGroups[t.attributes.TYPE];s[t.attributes["GROUP-ID"]]=s[t.attributes["GROUP-ID"]]||{},e=s[t.attributes["GROUP-ID"]],(r={default:/yes/i.test(t.attributes.DEFAULT)}).default?r.autoselect=!0:r.autoselect=/yes/i.test(t.attributes.AUTOSELECT),t.attributes.LANGUAGE&&(r.language=t.attributes.LANGUAGE),t.attributes.URI&&(r.uri=t.attributes.URI),t.attributes["INSTREAM-ID"]&&(r.instreamId=t.attributes["INSTREAM-ID"]),t.attributes.CHARACTERISTICS&&(r.characteristics=t.attributes.CHARACTERISTICS),t.attributes.FORCED&&(r.forced=/yes/i.test(t.attributes.FORCED)),e[t.attributes.NAME]=r}else this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity:function(){c+=1,l.discontinuity=!0,this.manifest.discontinuityStarts.push(u.length)},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=t.dateTimeString,this.manifest.dateTimeObject=t.dateTimeObject),l.dateTimeString=t.dateTimeString,l.dateTimeObject=t.dateTimeObject},targetduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+t.duration}):this.manifest.targetDuration=t.duration},totalduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+t.duration}):this.manifest.totalDuration=t.duration},start:function(){t.attributes&&!isNaN(t.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:t.attributes["TIME-OFFSET"],precise:t.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out":function(){l.cueOut=t.data},"cue-out-cont":function(){l.cueOutCont=t.data},"cue-in":function(){l.cueIn=t.data}}[t.tagType]||function(){}).call(a)},uri:function(){l.uri=t.uri,u.push(l),!this.manifest.targetDuration||"duration"in l||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),l.duration=this.manifest.targetDuration),i&&(l.key=i),l.timeline=c,s&&(l.map=s),l={}},comment:function(){},custom:function(){t.segment?(l.custom=l.custom||{},l.custom[t.customType]=t.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[t.customType]=t.data)}})[t.type].call(a)}),e}i(e,t);var s=e.prototype;return s.push=function(t){this.lineStream.push(t)},s.end=function(){this.lineStream.push("\n")},s.addParser=function(t){this.parseStream.addParser(t)},s.addTagMapper=function(t){this.parseStream.addTagMapper(t)},e}(a);s.LineStream=o,s.ParseStream=g,s.Parser=l},{}],"p2p-media-loader-hlsjs":[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const n=t("./engine");function i(t){t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&r(t,t.config.loader.getEngine())}function r(t,e){t.on("hlsFragChanged",function(t,s){const n=s.frag,i=2!==n.byteRange.length?void 0:{offset:n.byteRange[0],length:n.byteRange[1]-n.byteRange[0]};e.setPlayingSegment(n.url,i)}),t.on("hlsDestroying",function(){e.destroy()})}s.Engine=n.Engine,s.initHlsJsPlayer=i,s.initClapprPlayer=function(t){t.on("play",()=>{const e=t.core.getCurrentPlayback();e._hls&&!e._hls._p2pm_linitialized&&(e._hls._p2pm_linitialized=!0,i(t.core.getCurrentPlayback()._hls))})},s.initFlowplayerHlsJsPlayer=function(t){t.on("ready",()=>i(t.engine.hlsjs?t.engine.hlsjs:t.engine.hls))},s.initVideoJsContribHlsJsPlayer=function(t){t.ready(()=>{const e=t.tech_.options_;e&&e.hlsjsConfig&&e.hlsjsConfig.loader&&"function"==typeof e.hlsjsConfig.loader.getEngine&&r(t.tech_,e.hlsjsConfig.loader.getEngine())})},s.initMediaElementJsPlayer=function(t){t.addEventListener("hlsFragChanged",e=>{const s=t.hlsPlayer;if(s&&s.config&&s.config.loader&&"function"==typeof s.config.loader.getEngine){const t=s.config.loader.getEngine();if(e.data&&e.data.length>1){const s=e.data[1].frag,n=2!==s.byteRange.length?void 0:{offset:s.byteRange[0],length:s.byteRange[1]-s.byteRange[0]};t.setPlayingSegment(s.url,n)}}}),t.addEventListener("hlsDestroying",()=>{const e=t.hlsPlayer;e&&e.config&&e.config.loader&&"function"==typeof e.config.loader.getEngine&&e.config.loader.getEngine().destroy()})},s.initJwPlayer=function(t,e){const s=setInterval(()=>{t.hls&&t.hls.config&&(clearInterval(s),Object.assign(t.hls.config,e),i(t.hls))},200)},s.version="undefined"==typeof __P2PML_VERSION__?"0.5.0":__P2PML_VERSION__},{"./engine":2}]},{},[1]); |
@@ -77,3 +77,3 @@ "use strict"; | ||
clearInterval(iid); | ||
player.hls.config = Object.assign(player.hls.config, hlsjsConfig); | ||
Object.assign(player.hls.config, hlsjsConfig); | ||
initHlsJsPlayer(player.hls); | ||
@@ -80,0 +80,0 @@ } |
@@ -59,3 +59,3 @@ "use strict"; | ||
}; | ||
this.settings = Object.assign(defaultSettings, settings); | ||
this.settings = Object.assign({}, defaultSettings, settings); | ||
this.loader = loader; | ||
@@ -62,0 +62,0 @@ this.loader.on(p2p_media_loader_core_1.Events.SegmentLoaded, this.onSegmentLoaded); |
{ | ||
"name": "p2p-media-loader-hlsjs", | ||
"description": "P2P Media Loader hls.js integration", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"license": "Apache-2.0", | ||
@@ -41,3 +41,3 @@ "author": "Novage", | ||
"m3u8-parser": "^4.3.0", | ||
"p2p-media-loader-core": "^0.4.0" | ||
"p2p-media-loader-core": "^0.5.0" | ||
}, | ||
@@ -47,5 +47,5 @@ "devDependencies": { | ||
"@types/events": "^3.0.0", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.19", | ||
"@types/sinon": "^7.0.5", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^11.11.4", | ||
"@types/sinon": "^7.0.10", | ||
"browserify": "^16.2.3", | ||
@@ -55,12 +55,12 @@ "browserify-versionify": "^1.0.6", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^5.2.0", | ||
"sinon": "^7.2.3", | ||
"terser": "^3.14.1", | ||
"mocha": "^6.0.2", | ||
"sinon": "^7.3.0", | ||
"terser": "^3.17.0", | ||
"ts-loader": "^5.3.3", | ||
"ts-mockito": "^2.3.1", | ||
"ts-node": "^8.0.2", | ||
"tslint": "^5.12.1", | ||
"typescript": "^3.2.4", | ||
"webpack": "^4.29.0", | ||
"webpack-cli": "^3.2.1" | ||
"ts-node": "^8.0.3", | ||
"tslint": "^5.14.0", | ||
"typescript": "^3.3.4000", | ||
"webpack": "^4.29.6", | ||
"webpack-cli": "^3.3.0" | ||
}, | ||
@@ -67,0 +67,0 @@ "browserify": { |
@@ -9,2 +9,3 @@ # P2P Media Loader - Hls.js integration | ||
- [Demo](http://novage.com.ua/p2p-media-loader/demo.html) | ||
- [FAQ](https://github.com/Novage/p2p-media-loader/blob/master/FAQ.md) | ||
- [Overview](http://novage.com.ua/p2p-media-loader/overview.html) | ||
@@ -11,0 +12,0 @@ - [Technical overview](http://novage.com.ua/p2p-media-loader/technical-overview.html) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136389
301
+ Addedp2p-media-loader-core@0.5.0(transitive)
- Removedp2p-media-loader-core@0.4.0(transitive)
Updatedp2p-media-loader-core@^0.5.0