New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

p2p-media-loader-hlsjs

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p2p-media-loader-hlsjs - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

build/p2p-media-loader-hlsjs.min.js

@@ -18,2 +18,2 @@ require=function s(a,o,u){function l(e,t){if(!o[e]){if(!a[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(f)return f(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var i=o[e]={exports:{}};a[e][0].call(i.exports,function(t){return l(a[e][1][t]||t)},i,i.exports,s,a,o,u)}return o[e].exports}for(var f="function"==typeof require&&require,t=0;t<u.length;t++)l(u[t]);return l}({1:[function(t,e,n){

*/
window.p2pml||(window.p2pml={}),window.p2pml.hlsjs=t("p2p-media-loader-hlsjs")},{"p2p-media-loader-hlsjs":"p2p-media-loader-hlsjs"}],2:[function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var s=t("events"),a=t("p2p-media-loader-core"),o=t("./segment-manager"),u=t("./hlsjs-loader"),l=t("./hlsjs-loader-class"),f=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.loader=new a.HybridLoader(t.loader),r.segmentManager=new o.SegmentManager(r.loader,t.segments),Object.keys(a.Events).map(function(t){return a.Events[t]}).forEach(function(n){return r.loader.on(n,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.emit.apply(r,[n].concat(t))})}),r}return i(t,e),t.isSupported=function(){return a.HybridLoader.isSupported()},t.prototype.createLoaderClass=function(){return l.createHlsJsLoaderClass(u.HlsJsLoader,this)},t.prototype.destroy=function(){this.loader.destroy(),this.segmentManager.destroy()},t.prototype.getSettings=function(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}},t.prototype.setPlayingSegment=function(t){this.segmentManager.setPlayingSegment(t)},t}(s.EventEmitter);n.Engine=f},{"./hlsjs-loader":4,"./hlsjs-loader-class":3,"./segment-manager":5,events:7,"p2p-media-loader-core":void 0}],3:[function(t,e,n){e.exports.createHlsJsLoaderClass=function(t,e){function n(){this.impl=new t(e.segmentManager),this.stats=this.impl.stats}return n.prototype.load=function(t,e,n){this.context=t,this.impl.load(t,e,n)},n.prototype.abort=function(){this.impl.abort(this.context)},n.prototype.destroy=function(){this.context&&this.impl.abort(this.context)},n.getEngine=function(){return e},n}},{}],4:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t){this.stats={},this.segmentManager=t}return t.prototype.load=function(n,t,r){var i=this;n.type?this.segmentManager.loadPlaylist(n.url).then(function(t){return i.successPlaylist(t,n,r)}).catch(function(t){return i.error(t,n,r)}):n.frag?this.segmentManager.loadSegment(n.url,function(t,e){return setTimeout(function(){return i.successSegment(t,e,n,r)},0)},function(t){return setTimeout(function(){return i.error(t,n,r)},0)}):console.warn("Unknown load request",n)},t.prototype.abort=function(t){this.segmentManager.abortSegment(t.url)},t.prototype.successPlaylist=function(t,e,n){var r=performance.now();this.stats.trequest=r-300,this.stats.tfirst=r-200,this.stats.tload=r,this.stats.loaded=t.length,n.onSuccess({url:e.url,data:t},this.stats,e)},t.prototype.successSegment=function(t,e,n,r){var i=performance.now(),s=t.byteLength/(e<=0?12500:e);this.stats.trequest=i-1-s,this.stats.tfirst=i-s,this.stats.tload=i,this.stats.loaded=t.byteLength,r.onSuccess({url:n.url,data:t},this.stats,n)},t.prototype.error=function(t,e,n){n.onError(t,e)},t}();n.HlsJsLoader=r},{}],5:[function(t,e,n){"use strict";var r=this&&this.__awaiter||function(s,a,o,u){return new(o||(o=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new o(function(t){t(e.value)}).then(n,r)}i((u=u.apply(s,a||[])).next())})},i=this&&this.__generator||function(n,r){var i,s,a,t,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,s=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(a=0<(a=o.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){o.label=e[1];break}if(6===e[0]&&o.label<a[1]){o.label=a[1],a=e;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(e);break}a[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(n,o)}catch(t){e=[6,t],s=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};Object.defineProperty(n,"__esModule",{value:!0});var h=t("p2p-media-loader-core"),s=t("./utils"),a=t("m3u8-parser"),o={forwardSegmentCount:20,swarmId:void 0},u=function(){function t(t,e){void 0===e&&(e={});var n=this;this.masterPlaylist=null,this.variantPlaylists=new Map,this.segmentRequest=null,this.playQueue=[],this.onSegmentLoaded=function(t){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onSuccess(t.data.slice(0),t.downloadSpeed),n.segmentRequest=null)},this.onSegmentError=function(t,e){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onError(e),n.segmentRequest=null)},this.onSegmentAbort=function(t){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onError("Loading aborted: internal abort"),n.segmentRequest=null)},this.settings=Object.assign(o,e),this.loader=t,this.loader.on(h.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(h.Events.SegmentError,this.onSegmentError),this.loader.on(h.Events.SegmentAbort,this.onSegmentAbort)}return t.prototype.getSettings=function(){return this.settings},t.prototype.processPlaylist=function(t,e){var n=this,r=new a.Parser;r.push(e),r.end();var i=new l(t,r.manifest);if(i.manifest.playlists)this.masterPlaylist=i,this.variantPlaylists.forEach(function(t){return t.swarmId=n.getSwarmId(t.url)});else{var s=this.getSwarmId(t);s===t&&this.masterPlaylist||(i.swarmId=s,this.variantPlaylists.set(t,i),this.updateSegments())}},t.prototype.loadPlaylist=function(n){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,s.default.fetchContentAsText(n)];case 1:return e=t.sent(),this.processPlaylist(n,e),[2,e]}})})},t.prototype.loadSegment=function(t,e,n){var r=this.getSegmentLocation(t);if(r){var i=(r.playlist.manifest.mediaSequence?r.playlist.manifest.mediaSequence:0)+r.segmentIndex;if(0<this.playQueue.length)this.playQueue[this.playQueue.length-1].segmentSequence!==i-1&&(this.playQueue=[]);this.segmentRequest&&this.segmentRequest.onError("Cancel segment request: simultaneous segment requests are not supported"),this.segmentRequest=new f(t,i,r.playlist.url,e,n),this.playQueue.push({segmentUrl:t,segmentSequence:i}),this.loadSegments(r.playlist,r.segmentIndex,!0)}else s.default.fetchContentAsArrayBuffer(t).then(function(t){return e(t,0)}).catch(function(t){return n(t)})},t.prototype.setPlayingSegment=function(e){var t=this.playQueue.findIndex(function(t){return t.segmentUrl==e});0<=t&&(this.playQueue=this.playQueue.slice(t),this.updateSegments())},t.prototype.abortSegment=function(t){this.segmentRequest&&this.segmentRequest.segmentUrl===t&&(this.segmentRequest=null)},t.prototype.destroy=function(){this.loader.destroy(),this.segmentRequest&&(this.segmentRequest.onError("Loading aborted: object destroyed"),this.segmentRequest=null),this.masterPlaylist=null,this.variantPlaylists.clear(),this.playQueue=[]},t.prototype.updateSegments=function(){if(this.segmentRequest){var t=this.getSegmentLocation(this.segmentRequest.segmentUrl);if(t)this.loadSegments(t.playlist,t.segmentIndex,!1);else{var e=this.variantPlaylists.get(this.segmentRequest.playlistUrl);e&&this.loadSegments(e,0,!1,{url:this.segmentRequest.segmentUrl,sequence:this.segmentRequest.segmentSequence})}}},t.prototype.getSegmentLocation=function(t){for(var e=this.variantPlaylists.values(),n=e.next();!n.done;n=e.next()){var r=n.value,i=r.getSegmentIndex(t);if(0<=i)return{playlist:r,segmentIndex:i}}},t.prototype.loadSegments=function(t,e,n,r){var i=[],s=t.manifest.segments,a=t.manifest.mediaSequence?t.manifest.mediaSequence:0,o=null,u=Math.max(0,this.playQueue.length-1);if(r){var l=t.getSegmentAbsoluteUrl(r.url),f=this.getSegmentId(t,r.sequence);i.push(new h.Segment(f,l,void 0,u++)),n&&(o=f)}for(var c=e;c<s.length&&i.length<this.settings.forwardSegmentCount;++c){l=t.getSegmentAbsoluteUrlByIndex(c),f=this.getSegmentId(t,a+c);i.push(new h.Segment(f,l,void 0,u++)),n&&!o&&(o=f)}if(this.loader.load(i,t.swarmId),o){var g=this.loader.getSegment(o);g&&this.onSegmentLoaded(g)}},t.prototype.getSegmentId=function(t,e){return t.swarmId+"+"+e},t.prototype.getSwarmId=function(t){if(this.masterPlaylist)for(var e=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:this.masterPlaylist.url.split("?")[0],n=0;n<this.masterPlaylist.manifest.playlists.length;++n){var r=this.masterPlaylist.manifest.playlists[n].uri;if((r=s.default.isAbsoluteUrl(r)?r:this.masterPlaylist.baseUrl+r)===t)return e+"+V"+n}return t},t}();n.SegmentManager=u;var l=function(){function t(t,e){this.url=t,this.manifest=e,this.swarmId="";var n=t.lastIndexOf("/");if(-1===n)throw new Error("Unexpected playlist URL format");this.baseUrl=t.substring(0,n+1)}return t.prototype.getSegmentIndex=function(t){for(var e=0;e<this.manifest.segments.length;++e)if(t===this.getSegmentAbsoluteUrlByIndex(e))return e;return-1},t.prototype.getSegmentAbsoluteUrlByIndex=function(t){return this.getSegmentAbsoluteUrl(this.manifest.segments[t].uri)},t.prototype.getSegmentAbsoluteUrl=function(t){return s.default.isAbsoluteUrl(t)?t:this.baseUrl+t},t}(),f=function(t,e,n,r,i){this.segmentUrl=t,this.segmentSequence=e,this.playlistUrl=n,this.onSuccess=r,this.onError=i}},{"./utils":6,"m3u8-parser":8,"p2p-media-loader-core":void 0}],6:[function(t,e,n){"use strict";var s=this&&this.__awaiter||function(s,a,o,u){return new(o||(o=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new o(function(t){t(e.value)}).then(n,r)}i((u=u.apply(s,a||[])).next())})},a=this&&this.__generator||function(n,r){var i,s,a,t,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,s=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(a=0<(a=o.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){o.label=e[1];break}if(6===e[0]&&o.label<a[1]){o.label=a[1],a=e;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(e);break}a[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(n,o)}catch(t){e=[6,t],s=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function n(){}return n.fetchContentAsAny=function(r,i){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,new Promise(function(t,e){var n=new XMLHttpRequest;n.open("GET",r,!0),n.responseType=i,n.onreadystatechange=function(){4===n.readyState&&(200<=n.status&&n.status<300?t(n.response):e(n.statusText))},n.send()})]})})},n.fetchContentAsText=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,n.fetchContentAsAny(e,"text")]})})},n.fetchContentAsArrayBuffer=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,n.fetchContentAsAny(e,"arraybuffer")]})})},n.isAbsoluteUrl=function(t){return t.startsWith("http://")||t.startsWith("https://")},n}();n.default=r},{}],7:[function(t,e,n){var u=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},s=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=u(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((e.exports=r).EventEmitter=r).prototype._events=void 0,r.prototype._maxListeners=void 0;var i,o=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),i=0===l.x}catch(t){i=!1}function f(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function c(t,e,n,r){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]):(s=t._events=u(null),t._eventsCount=0),a){if("function"==typeof a?a=s[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),!a.warned&&(i=f(t))&&0<i&&a.length>i){a.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",o.name,o.message)}}else a=s[e]=n,++t._eventsCount;return t}function g(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function h(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=s.call(g,r);return i.listener=n,r.wrapFn=i}function p(t,e,n){var r=t._events;if(!r)return[];var i=r[e];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):m(i,i.length):[]}function d(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function m(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}i?Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');o=t}}):r.defaultMaxListeners=o,r.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},r.prototype.getMaxListeners=function(){return f(this)},r.prototype.emit=function(t){var e,n,r,i,s,a,o="error"===t;if(a=this._events)o=o&&null==a.error;else if(!o)return!1;if(o){if(1<arguments.length&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(n=a[t]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=m(t,r),s=0;s<r;++s)i[s].call(n)}(n,l,this);break;case 2:!function(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,s=m(t,i),a=0;a<i;++a)s[a].call(n,r)}(n,l,this,arguments[1]);break;case 3:!function(t,e,n,r,i){if(e)t.call(n,r,i);else for(var s=t.length,a=m(t,s),o=0;o<s;++o)a[o].call(n,r,i)}(n,l,this,arguments[1],arguments[2]);break;case 4:!function(t,e,n,r,i,s){if(e)t.call(n,r,i,s);else for(var a=t.length,o=m(t,a),u=0;u<a;++u)o[u].call(n,r,i,s)}(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,s=m(t,i),a=0;a<i;++a)s[a].apply(n,r)}(n,l,this,i)}return!0},r.prototype.on=r.prototype.addListener=function(t,e){return c(this,t,e,!1)},r.prototype.prependListener=function(t,e){return c(this,t,e,!0)},r.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,h(this,t,e)),this},r.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,h(this,t,e)),this},r.prototype.removeListener=function(t,e){var n,r,i,s,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=u(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,s=n.length-1;0<=s;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),r.removeListener&&this.emit("removeListener",t,a||e)}return this},r.prototype.removeAllListeners=function(t){var e,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=u(null),this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=u(null):delete n[t]),this;if(0===arguments.length){var i,s=a(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=u(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)for(r=e.length-1;0<=r;r--)this.removeListener(t,e[r]);return this},r.prototype.listeners=function(t){return p(this,t,!0)},r.prototype.rawListeners=function(t){return p(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,n){"use strict";var r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},g=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},s=function(){function t(){r(this,t),this.listeners={}}return t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},t.prototype.off=function(t,e){if(!this.listeners[t])return!1;var n=this.listeners[t].indexOf(e);return this.listeners[t].splice(n,1),-1<n},t.prototype.trigger=function(t){var e=this.listeners[t],n=void 0,r=void 0,i=void 0;if(e)if(2===arguments.length)for(r=e.length,n=0;n<r;++n)e[n].call(this,arguments[1]);else for(i=Array.prototype.slice.call(arguments,1),r=e.length,n=0;n<r;++n)e[n].apply(this,i)},t.prototype.dispose=function(){this.listeners={}},t.prototype.pipe=function(e){this.on("data",function(t){e.push(t)})},t}(),h=function(e){function n(){r(this,n);var t=g(this,e.call(this));return t.buffer="",t}return i(n,e),n.prototype.push=function(t){var e=void 0;for(this.buffer+=t,e=this.buffer.indexOf("\n");-1<e;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)},n}(s),f=function(t){for(var e=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},r=e.length,i=void 0;r--;)""!==e[r]&&((i=/([^=]*)=(.*)/.exec(e[r]).slice(1))[0]=i[0].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^['"](.*)['"]$/g,"$1"),n[i[0]]=i[1]);return n},p=function(e){function n(){r(this,n);var t=g(this,e.call(this));return t.customParsers=[],t}return i(n,e),n.prototype.push=function(t){var e=void 0,n=void 0;if(0!==(t=t.replace(/^[\u0000\s]+|[\u0000\s]+$/g,"")).length)if("#"===t[0]){for(var r=0;r<this.customParsers.length;r++)if(this.customParsers[r].call(this,t))return;if(0===t.indexOf("#EXT"))if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t))this.trigger("data",{type:"tag",tagType:"m3u"});else{if(e=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(t))return n={type:"tag",tagType:"inf"},e[1]&&(n.duration=parseFloat(e[1])),e[2]&&(n.title=e[2]),void this.trigger("data",n);if(e=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"targetduration"},e[1]&&(n.duration=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"totalduration"},e[1]&&(n.duration=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"version"},e[1]&&(n.version=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return n={type:"tag",tagType:"media-sequence"},e[1]&&(n.number=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return n={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(n.number=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(t))return n={type:"tag",tagType:"playlist-type"},e[1]&&(n.playlistType=e[1]),void this.trigger("data",n);if(e=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"byterange"},e[1]&&(n.length=parseInt(e[1],10)),e[2]&&(n.offset=parseInt(e[2],10)),void this.trigger("data",n);if(e=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(t))return n={type:"tag",tagType:"allow-cache"},e[1]&&(n.allowed=!/NO/.test(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-MAP:?(.*)$/.exec(t)){if(n={type:"tag",tagType:"map"},e[1]){var i=f(e[1]);if(i.URI&&(n.uri=i.URI),i.BYTERANGE){var s=i.BYTERANGE.split("@"),a=s[0],o=s[1];n.byterange={},a&&(n.byterange.length=parseInt(a,10)),o&&(n.byterange.offset=parseInt(o,10))}}this.trigger("data",n)}else if(e=/^#EXT-X-STREAM-INF:?(.*)$/.exec(t)){if(n={type:"tag",tagType:"stream-inf"},e[1]){if(n.attributes=f(e[1]),n.attributes.RESOLUTION){var u=n.attributes.RESOLUTION.split("x"),l={};u[0]&&(l.width=parseInt(u[0],10)),u[1]&&(l.height=parseInt(u[1],10)),n.attributes.RESOLUTION=l}n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))}this.trigger("data",n)}else{if(e=/^#EXT-X-MEDIA:?(.*)$/.exec(t))return n={type:"tag",tagType:"media"},e[1]&&(n.attributes=f(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-ENDLIST/.exec(t))this.trigger("data",{type:"tag",tagType:"endlist"});else if(e=/^#EXT-X-DISCONTINUITY/.exec(t))this.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(e=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(t))return n={type:"tag",tagType:"program-date-time"},e[1]&&(n.dateTimeString=e[1],n.dateTimeObject=new Date(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-KEY:?(.*)$/.exec(t))return n={type:"tag",tagType:"key"},e[1]&&(n.attributes=f(e[1]),n.attributes.IV&&("0x"===n.attributes.IV.substring(0,2).toLowerCase()&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),void this.trigger("data",n);if(e=/^#EXT-X-START:?(.*)$/.exec(t))return n={type:"tag",tagType:"start"},e[1]&&(n.attributes=f(e[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),void this.trigger("data",n);if(e=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-out-cont"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);if(e=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-out"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);if(e=/^#EXT-X-CUE-IN:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-in"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);this.trigger("data",{type:"tag",data:t.slice(4)})}}}else this.trigger("data",{type:"comment",text:t.slice(1)})}else this.trigger("data",{type:"uri",uri:t})},n.prototype.addParser=function(t){var e=this,n=t.expression,r=t.customType,i=t.dataParser,s=t.segment;"function"!=typeof i&&(i=function(t){return t}),this.customParsers.push(function(t){if(n.exec(t))return e.trigger("data",{type:"custom",data:i(t),customType:r,segment:s}),!0})},n}(s),a=function(e){function n(){r(this,n);var t=g(this,e.call(this));t.lineStream=new h,t.parseStream=new p,t.lineStream.pipe(t.parseStream);var i=t,s=[],a={},o=void 0,u=void 0,l={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f=0;return t.manifest={allowCache:!0,discontinuityStarts:[],segments:[]},t.parseStream.on("data",function(e){var n=void 0,r=void 0;({tag:function(){({"allow-cache":function(){this.manifest.allowCache=e.allowed,"allowed"in e||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function(){var t={};"length"in e&&((a.byterange=t).length=e.length,"offset"in e||(this.trigger("info",{message:"defaulting offset to zero"}),e.offset=0)),"offset"in e&&((a.byterange=t).offset=e.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"})),0<e.duration&&(a.duration=e.duration),0===e.duration&&(a.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=s},key:function(){e.attributes?"NONE"!==e.attributes.METHOD?e.attributes.URI?(e.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),u={method:e.attributes.METHOD||"AES-128",uri:e.attributes.URI},void 0!==e.attributes.IV&&(u.iv=e.attributes.IV)):this.trigger("warn",{message:"ignoring key declaration without URI"}):u=null:this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){isFinite(e.number)?this.manifest.mediaSequence=e.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+e.number})},"discontinuity-sequence":function(){isFinite(e.number)?(this.manifest.discontinuitySequence=e.number,f=e.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+e.number})},"playlist-type":function(){/VOD|EVENT/.test(e.playlistType)?this.manifest.playlistType=e.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+e.playlist})},map:function(){o={},e.uri&&(o.uri=e.uri),e.byterange&&(o.byterange=e.byterange)},"stream-inf":function(){this.manifest.playlists=s,this.manifest.mediaGroups=this.manifest.mediaGroups||l,e.attributes?(a.attributes||(a.attributes={}),c(a.attributes,e.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||l,e.attributes&&e.attributes.TYPE&&e.attributes["GROUP-ID"]&&e.attributes.NAME){var t=this.manifest.mediaGroups[e.attributes.TYPE];t[e.attributes["GROUP-ID"]]=t[e.attributes["GROUP-ID"]]||{},n=t[e.attributes["GROUP-ID"]],(r={default:/yes/i.test(e.attributes.DEFAULT)}).default?r.autoselect=!0:r.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(r.language=e.attributes.LANGUAGE),e.attributes.URI&&(r.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(r.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(r.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(r.forced=/yes/i.test(e.attributes.FORCED)),n[e.attributes.NAME]=r}else this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity:function(){f+=1,a.discontinuity=!0,this.manifest.discontinuityStarts.push(s.length)},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject),a.dateTimeString=e.dateTimeString,a.dateTimeObject=e.dateTimeObject},targetduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+e.duration}):this.manifest.targetDuration=e.duration},totalduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+e.duration}):this.manifest.totalDuration=e.duration},start:function(){e.attributes&&!isNaN(e.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:e.attributes["TIME-OFFSET"],precise:e.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out":function(){a.cueOut=e.data},"cue-out-cont":function(){a.cueOutCont=e.data},"cue-in":function(){a.cueIn=e.data}}[e.tagType]||function(){}).call(i)},uri:function(){a.uri=e.uri,s.push(a),!this.manifest.targetDuration||"duration"in a||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),a.duration=this.manifest.targetDuration),u&&(a.key=u),a.timeline=f,o&&(a.map=o),a={}},comment:function(){},custom:function(){e.segment?(a.custom=a.custom||{},a.custom[e.customType]=e.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[e.customType]=e.data)}})[e.type].call(i)}),t}return i(n,e),n.prototype.push=function(t){this.lineStream.push(t)},n.prototype.end=function(){this.lineStream.push("\n")},n.prototype.addParser=function(t){this.parseStream.addParser(t)},n}(s);n.LineStream=h,n.ParseStream=p,n.Parser=a},{}],"p2p-media-loader-hlsjs":[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("./engine");function i(t){t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&s(t,t.config.loader.getEngine())}function s(t,r){t.on("hlsFragChanged",function(t,e){var n=e&&e.frag?e.frag.url:void 0;r.setPlayingSegment(n)}),t.on("hlsDestroying",function(){r.destroy()})}n.Engine=r.Engine,n.initHlsJsPlayer=i,n.initClapprPlayer=function(e){e.on("play",function(){var t=e.core.getCurrentPlayback();t._hls&&!t._hls._p2pm_linitialized&&(t._hls._p2pm_linitialized=!0,i(e.core.getCurrentPlayback()._hls))})},n.initFlowplayerHlsJsPlayer=function(t){t.on("ready",function(){return i(t.engine.hlsjs)})},n.initVideoJsContribHlsJsPlayer=function(e){e.ready(function(){var t=e.tech_.options_;t&&t.hlsjsConfig&&t.hlsjsConfig.loader&&"function"==typeof t.hlsjsConfig.loader.getEngine&&s(e.tech_,t.hlsjsConfig.loader.getEngine())})},n.initMediaElementJsPlayer=function(r){r.addEventListener("hlsFragChanged",function(t){var e=t.data&&1<t.data.length&&t.data[1].frag?t.data[1].frag.url:void 0,n=r.hlsPlayer;n&&n.config&&n.config.loader&&"function"==typeof n.config.loader.getEngine&&n.config.loader.getEngine().setPlayingSegment(e)}),r.addEventListener("hlsDestroying",function(){var t=r.hlsPlayer;t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&t.config.loader.getEngine().destroy()})},n.initJwPlayer=function(t,e){var n=setInterval(function(){t.hls&&t.hls.config&&(clearInterval(n),t.hls.config=Object.assign(t.hls.config,e),i(t.hls))},200)},n.version="0.2.0"},{"./engine":2}]},{},[1]);
window.p2pml||(window.p2pml={}),window.p2pml.hlsjs=t("p2p-media-loader-hlsjs")},{"p2p-media-loader-hlsjs":"p2p-media-loader-hlsjs"}],2:[function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var s=t("events"),a=t("p2p-media-loader-core"),o=t("./segment-manager"),u=t("./hlsjs-loader"),l=t("./hlsjs-loader-class"),f=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.loader=new a.HybridLoader(t.loader),r.segmentManager=new o.SegmentManager(r.loader,t.segments),Object.keys(a.Events).map(function(t){return a.Events[t]}).forEach(function(n){return r.loader.on(n,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.emit.apply(r,[n].concat(t))})}),r}return i(t,e),t.isSupported=function(){return a.HybridLoader.isSupported()},t.prototype.createLoaderClass=function(){return l.createHlsJsLoaderClass(u.HlsJsLoader,this)},t.prototype.destroy=function(){this.loader.destroy(),this.segmentManager.destroy()},t.prototype.getSettings=function(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}},t.prototype.setPlayingSegment=function(t){this.segmentManager.setPlayingSegment(t)},t}(s.EventEmitter);n.Engine=f},{"./hlsjs-loader":4,"./hlsjs-loader-class":3,"./segment-manager":5,events:7,"p2p-media-loader-core":void 0}],3:[function(t,e,n){e.exports.createHlsJsLoaderClass=function(t,e){function n(){this.impl=new t(e.segmentManager),this.stats=this.impl.stats}return n.prototype.load=function(t,e,n){this.context=t,this.impl.load(t,e,n)},n.prototype.abort=function(){this.impl.abort(this.context)},n.prototype.destroy=function(){this.context&&this.impl.abort(this.context)},n.getEngine=function(){return e},n}},{}],4:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function t(t){this.stats={},this.segmentManager=t}return t.prototype.load=function(n,t,r){var i=this;n.type?this.segmentManager.loadPlaylist(n.url).then(function(t){return i.successPlaylist(t,n,r)}).catch(function(t){return i.error(t,n,r)}):n.frag?this.segmentManager.loadSegment(n.url,function(t,e){return setTimeout(function(){return i.successSegment(t,e,n,r)},0)},function(t){return setTimeout(function(){return i.error(t,n,r)},0)}):console.warn("Unknown load request",n)},t.prototype.abort=function(t){this.segmentManager.abortSegment(t.url)},t.prototype.successPlaylist=function(t,e,n){var r=performance.now();this.stats.trequest=r-300,this.stats.tfirst=r-200,this.stats.tload=r,this.stats.loaded=t.length,n.onSuccess({url:e.url,data:t},this.stats,e)},t.prototype.successSegment=function(t,e,n,r){var i=performance.now(),s=t.byteLength/(e<=0?12500:e);this.stats.trequest=i-1-s,this.stats.tfirst=i-s,this.stats.tload=i,this.stats.loaded=t.byteLength,r.onSuccess({url:n.url,data:t},this.stats,n)},t.prototype.error=function(t,e,n){n.onError(t,e)},t}();n.HlsJsLoader=r},{}],5:[function(t,e,n){"use strict";var r=this&&this.__awaiter||function(s,a,o,u){return new(o||(o=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new o(function(t){t(e.value)}).then(n,r)}i((u=u.apply(s,a||[])).next())})},i=this&&this.__generator||function(n,r){var i,s,a,t,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,s=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(a=0<(a=o.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){o.label=e[1];break}if(6===e[0]&&o.label<a[1]){o.label=a[1],a=e;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(e);break}a[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(n,o)}catch(t){e=[6,t],s=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};Object.defineProperty(n,"__esModule",{value:!0});var h=t("p2p-media-loader-core"),s=t("./utils"),a=t("m3u8-parser"),o={forwardSegmentCount:20,swarmId:void 0},u=function(){function t(t,e){void 0===e&&(e={});var n=this;this.masterPlaylist=null,this.variantPlaylists=new Map,this.segmentRequest=null,this.playQueue=[],this.onSegmentLoaded=function(t){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onSuccess(t.data.slice(0),t.downloadSpeed),n.segmentRequest=null)},this.onSegmentError=function(t,e){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onError(e),n.segmentRequest=null)},this.onSegmentAbort=function(t){n.segmentRequest&&n.segmentRequest.segmentUrl===t.url&&(n.segmentRequest.onError("Loading aborted: internal abort"),n.segmentRequest=null)},this.settings=Object.assign(o,e),this.loader=t,this.loader.on(h.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(h.Events.SegmentError,this.onSegmentError),this.loader.on(h.Events.SegmentAbort,this.onSegmentAbort)}return t.prototype.getSettings=function(){return this.settings},t.prototype.processPlaylist=function(t,e){var n=this,r=new a.Parser;r.push(e),r.end();var i=new l(t,r.manifest);if(i.manifest.playlists)this.masterPlaylist=i,this.variantPlaylists.forEach(function(t){return t.swarmId=n.getSwarmId(t.url)});else{var s=this.getSwarmId(t);s===t&&this.masterPlaylist||(i.swarmId=s,this.variantPlaylists.set(t,i),this.updateSegments())}},t.prototype.loadPlaylist=function(n){return r(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,s.default.fetchContentAsText(n)];case 1:return e=t.sent(),this.processPlaylist(n,e),[2,e]}})})},t.prototype.loadSegment=function(t,e,n){var r=this.getSegmentLocation(t);if(r){var i=(r.playlist.manifest.mediaSequence?r.playlist.manifest.mediaSequence:0)+r.segmentIndex;if(0<this.playQueue.length)this.playQueue[this.playQueue.length-1].segmentSequence!==i-1&&(this.playQueue=[]);this.segmentRequest&&this.segmentRequest.onError("Cancel segment request: simultaneous segment requests are not supported"),this.segmentRequest=new f(t,i,r.playlist.url,e,n),this.playQueue.push({segmentUrl:t,segmentSequence:i}),this.loadSegments(r.playlist,r.segmentIndex,!0)}else s.default.fetchContentAsArrayBuffer(t).then(function(t){return e(t,0)}).catch(function(t){return n(t)})},t.prototype.setPlayingSegment=function(e){var t=this.playQueue.findIndex(function(t){return t.segmentUrl==e});0<=t&&(this.playQueue=this.playQueue.slice(t),this.updateSegments())},t.prototype.abortSegment=function(t){this.segmentRequest&&this.segmentRequest.segmentUrl===t&&(this.segmentRequest=null)},t.prototype.destroy=function(){this.loader.destroy(),this.segmentRequest&&(this.segmentRequest.onError("Loading aborted: object destroyed"),this.segmentRequest=null),this.masterPlaylist=null,this.variantPlaylists.clear(),this.playQueue=[]},t.prototype.updateSegments=function(){if(this.segmentRequest){var t=this.getSegmentLocation(this.segmentRequest.segmentUrl);if(t)this.loadSegments(t.playlist,t.segmentIndex,!1);else{var e=this.variantPlaylists.get(this.segmentRequest.playlistUrl);e&&this.loadSegments(e,0,!1,{url:this.segmentRequest.segmentUrl,sequence:this.segmentRequest.segmentSequence})}}},t.prototype.getSegmentLocation=function(t){for(var e=this.variantPlaylists.values(),n=e.next();!n.done;n=e.next()){var r=n.value,i=r.getSegmentIndex(t);if(0<=i)return{playlist:r,segmentIndex:i}}},t.prototype.loadSegments=function(t,e,n,r){var i=[],s=t.manifest.segments,a=t.manifest.mediaSequence?t.manifest.mediaSequence:0,o=null,u=Math.max(0,this.playQueue.length-1);if(r){var l=t.getSegmentAbsoluteUrl(r.url),f=this.getSegmentId(t,r.sequence);i.push(new h.Segment(f,l,void 0,u++)),n&&(o=f)}for(var c=e;c<s.length&&i.length<this.settings.forwardSegmentCount;++c){l=t.getSegmentAbsoluteUrlByIndex(c),f=this.getSegmentId(t,a+c);i.push(new h.Segment(f,l,void 0,u++)),n&&!o&&(o=f)}if(this.loader.load(i,t.swarmId),o){var g=this.loader.getSegment(o);g&&this.onSegmentLoaded(g)}},t.prototype.getSegmentId=function(t,e){return t.swarmId+"+"+e},t.prototype.getSwarmId=function(t){if(this.masterPlaylist)for(var e=this.settings.swarmId&&0!==this.settings.swarmId.length?this.settings.swarmId:this.masterPlaylist.url.split("?")[0],n=0;n<this.masterPlaylist.manifest.playlists.length;++n){var r=this.masterPlaylist.manifest.playlists[n].uri;if((r=s.default.isAbsoluteUrl(r)?r:this.masterPlaylist.baseUrl+r)===t)return e+"+V"+n}return t},t}();n.SegmentManager=u;var l=function(){function t(t,e){this.url=t,this.manifest=e,this.swarmId="";var n=t.lastIndexOf("/");if(-1===n)throw new Error("Unexpected playlist URL format");this.baseUrl=t.substring(0,n+1)}return t.prototype.getSegmentIndex=function(t){for(var e=0;e<this.manifest.segments.length;++e)if(t===this.getSegmentAbsoluteUrlByIndex(e))return e;return-1},t.prototype.getSegmentAbsoluteUrlByIndex=function(t){return this.getSegmentAbsoluteUrl(this.manifest.segments[t].uri)},t.prototype.getSegmentAbsoluteUrl=function(t){return s.default.isAbsoluteUrl(t)?t:this.baseUrl+t},t}(),f=function(t,e,n,r,i){this.segmentUrl=t,this.segmentSequence=e,this.playlistUrl=n,this.onSuccess=r,this.onError=i}},{"./utils":6,"m3u8-parser":8,"p2p-media-loader-core":void 0}],6:[function(t,e,n){"use strict";var s=this&&this.__awaiter||function(s,a,o,u){return new(o||(o=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new o(function(t){t(e.value)}).then(n,r)}i((u=u.apply(s,a||[])).next())})},a=this&&this.__generator||function(n,r){var i,s,a,t,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,s=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(a=0<(a=o.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){o.label=e[1];break}if(6===e[0]&&o.label<a[1]){o.label=a[1],a=e;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(e);break}a[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(n,o)}catch(t){e=[6,t],s=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function n(){}return n.fetchContentAsAny=function(r,i){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,new Promise(function(t,e){var n=new XMLHttpRequest;n.open("GET",r,!0),n.responseType=i,n.onreadystatechange=function(){4===n.readyState&&(200<=n.status&&n.status<300?t(n.response):e(n.statusText))},n.send()})]})})},n.fetchContentAsText=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,n.fetchContentAsAny(e,"text")]})})},n.fetchContentAsArrayBuffer=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,n.fetchContentAsAny(e,"arraybuffer")]})})},n.isAbsoluteUrl=function(t){return t.startsWith("http://")||t.startsWith("https://")},n}();n.default=r},{}],7:[function(t,e,n){var u=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},s=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=u(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((e.exports=r).EventEmitter=r).prototype._events=void 0,r.prototype._maxListeners=void 0;var i,o=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),i=0===l.x}catch(t){i=!1}function f(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function c(t,e,n,r){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]):(s=t._events=u(null),t._eventsCount=0),a){if("function"==typeof a?a=s[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),!a.warned&&(i=f(t))&&0<i&&a.length>i){a.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",o.name,o.message)}}else a=s[e]=n,++t._eventsCount;return t}function g(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function h(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=s.call(g,r);return i.listener=n,r.wrapFn=i}function p(t,e,n){var r=t._events;if(!r)return[];var i=r[e];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):m(i,i.length):[]}function d(t){var e=this._events;if(e){var n=e[t];if("function"==typeof n)return 1;if(n)return n.length}return 0}function m(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}i?Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');o=t}}):r.defaultMaxListeners=o,r.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},r.prototype.getMaxListeners=function(){return f(this)},r.prototype.emit=function(t){var e,n,r,i,s,a,o="error"===t;if(a=this._events)o=o&&null==a.error;else if(!o)return!1;if(o){if(1<arguments.length&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(n=a[t]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=m(t,r),s=0;s<r;++s)i[s].call(n)}(n,l,this);break;case 2:!function(t,e,n,r){if(e)t.call(n,r);else for(var i=t.length,s=m(t,i),a=0;a<i;++a)s[a].call(n,r)}(n,l,this,arguments[1]);break;case 3:!function(t,e,n,r,i){if(e)t.call(n,r,i);else for(var s=t.length,a=m(t,s),o=0;o<s;++o)a[o].call(n,r,i)}(n,l,this,arguments[1],arguments[2]);break;case 4:!function(t,e,n,r,i,s){if(e)t.call(n,r,i,s);else for(var a=t.length,o=m(t,a),u=0;u<a;++u)o[u].call(n,r,i,s)}(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(t,e,n,r){if(e)t.apply(n,r);else for(var i=t.length,s=m(t,i),a=0;a<i;++a)s[a].apply(n,r)}(n,l,this,i)}return!0},r.prototype.on=r.prototype.addListener=function(t,e){return c(this,t,e,!1)},r.prototype.prependListener=function(t,e){return c(this,t,e,!0)},r.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,h(this,t,e)),this},r.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,h(this,t,e)),this},r.prototype.removeListener=function(t,e){var n,r,i,s,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=u(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,s=n.length-1;0<=s;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r<i;n+=1,r+=1)t[n]=t[r];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),r.removeListener&&this.emit("removeListener",t,a||e)}return this},r.prototype.removeAllListeners=function(t){var e,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=u(null),this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=u(null):delete n[t]),this;if(0===arguments.length){var i,s=a(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=u(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(e)for(r=e.length-1;0<=r;r--)this.removeListener(t,e[r]);return this},r.prototype.listeners=function(t){return p(this,t,!0)},r.prototype.rawListeners=function(t){return p(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],8:[function(t,e,n){"use strict";var r=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},g=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},s=function(){function t(){r(this,t),this.listeners={}}return t.prototype.on=function(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)},t.prototype.off=function(t,e){if(!this.listeners[t])return!1;var n=this.listeners[t].indexOf(e);return this.listeners[t].splice(n,1),-1<n},t.prototype.trigger=function(t){var e=this.listeners[t],n=void 0,r=void 0,i=void 0;if(e)if(2===arguments.length)for(r=e.length,n=0;n<r;++n)e[n].call(this,arguments[1]);else for(i=Array.prototype.slice.call(arguments,1),r=e.length,n=0;n<r;++n)e[n].apply(this,i)},t.prototype.dispose=function(){this.listeners={}},t.prototype.pipe=function(e){this.on("data",function(t){e.push(t)})},t}(),h=function(e){function n(){r(this,n);var t=g(this,e.call(this));return t.buffer="",t}return i(n,e),n.prototype.push=function(t){var e=void 0;for(this.buffer+=t,e=this.buffer.indexOf("\n");-1<e;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)},n}(s),f=function(t){for(var e=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},r=e.length,i=void 0;r--;)""!==e[r]&&((i=/([^=]*)=(.*)/.exec(e[r]).slice(1))[0]=i[0].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^\s+|\s+$/g,""),i[1]=i[1].replace(/^['"](.*)['"]$/g,"$1"),n[i[0]]=i[1]);return n},p=function(e){function n(){r(this,n);var t=g(this,e.call(this));return t.customParsers=[],t}return i(n,e),n.prototype.push=function(t){var e=void 0,n=void 0;if(0!==(t=t.replace(/^[\u0000\s]+|[\u0000\s]+$/g,"")).length)if("#"===t[0]){for(var r=0;r<this.customParsers.length;r++)if(this.customParsers[r].call(this,t))return;if(0===t.indexOf("#EXT"))if(t=t.replace("\r",""),e=/^#EXTM3U/.exec(t))this.trigger("data",{type:"tag",tagType:"m3u"});else{if(e=/^#EXTINF:?([0-9\.]*)?,?(.*)?$/.exec(t))return n={type:"tag",tagType:"inf"},e[1]&&(n.duration=parseFloat(e[1])),e[2]&&(n.title=e[2]),void this.trigger("data",n);if(e=/^#EXT-X-TARGETDURATION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"targetduration"},e[1]&&(n.duration=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#ZEN-TOTAL-DURATION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"totalduration"},e[1]&&(n.duration=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-VERSION:?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"version"},e[1]&&(n.version=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-MEDIA-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return n={type:"tag",tagType:"media-sequence"},e[1]&&(n.number=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-DISCONTINUITY-SEQUENCE:?(\-?[0-9.]*)?/.exec(t))return n={type:"tag",tagType:"discontinuity-sequence"},e[1]&&(n.number=parseInt(e[1],10)),void this.trigger("data",n);if(e=/^#EXT-X-PLAYLIST-TYPE:?(.*)?$/.exec(t))return n={type:"tag",tagType:"playlist-type"},e[1]&&(n.playlistType=e[1]),void this.trigger("data",n);if(e=/^#EXT-X-BYTERANGE:?([0-9.]*)?@?([0-9.]*)?/.exec(t))return n={type:"tag",tagType:"byterange"},e[1]&&(n.length=parseInt(e[1],10)),e[2]&&(n.offset=parseInt(e[2],10)),void this.trigger("data",n);if(e=/^#EXT-X-ALLOW-CACHE:?(YES|NO)?/.exec(t))return n={type:"tag",tagType:"allow-cache"},e[1]&&(n.allowed=!/NO/.test(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-MAP:?(.*)$/.exec(t)){if(n={type:"tag",tagType:"map"},e[1]){var i=f(e[1]);if(i.URI&&(n.uri=i.URI),i.BYTERANGE){var s=i.BYTERANGE.split("@"),a=s[0],o=s[1];n.byterange={},a&&(n.byterange.length=parseInt(a,10)),o&&(n.byterange.offset=parseInt(o,10))}}this.trigger("data",n)}else if(e=/^#EXT-X-STREAM-INF:?(.*)$/.exec(t)){if(n={type:"tag",tagType:"stream-inf"},e[1]){if(n.attributes=f(e[1]),n.attributes.RESOLUTION){var u=n.attributes.RESOLUTION.split("x"),l={};u[0]&&(l.width=parseInt(u[0],10)),u[1]&&(l.height=parseInt(u[1],10)),n.attributes.RESOLUTION=l}n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))}this.trigger("data",n)}else{if(e=/^#EXT-X-MEDIA:?(.*)$/.exec(t))return n={type:"tag",tagType:"media"},e[1]&&(n.attributes=f(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-ENDLIST/.exec(t))this.trigger("data",{type:"tag",tagType:"endlist"});else if(e=/^#EXT-X-DISCONTINUITY/.exec(t))this.trigger("data",{type:"tag",tagType:"discontinuity"});else{if(e=/^#EXT-X-PROGRAM-DATE-TIME:?(.*)$/.exec(t))return n={type:"tag",tagType:"program-date-time"},e[1]&&(n.dateTimeString=e[1],n.dateTimeObject=new Date(e[1])),void this.trigger("data",n);if(e=/^#EXT-X-KEY:?(.*)$/.exec(t))return n={type:"tag",tagType:"key"},e[1]&&(n.attributes=f(e[1]),n.attributes.IV&&("0x"===n.attributes.IV.substring(0,2).toLowerCase()&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),void this.trigger("data",n);if(e=/^#EXT-X-START:?(.*)$/.exec(t))return n={type:"tag",tagType:"start"},e[1]&&(n.attributes=f(e[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),void this.trigger("data",n);if(e=/^#EXT-X-CUE-OUT-CONT:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-out-cont"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);if(e=/^#EXT-X-CUE-OUT:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-out"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);if(e=/^#EXT-X-CUE-IN:?(.*)?$/.exec(t))return n={type:"tag",tagType:"cue-in"},e[1]?n.data=e[1]:n.data="",void this.trigger("data",n);this.trigger("data",{type:"tag",data:t.slice(4)})}}}else this.trigger("data",{type:"comment",text:t.slice(1)})}else this.trigger("data",{type:"uri",uri:t})},n.prototype.addParser=function(t){var e=this,n=t.expression,r=t.customType,i=t.dataParser,s=t.segment;"function"!=typeof i&&(i=function(t){return t}),this.customParsers.push(function(t){if(n.exec(t))return e.trigger("data",{type:"custom",data:i(t),customType:r,segment:s}),!0})},n}(s),a=function(e){function n(){r(this,n);var t=g(this,e.call(this));t.lineStream=new h,t.parseStream=new p,t.lineStream.pipe(t.parseStream);var i=t,s=[],a={},o=void 0,u=void 0,l={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},f=0;return t.manifest={allowCache:!0,discontinuityStarts:[],segments:[]},t.parseStream.on("data",function(e){var n=void 0,r=void 0;({tag:function(){({"allow-cache":function(){this.manifest.allowCache=e.allowed,"allowed"in e||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange:function(){var t={};"length"in e&&((a.byterange=t).length=e.length,"offset"in e||(this.trigger("info",{message:"defaulting offset to zero"}),e.offset=0)),"offset"in e&&((a.byterange=t).offset=e.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"})),0<e.duration&&(a.duration=e.duration),0===e.duration&&(a.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=s},key:function(){e.attributes?"NONE"!==e.attributes.METHOD?e.attributes.URI?(e.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),u={method:e.attributes.METHOD||"AES-128",uri:e.attributes.URI},void 0!==e.attributes.IV&&(u.iv=e.attributes.IV)):this.trigger("warn",{message:"ignoring key declaration without URI"}):u=null:this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){isFinite(e.number)?this.manifest.mediaSequence=e.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+e.number})},"discontinuity-sequence":function(){isFinite(e.number)?(this.manifest.discontinuitySequence=e.number,f=e.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+e.number})},"playlist-type":function(){/VOD|EVENT/.test(e.playlistType)?this.manifest.playlistType=e.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+e.playlist})},map:function(){o={},e.uri&&(o.uri=e.uri),e.byterange&&(o.byterange=e.byterange)},"stream-inf":function(){this.manifest.playlists=s,this.manifest.mediaGroups=this.manifest.mediaGroups||l,e.attributes?(a.attributes||(a.attributes={}),c(a.attributes,e.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||l,e.attributes&&e.attributes.TYPE&&e.attributes["GROUP-ID"]&&e.attributes.NAME){var t=this.manifest.mediaGroups[e.attributes.TYPE];t[e.attributes["GROUP-ID"]]=t[e.attributes["GROUP-ID"]]||{},n=t[e.attributes["GROUP-ID"]],(r={default:/yes/i.test(e.attributes.DEFAULT)}).default?r.autoselect=!0:r.autoselect=/yes/i.test(e.attributes.AUTOSELECT),e.attributes.LANGUAGE&&(r.language=e.attributes.LANGUAGE),e.attributes.URI&&(r.uri=e.attributes.URI),e.attributes["INSTREAM-ID"]&&(r.instreamId=e.attributes["INSTREAM-ID"]),e.attributes.CHARACTERISTICS&&(r.characteristics=e.attributes.CHARACTERISTICS),e.attributes.FORCED&&(r.forced=/yes/i.test(e.attributes.FORCED)),n[e.attributes.NAME]=r}else this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity:function(){f+=1,a.discontinuity=!0,this.manifest.discontinuityStarts.push(s.length)},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=e.dateTimeString,this.manifest.dateTimeObject=e.dateTimeObject),a.dateTimeString=e.dateTimeString,a.dateTimeObject=e.dateTimeObject},targetduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+e.duration}):this.manifest.targetDuration=e.duration},totalduration:function(){!isFinite(e.duration)||e.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+e.duration}):this.manifest.totalDuration=e.duration},start:function(){e.attributes&&!isNaN(e.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:e.attributes["TIME-OFFSET"],precise:e.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out":function(){a.cueOut=e.data},"cue-out-cont":function(){a.cueOutCont=e.data},"cue-in":function(){a.cueIn=e.data}}[e.tagType]||function(){}).call(i)},uri:function(){a.uri=e.uri,s.push(a),!this.manifest.targetDuration||"duration"in a||(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),a.duration=this.manifest.targetDuration),u&&(a.key=u),a.timeline=f,o&&(a.map=o),a={}},comment:function(){},custom:function(){e.segment?(a.custom=a.custom||{},a.custom[e.customType]=e.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[e.customType]=e.data)}})[e.type].call(i)}),t}return i(n,e),n.prototype.push=function(t){this.lineStream.push(t)},n.prototype.end=function(){this.lineStream.push("\n")},n.prototype.addParser=function(t){this.parseStream.addParser(t)},n}(s);n.LineStream=h,n.ParseStream=p,n.Parser=a},{}],"p2p-media-loader-hlsjs":[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t("./engine");function i(t){t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&s(t,t.config.loader.getEngine())}function s(t,r){t.on("hlsFragChanged",function(t,e){var n=e&&e.frag?e.frag.url:void 0;r.setPlayingSegment(n)}),t.on("hlsDestroying",function(){r.destroy()})}n.Engine=r.Engine,n.initHlsJsPlayer=i,n.initClapprPlayer=function(e){e.on("play",function(){var t=e.core.getCurrentPlayback();t._hls&&!t._hls._p2pm_linitialized&&(t._hls._p2pm_linitialized=!0,i(e.core.getCurrentPlayback()._hls))})},n.initFlowplayerHlsJsPlayer=function(t){t.on("ready",function(){return i(t.engine.hlsjs?t.engine.hlsjs:t.engine.hls)})},n.initVideoJsContribHlsJsPlayer=function(e){e.ready(function(){var t=e.tech_.options_;t&&t.hlsjsConfig&&t.hlsjsConfig.loader&&"function"==typeof t.hlsjsConfig.loader.getEngine&&s(e.tech_,t.hlsjsConfig.loader.getEngine())})},n.initMediaElementJsPlayer=function(r){r.addEventListener("hlsFragChanged",function(t){var e=t.data&&1<t.data.length&&t.data[1].frag?t.data[1].frag.url:void 0,n=r.hlsPlayer;n&&n.config&&n.config.loader&&"function"==typeof n.config.loader.getEngine&&n.config.loader.getEngine().setPlayingSegment(e)}),r.addEventListener("hlsDestroying",function(){var t=r.hlsPlayer;t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&t.config.loader.getEngine().destroy()})},n.initJwPlayer=function(t,e){var n=setInterval(function(){t.hls&&t.hls.config&&(clearInterval(n),t.hls.config=Object.assign(t.hls.config,e),i(t.hls))},200)},n.version="undefined"==typeof __P2PML_VERSION__?"0.2.1":__P2PML_VERSION__},{"./engine":2}]},{},[1]);

@@ -24,2 +24,2 @@ /**

export { Engine };
export declare const version = "__VERSION__";
export declare const version: string;

@@ -37,3 +37,3 @@ "use strict";

function initFlowplayerHlsJsPlayer(player) {
player.on("ready", function () { return initHlsJsPlayer(player.engine.hlsjs); });
player.on("ready", function () { return initHlsJsPlayer(player.engine.hlsjs ? player.engine.hlsjs : player.engine.hls); });
}

@@ -78,3 +78,3 @@ exports.initFlowplayerHlsJsPlayer = initFlowplayerHlsJsPlayer;

exports.initJwPlayer = initJwPlayer;
exports.version = "__VERSION__";
exports.version = typeof (__P2PML_VERSION__) === "undefined" ? "__VERSION__" : __P2PML_VERSION__;
function initHlsJsEvents(player, engine) {

@@ -81,0 +81,0 @@ player.on("hlsFragChanged", function (event_unused, data) {

{
"name": "p2p-media-loader-hlsjs",
"description": "P2P Media Loader hls.js integration",
"version": "0.2.0",
"version": "0.2.1",
"license": "Apache-2.0",

@@ -40,3 +40,3 @@ "author": "Novage",

"m3u8-parser": "^4.2.0",
"p2p-media-loader-core": "^0.2.0"
"p2p-media-loader-core": "^0.2.1"
},

@@ -43,0 +43,0 @@ "devDependencies": {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc