hjplayer
Version:
hjplayer, a HTML5 Player, can play flv and hls by Media Source Extension, based on typescript;
1 lines • 237 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("HJPlayer",[],t):"object"==typeof exports?exports.HJPlayer=t():e.HJPlayer=t()}(this,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=31)}([function(e,t,i){"use strict";var n=i(4),r=i.n(n),a=i(1),s=new r.a,o=function(){function e(){}return Object.defineProperty(e,"GLOBAL_TAG",{get:function(){return e._tag},set:function(t){e._tag=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"config",{get:function(){return e._config||(e._config=Object.create(null)),e._config},set:function(t){e._config=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"emitter",{get:function(){return s},enumerable:!0,configurable:!0}),e.on=function(t,i){e.emitter.on(t,i)},e.once=function(t,i){e.emitter.once(t,i)},e.off=function(t,i){e.emitter.off(t,i)},e.clearEvents=function(){e.emitter.removeAllListeners()},e.error=function(t,i){t&&!e.config.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.config.ENABLE_CALLBACK&&e.emitter.emit(a.a.HJ_PLAYER_LOG,"error",n),e.config.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))},e.info=function(t,i){t&&!e.config.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.config.ENABLE_CALLBACK&&e.emitter.emit(a.a.HJ_PLAYER_LOG,"info",n),e.config.ENABLE_INFO&&(console.info?console.info(n):console.log(n))},e.log=function(t,i){t&&!e.config.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.config.ENABLE_CALLBACK&&e.emitter.emit(a.a.HJ_PLAYER_LOG,"log",n),e.config.ENABLE_INFO&&console.log(n)},e.warn=function(t,i){t&&!e.config.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.config.ENABLE_CALLBACK&&e.emitter.emit(a.a.HJ_PLAYER_LOG,"warn",n),e.config.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))},e.debug=function(t,i){t&&!e.config.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.config.ENABLE_CALLBACK&&e.emitter.emit(a.a.HJ_PLAYER_LOG,"debug",n),e.config.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))},e}();t.a=o},function(e,t,i){"use strict";t.a={INIT_SEGMENT:"INIT_SEGMENT",MEDIA_SEGMENT:"MEDIA_SEGMENT",GET_SEI_INFO:"GET_SEI_INFO",MEDIA_INFO:"MEDIA_INFO",LOAD_COMPLETE:"LOAD_COMPLETE",DATA_ARRIVED:"DATA_ARRIVED",STATISTICS_INFO:"STATISTICS_INFO",HJ_PLAYER_LOG:"HJ_PLAYER_LOG",FRAG_PARSED:"FRAG_PARSED",FRAG_PARSING_METADATA:"FRAG_PARSING_METADATA",FRAG_PARSING_USERDATA:"FRAG_PARSING_USERDATA",INIT_PTS_FOUND:"INIT_PTS_FOUND",FRAG_PARSING_INIT_SEGMENT:"FRAG_PARSING_INIT_SEGMENT",MEDIA_SEEK:"MEDIA_SEEK",RECOVERED_EARLY_EOF:"RECOVERED_EARLY_EOF",RECOMMEND_SEEKPOINT:"RECOMMEND_SEEKPOINT",METADATA_ARRIVED:"METADATA_ARRIVED",SCRIPTDATA_ARRIVED:"SCRIPTDATA_ARRIVED",UPDATE_END:"UPDATE_END",BUFFER_FULL:"BUFFER_FULL",SOURCE_OPEN:"SOURCE_OPEN",ERROR:"ERROR",MANIFEST_PARSED:"MANIFEST_PARSED",IO_ERROR:"IO_ERROR",DEMUX_ERROR:"DEMUX_ERROR",WORKER_LOG:"WORKER_LOG",LOAD_NEXT_FRAG:"LOAD_NEXT_FRAG"}},function(e,t,i){"use strict";var n;!function(e){e[e.kIdle=0]="kIdle",e[e.kConnecting=1]="kConnecting",e[e.kBuffering=2]="kBuffering",e[e.kError=3]="kError",e[e.kComplete=4]="kComplete"}(n||(n={})),t.a=n},function(e,t,i){"use strict";i.d(t,"d",(function(){return a})),i.d(t,"a",(function(){return s})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return u}));var n,r=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),a=function(){function e(e){this._message=e}return Object.defineProperty(e.prototype,"name",{get:function(){return"RuntimeException"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),s=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"IllegalStateException"},enumerable:!0,configurable:!0}),t}(a),o=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"InvalidArgumentException"},enumerable:!0,configurable:!0}),t}(a),u=function(e){function t(t){return e.call(this,t)||this}return r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"NotImplementedException"},enumerable:!0,configurable:!0}),t}(a)},function(e,t,i){"use strict";var n=Object.prototype.hasOwnProperty,r="~";function a(){}function s(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function o(e,t,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new s(i,n||e,a),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function h(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(r=!1)),h.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)n.call(e,t)&&i.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},h.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},h.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},h.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,h,d=this._events[o],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,a),!0;case 6:return d.fn.call(d.context,t,i,n,a,s),!0}for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];d.fn.apply(d.context,u)}else{var c,f=d.length;for(h=0;h<f;h++)switch(d[h].once&&this.removeListener(e,d[h].fn,void 0,!0),l){case 1:d[h].fn.call(d[h].context);break;case 2:d[h].fn.call(d[h].context,t);break;case 3:d[h].fn.call(d[h].context,t,i);break;case 4:d[h].fn.call(d[h].context,t,i,n);break;default:if(!u)for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];d[h].fn.apply(d[h].context,u)}}return!0},h.prototype.on=function(e,t,i){return o(this,e,t,i,!1)},h.prototype.once=function(e,t,i){return o(this,e,t,i,!0)},h.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return u(this,a),this;var s=this._events[a];if(s.fn)s.fn!==t||n&&!s.once||i&&s.context!==i||u(this,a);else{for(var o=0,h=[],d=s.length;o<d;o++)(s[o].fn!==t||n&&!s[o].once||i&&s[o].context!==i)&&h.push(s[o]);h.length?this._events[a]=1===h.length?h[0]:h:u(this,a)}return this},h.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&u(this,t)):(this._events=new a,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=r,h.EventEmitter=h,e.exports=h},function(e,t,i){"use strict";function n(){return"undefined"==typeof window?self:window}i.d(t,"a",(function(){return n}))},function(e,t,i){"use strict";var n;!function(e){e.OK="OK",e.EXCEPTION="EXCEPTION",e.HTTP_STATUS_CODE_INVALID="HTTP_STATUS_CODE_INVALID",e.CONNECTING_TIMEOUT="CONNECTING_TIMEOUT",e.EARLY_EOF="EARLY_EOF",e.UNRECOVERABLE_EARLY_EOF="UNRECOVERABLE_EARLY_EOF",e.PARSE_PLAYLISTING_ERROR="PARSE_PLAYLISTING_ERROR"}(n||(n={})),t.a=n},function(e,t,i){"use strict";var n=i(5),r=Object(n.a)();var a=function(){var e=r.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[/]([\w.]+)/.exec(e)||/(chrome)[/]([\w.]+)/.exec(e)||/(iemobile)[/]([\w.]+)/.exec(e)||/(version)(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(e)||/(webkit)[/]([\w.]+).*(version)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(e)||/(webkit)[/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],n={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},a=Object.create(null);if(n.browser){a[n.browser]=!0;var s=n.majorVersion.split(".");a.version={major:parseInt(n.majorVersion,10),string:n.version},s.length>1&&(a.version.minor=parseInt(s[1],10)),s.length>2&&(a.version.build=parseInt(s[2],10))}if(n.platform&&(a[n.platform]=!0),(a.chrome||a.opr||a.safari)&&(a.webkit=!0),a.rv||a.iemobile){a.rv&&delete a.rv;n.browser="msie",a.msie=!0}if(a.edge){delete a.edge;n.browser="msedge",a.msedge=!0}if(a.opr){n.browser="opera",a.opera=!0}if(a.safari&&a.android){n.browser="android",a.android=!0}return a.name=n.browser,a.platform=n.platform,a}();t.a=a},function(e,t,i){"use strict";t.a={INIT:"INIT",START:"START",STOP:"STOP",SEEK:"SEEK",PAUSE:"PAUSE",RESUME:"RESUME",DESTROY:"DESTROY",LOG_CONFIG_CHANGE:"LOG_CONFIG_CHANGE"}},function(e,t,i){"use strict";t.a={UN_SUPPORT_MEDIA:"UN_SUPPORT_MEDIA",NETWORK_ERROR:"NETWORK_ERROR",TRANSMUXING_ERROR:"TRANSMUXING_ERROR",IO_ERROR:"IO_ERROR",OK:"OK",EXCEPTION:"EXCEPTION",HTTP_STATUS_CODE_INVALID:"HTTP_STATUS_CODE_INVALID",CONNECTING_TIMEOUT:"CONNECTING_TIMEOUT",EARLY_EOF:"EARLY_EOF",UNRECOVERABLE_EARLY_EOF:"UNRECOVERABLE_EARLY_EOF",MEDIA_ERROR:"MEDIA_ERROR",MEDIA_MSE_ERROR:"MEDIA_MSE_ERROR",FORMAT_ERROR:"FORMAT_ERROR",FORMAT_UNSUPPORTED:"FORMAT_UNSUPPORTED",CODEC_UNSUPPORTED:"CODEC_UNSUPPORTED"}},function(e,t,i){"use strict";var n;!function(e){e.LOADING_ERROR="LOADING_ERROR",e.LOAD_COMPLETE="LOAD_COMPLETE",e.MANIFEST_PARSED="MANIFEST_PARSED",e.DEMUXER_PUSH="DEMUXER_PUSH",e.PARSE_SUCCESS="PARSE_SUCCESS",e.PARSE_ERROR="PARSE_ERROR",e.GET_TS_URL="GET_TS_URL",e.LOADIND_TIMEOUT="LOADIND_TIMEOUT"}(n||(n={})),t.a=n},function(e,t,i){"use strict";var n=i(4),r=i.n(n),a=i(3),s=i(2),o=function(){function e(e,t){this.Tag="BaseLoader",this.supportType=t,this._type=e||"undefined",this._status=s.a.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null,this.eventEmitter=new r.a}return e.prototype.on=function(e,t){this.eventEmitter.on(e,t)},e.prototype.once=function(e,t){this.eventEmitter.once(e,t)},e.prototype.off=function(e,t){this.eventEmitter.off(e,t)},e.prototype.destroy=function(){this.eventEmitter.removeAllListeners(),delete this.eventEmitter,this._status=s.a.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===s.a.kConnecting||this._status===s.a.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!0,configurable:!0}),e.prototype.startLoad=function(e,t){throw new a.c("Unimplemented abstract function!")},e.prototype.abort=function(){throw new a.c("Unimplemented abstract function!")},e}();t.a=o},function(e,t,i){"use strict";var n=function(e,t,i,n,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=n,this.isSyncPoint=r,this.fileposition=null};t.a=n},function(e,t,i){"use strict";var n=i(4),r=i.n(n),a=i(0),s=i(1),o=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return a.a.config.FORCE_GLOBAL_TAG||!1},set:function(t){a.a.config.FORCE_GLOBAL_TAG=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return a.a.GLOBAL_TAG},set:function(t){a.a.GLOBAL_TAG=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return a.a.config.ENABLE_DEBUG&&a.a.config.ENABLE_INFO&&a.a.config.ENABLE_WARN&&a.a.config.ENABLE_ERROR},set:function(t){a.a.config.ENABLE_DEBUG=t,a.a.config.ENABLE_INFO=t,a.a.config.ENABLE_WARN=t,a.a.config.ENABLE_ERROR=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return a.a.config.ENABLE_DEBUG},set:function(t){a.a.config.ENABLE_DEBUG=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return a.a.config.ENABLE_INFO},set:function(t){a.a.config.ENABLE_INFO=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return a.a.config.ENABLE_WARN},set:function(t){a.a.config.ENABLE_WARN=t,e._notifyChange()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return a.a.config.ENABLE_ERROR},set:function(t){a.a.config.ENABLE_ERROR=t,e._notifyChange()},enumerable:!0,configurable:!0}),e.getConfig=function(){return{globalTag:a.a.GLOBAL_TAG,forceGlobalTag:a.a.config.FORCE_GLOBAL_TAG,enableDebug:a.a.config.ENABLE_DEBUG,enableInfo:a.a.config.ENABLE_INFO,enableWarn:a.a.config.ENABLE_WARN,enableError:a.a.config.ENABLE_ERROR,enableCallback:a.a.config.ENABLE_CALLBACK}},e.applyConfig=function(e){a.a.GLOBAL_TAG=e.GLOBAL_TAG||"HJPLAYER",a.a.config.FORCE_GLOBAL_TAG=e.FORCE_GLOBAL_TAG,a.a.config.ENABLE_DEBUG=e.ENABLE_DEBUG,a.a.config.ENABLE_INFO=e.ENABLE_INFO,a.a.config.ENABLE_WARN=e.ENABLE_WARN,a.a.config.ENABLE_ERROR=e.ENABLE_ERROR,a.a.config.ENABLE_CALLBACK=e.ENABLE_CALLBACK},e._notifyChange=function(){var t=e.emitter;if(t.listenerCount("change")>0){var i=e.getConfig();t.emit("change",i)}},e.registerListener=function(t){e.emitter.addListener("change",t)},e.removeListener=function(t){e.emitter.removeListener("change",t)},e.addLogListener=function(t){a.a.emitter.addListener(s.a.HJ_PLAYER_LOG,t),a.a.emitter.listenerCount(s.a.HJ_PLAYER_LOG)>0&&(a.a.config.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(t){a.a.emitter.removeListener(s.a.HJ_PLAYER_LOG,t),0===a.a.emitter.listenerCount(s.a.HJ_PLAYER_LOG)&&(a.a.config.ENABLE_CALLBACK=!1,e._notifyChange())},e}();o.emitter=new r.a,t.a=o},function(e,t,i){"use strict";var n=i(4),r=i.n(n),a=i(7),s=i(19),o=i(9),u=i(24),h=i(1),d=function(){return{forceKeyFrameOnDiscontinuity:!0,maxAudioFramesDrift:1,maxBufferHole:.5,maxFragLookUpTolerance:.25,stretchShortVideoTrack:!1}},l=i(0),c=i(17),f=i(16),p=i(5),m=function(){return(m=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},_=Object(p.a)(),g=function(){function e(e,t,i,n){this.Tag="TransmuxingController",this._emitter=new r.a,this._config=t,this.typeSupported=i,this.navigator=n,this._mediaCodec=null,"boolean"!=typeof e.cors&&(e.cors=!0),"boolean"!=typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e;var a=0;this._currentSegmentIndex=0,e.segments||(this._mediaDataSource.segments=[{duration:e.duration,filesize:e.fileSize,url:e.url,type:e.type,live:t.isLive}]),this._mediaDataSource.segments.forEach((function(i){i.timestampBase=a,a+=i.duration,i.cors=e.cors,i.withCredentials=e.withCredentials,t.referrerPolicy&&(i.referrerPolicy=t.referrerPolicy)})),Number.isNaN(a)||this._mediaDataSource.duration===a||(this._mediaDataSource.duration=a),this._mediaInfo=null,this._mediaCodec=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReportTimer=null}return e.prototype.destroy=function(){this._mediaInfo=null,delete this._mediaDataSource,this._statisticsReportTimer&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._mediaCodec&&(this._mediaCodec.destroy(),this._mediaCodec=null),this._emitter.removeAllListeners(),delete this._emitter},e.prototype.on=function(e,t){this._emitter.on(e,t)},e.prototype.off=function(e,t){this._emitter.off(e,t)},e.prototype.start=function(){this._loadSegment(0),this._enableStatisticsReporter()},e.prototype._loadSegment=function(e,t){this._currentSegmentIndex=e;var i=this._mediaDataSource.segments[e];this._ioctl=new u.a(i,this._config,e);var n=this._ioctl;n.onError=this._onIOException.bind(this),n.onSeeked=this._onIOSeeked.bind(this),n.onComplete=this._onIOComplete.bind(this),n.onRedirect=this._onIORedirect.bind(this),n.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),n.onManifestParsed=this._onManifestParsed.bind(this),t&&this._mediaCodec?this._mediaCodec.bindDataSource(this._ioctl):n.onDataArrival=this._onInitChunkArrival.bind(this),n.open(t)},e.prototype.stop=function(){this._internalAbort(),this._disableStatisticsReporter()},e.prototype._internalAbort=function(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)},e.prototype.pause=function(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())},e.prototype.resume=function(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())},e.prototype.seek=function(e){if("m3u8"===this._mediaDataSource.type)this._ioctl&&this._ioctl.tsSeek(e),this.resume();else{if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;var t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){var i=this._mediaInfo.segments?this._mediaInfo.segments[t]:void 0;if(i){var n=i.getNearestKeyframe(e);this._mediaCodec&&this._mediaCodec.seek(n.milliseconds),this._ioctl&&this._ioctl.seek(n.fileposition),this._pendingResolveSeekPoint=n.milliseconds}else this._pendingSeekTime=e}else{var r=this._mediaInfo.segments&&this._mediaInfo.segments[t]?this._mediaInfo.segments[t]:void 0;if(void 0===r)this._pendingSeekTime=e,this._internalAbort(),this._mediaCodec&&(this._mediaCodec.seek(),this._mediaCodec.insertDiscontinuity()),this._loadSegment(t);else{n=r.getNearestKeyframe(e);this._internalAbort(),this._mediaCodec&&(this._mediaCodec.seek(),this._mediaCodec.insertDiscontinuity(),this._mediaCodec.resetMediaInfo(),this._mediaCodec.timestampBase=this._mediaDataSource.segments[t].timestampBase),this._loadSegment(t,n.fileposition),this._pendingResolveSeekPoint=n.milliseconds,this._reportSegmentMediaInfo(t)}}}this._enableStatisticsReporter()},e.prototype._searchSegmentIndexContains=function(e){for(var t=this._mediaDataSource.segments,i=t.length-1,n=0;n<t.length;n++)if(e<t[n].timestampBase){i=n-1;break}return i},e.prototype._onInitChunkArrival=function(e,t,i){var n=this;if(t>0&&this._mediaCodec)return this._mediaCodec.bindDataSource(this._ioctl),this._mediaCodec.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,this._mediaCodec.parseChunks(e,t,i);if(f.a.probe(e).match){this._mediaCodec=new f.a(e,this._config);var r=this._mediaDataSource;return void 0===r.duration||Number.isNaN(r.duration)||(this._mediaCodec.overridedDuration=r.duration),"boolean"==typeof r.hasAudio&&(this._mediaCodec.overridedHasAudio=r.hasAudio),"boolean"==typeof r.hasVideo&&(this._mediaCodec.overridedHasVideo=r.hasVideo),this._mediaCodec.timestampBase=r.segments[this._currentSegmentIndex].timestampBase,this._mediaCodecBindEvents(),this._mediaCodec.bindDataSource(this._ioctl),this._mediaCodec.parseChunks(e,t)}return c.a.probe(e)?(this._mediaCodec=new c.a(d(),this.typeSupported,this.navigator),this._mediaCodecBindEvents(),this._mediaCodec.resetInitSegment(new Uint8Array(i.initSegmentData),i.audioCodec,i.videoCodec,i.totalduration),this._mediaCodec.resetTimeStamp(void 0),this._mediaCodec.bindDataSource(this._ioctl),this._mediaCodec.parseChunks(new Uint8Array(e),t,i),e.byteLength):(null,l.a.error(this.Tag,"Unsupported media type, this "+this._mediaDataSource.type+" stream is not standard format"),Promise.resolve().then((function(){n._internalAbort()})),this._emitter.emit(h.a.DEMUX_ERROR,o.a.FORMAT_UNSUPPORTED,"Unsupported media type, this "+this._mediaDataSource.type+" stream is not standard format!"),0)},e.prototype._onMediaInfo=function(e){var t=this;null===this._mediaInfo&&(this._mediaInfo=m({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,s.a.prototype));var i=m({},e);Object.setPrototypeOf(i,s.a.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=i,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=Number(t._pendingSeekTime);t._pendingSeekTime=null,t.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(h.a.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(h.a.SCRIPTDATA_ARRIVED,e)},e.prototype._onIOSeeked=function(){this._mediaCodec&&this._mediaCodec.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var t=e+1;this._mediaCodec&&(t<this._mediaDataSource.segments.length?(this._internalAbort(),this._mediaCodec.flushStashedSamples&&this._mediaCodec.flushStashedSamples(),this._loadSegment(t)):(this._mediaCodec.flushStashedSamples&&this._mediaCodec.flushStashedSamples(),this._emitter.emit(h.a.LOAD_COMPLETE),this._disableStatisticsReporter()))},e.prototype._onIORedirect=function(e){var t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(h.a.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,t){l.a.error(this.Tag,"IOException: type = "+e+", code = "+t.code+", msg = "+t.reason),this._emitter.emit(h.a.IO_ERROR,e,t),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,t){l.a.error(this.Tag,"DemuxException: type = "+e+", info = "+t.reason),this._emitter.emit(h.a.DEMUX_ERROR,e,t)},e.prototype._onRemuxerInitSegmentArrival=function(e,t){this._emitter.emit(h.a.INIT_SEGMENT,e,t)},e.prototype._onRemuxerMediaSegmentArrival=function(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(h.a.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){var i=t.info.syncPoints,n=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,a.a.safari&&i.length>0&&i[0].originalDts===n&&(n=i[0].pts),this._emitter.emit(h.a.RECOMMEND_SEEKPOINT,n)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReportTimer&&(this._statisticsReportTimer=_.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReportTimer&&(_.clearInterval(this._statisticsReportTimer),this._statisticsReportTimer=null)},e.prototype._reportSegmentMediaInfo=function(e){var t=this._mediaInfo.segments[e],i=m({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(h.a.MEDIA_INFO,i)},e.prototype._reportStatisticsInfo=function(){var e=Object.create(null);this._ioctl&&(e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType),e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(h.a.STATISTICS_INFO,e)},e.prototype._onManifestParsed=function(e){this._emitter.emit(h.a.MANIFEST_PARSED,e)},e.prototype._mediaCodecBindEvents=function(){var e=this;this._mediaCodec&&(this._mediaCodec.on(h.a.ERROR,(function(t){e._onDemuxException(o.a.TRANSMUXING_ERROR,t)})),this._mediaCodec.on(h.a.MEDIA_INFO,(function(t){e._onMediaInfo(t)})),this._mediaCodec.on(h.a.METADATA_ARRIVED,(function(t){e._onMetaDataArrived(t)})),this._mediaCodec.on(h.a.SCRIPTDATA_ARRIVED,(function(t){e._onScriptDataArrived(t)})),this._mediaCodec.on(h.a.GET_SEI_INFO,(function(t){e._emitter.emit(h.a.GET_SEI_INFO,t)})),this._mediaCodec.on(h.a.INIT_SEGMENT,(function(t,i){e._onRemuxerInitSegmentArrival(t,i)})),this._mediaCodec.on(h.a.MEDIA_SEGMENT,(function(t,i){e._onRemuxerMediaSegmentArrival(t,i)})),this._mediaCodec.on(h.a.LOAD_NEXT_FRAG,(function(){e._ioctl&&e._ioctl.isWorking()&&e._ioctl.loadNextFrag()})))},e}();t.a=g},function(e,t,i){"use strict";var n,r=i(4),a=i.n(r),s=i(11),o=i(21),u=i(0),h=i(23),d=i(10),l=i(25),c=i(2),f=i(6),p=i(3),m=i(5),_=(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)},function(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),g=Object(m.a)(),y=function(e){function t(t,i){var n=e.call(this,"fragment-loader","m3u8")||this;return n.eventEmitter=new a.a,n.Tag="FragmentLoader",n.audioCodecSwitch=!1,n.levels=null,n.startFragRequested=!1,n.bitrateTest=!1,n.stats=null,n.stashFrag=[],n.sn=-1,n.loading=!1,n.masterLevels=[],n.currentFrag=null,n.loader=null,n._pause=!1,n.audioCodecSwap=!1,n._seekHandler=t,n._config=i,n._needStash=!0,n._requestAbort=!1,n._contentLength=null,n._receivedLength=0,n._parser=null,n.pl=null,n._dataSource=null,n._range=null,n}return _(t,e),t.isSupport=function(){return Object(l.a)()},t.prototype.on=function(e,t){this.eventEmitter.on(e,t)},t.prototype.once=function(e,t){this.eventEmitter.once(e,t)},t.prototype.off=function(e,t){this.eventEmitter.off(e,t)},Object.defineProperty(t.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!0,configurable:!0}),t.prototype.destroy=function(){this.abort(),this.pl&&this.pl.abort(),this.pl=null,this.currentFrag=null,this.loader=null,this.bitrateTest=!1,this.eventEmitter.removeAllListeners(),delete this.masterLevels,delete this.eventEmitter,delete this.stashFrag,delete this.levels,delete this.stats},t.prototype.abort=function(){this._pause=!0,this._requestAbort=!0,this.loading=!1,this._status=c.a.kComplete,this.loader&&this.loader.abort()},t.prototype.pause=function(){this._pause=!0,this.loading=!1},t.prototype.resume=function(){u.a.debug(this.Tag,"恢复下载"),this._pause=!1,this._requestAbort=!1,this.loading=!1},t.prototype.isWorking=function(){return!1===this._pause},t.prototype.open=function(e,t){this._dataSource=e,this._range=t,this.pl=new h.a(e),this.pl.on(d.a.MANIFEST_PARSED,this.onManifestParsed.bind(this)),this.pl.on(d.a.LOAD_COMPLETE,this._loadingM3U8Complete.bind(this)),this.pl.on(d.a.LOADING_ERROR,this._loadingM3U8Error.bind(this)),this.pl.on(d.a.PARSE_ERROR,this._parseM3U8Error.bind(this)),this.pl.on(d.a.LOADIND_TIMEOUT,this._loadingM3U8Timeout.bind(this)),this.pl.load()},t.prototype.startLoad=function(e,t){this.open(e,t)},t.prototype.loadNextFrag=function(){if(!this._requestAbort&&!this._pause&&this.levels){if(!1===this.levels[0].details.live&&this.sn===this.levels[0].details.endSN)return this.pl&&this.pl.stop&&this.pl.stop(),void(this.onComplete&&this.onComplete());var e=this.stashFrag[0];if("initSegment"===this.sn){if(!(e=this.stashFrag[1]))return;this.loadFrag(e)}else{for(var t=0;t<this.stashFrag.length;t++)if(this.stashFrag[t].sn===this.sn+1){e=this.stashFrag[t];break}if(!e)return;this.sn<e.sn&&this.loadFrag(e)}}},t.prototype.loadFrag=function(e){if(!this.loading){this.loading=!0,this._status=c.a.kConnecting,this.currentFrag=e,this.sn=e.sn;var t={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1};this.bitrateTest&&(e.url.indexOf("?")>-1?e.url+="&r="+Math.random():e.url+="?r="+Math.random());var i=e.byteRangeStartOffset,n=e.byteRangeEndOffset;Number.isFinite(i)&&Number.isFinite(n)&&(t.rangeStart=i,t.rangeEnd=n);var r={onSuccess:this._loadsuccess.bind(this),onError:this._loaderror.bind(this),onTimeout:this._loadtimeout.bind(this),onProgress:this._loadprogress.bind(this)};this.loader=null,this.loader=new o.a,this.loader.load(t,{timeout:1e4,maxRetry:1,retryDelay:200,maxRetryDelay:200},r)}},t.prototype.seek=function(e){var t=this.currentFrag,i=this._config.maxFragLookUpTolerance;if(this.currentFrag&&t&&this.loader&&this.levels&&!(this.status===c.a.kConnecting&&e>=1e3*(t.start+i)&&e<=1e3*(t.start+t.duration-i))){this.loader.abort();for(var n=0,r=this.stashFrag||[],a=0;a<r.length;a++)if(e>=1e3*r[a].start&&e<=1e3*(r[a].start+r[a].duration)){n=a;break}n=Math.max(n-1,0),this.currentFrag=r[n],this.sn=r[n].sn,this.loadFrag(r[n])}},t.prototype.onManifestParsed=function(e){var t,i=!1,n=!1;if(this.pl)if(e.levels.forEach((function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(i=!0),-1!==t.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n,this.audioCodecSwitch&&u.a.log(this.Tag,"both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),"masterPlaylist"===e.type&&e.levels.length>0){this._config.tsAutoLevelChoose&&(this.bitrateTest=!0);var r=this._dataSource;r.url=e.levels[0].url,this.masterLevels=e.levels,this.pl.dataSource=r,this.pl.url=e.levels[0].url,this.pl.load()}else if("levelPlaylist"===e.type)this.levels=e.levels,this.stashFrag=e.levels[0].details.fragments,this.startFragRequested=!1,this.loadNextFrag(),this.eventEmitter.emit(d.a.MANIFEST_PARSED,e.levels[0]);else{var a={code:-1,reason:"can not find useful playlist"};if(!this._onError)throw new p.d(a.reason);this._onError(d.a.LOADING_ERROR,a)}},t.prototype.onFragLoaded=function(e){var t=e.payload,i=e.frag;if(this.levels&&this.pl&&"main"===i.type){var n=e.stats,r=this.levels[0],a=r.details;if(this.stats=n,this.bitrateTest){this.startFragRequested=!1,n.tbuffered=g.performance.now(),n.tparsed=g.performance.now();var s=this._caluCodeRate(t.byteLength,n),o=this._findSuitableLevels(s);this.pl.url=this.masterLevels[o].url,this.pl.load(),this.bitrateTest=!1}else if("initSegment"===i.sn)n.tbuffered=g.performance.now(),n.tparsed=g.performance.now(),a.initSegment.data=e.payload,this.loadNextFrag();else{i.bitrateTest&&(i.bitrateTest=!1);var u=a.initSegment?a.initSegment.data:[],h=this._getAudioCodec(r),d=r.videoCodec,l=a.totalduration,c=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,c,this._receivedLength,{initSegmentData:u,audioCodec:h,videoCodec:d,fragCurrent:i,totalduration:l,accurateTimeOffset:!1}),this._requestAbort&&this._pause&&(this.sn=this.sn-1,this.currentFrag=this.stashFrag[this.sn])}}},t.prototype._getAudioCodec=function(e){var t=this._config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(u.a.log(this.Tag,"swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},t.prototype._loadsuccess=function(e,t,i,n){void 0===n&&(n=null),this.loading=!1;var r=e.data,a=i.frag;this._status=c.a.kComplete,a&&this.onFragLoaded({payload:r,frag:a,stats:t,networkDetails:n})},t.prototype._loaderror=function(e,t,i){void 0===i&&(i=null),this.loading=!1,this._status=c.a.kError;var n={code:e.code,reason:e.text};if(!this._onError)throw new p.d(n.reason);this._onError(f.a.HTTP_STATUS_CODE_INVALID,n)},t.prototype._loadtimeout=function(e,t,i){void 0===i&&(i=null),this.loading=!1,this._status=c.a.kError;var n={code:-1,reason:"fragment request is timeout"};if(!this._onError)throw new p.d(n.reason);this._onError(f.a.CONNECTING_TIMEOUT,n)},t.prototype._loadprogress=function(e,t,i){void 0===i&&(i=null);t.frag},t.prototype._loadingM3U8Complete=function(){},t.prototype._loadingM3U8Error=function(e){this.loading=!1,this._status=c.a.kError;var t={code:e.response.code,reason:e.response.text};if(!this._onError)throw new p.d(t.reason);this._onError(f.a.HTTP_STATUS_CODE_INVALID,t)},t.prototype._loadingM3U8Timeout=function(e){this.loading=!1,this._status=c.a.kError;var t={code:-1,reason:e.stats.text};if(!this._onError)throw new p.d(t.reason);this._onError(f.a.CONNECTING_TIMEOUT,t)},t.prototype._caluCodeRate=function(e,t){var i=8*e/((t.tparsed-t.trequest)/1e3);return i*=.8},t.prototype._parseM3U8Error=function(e){this.loading=!1,this._status=c.a.kError;var t={code:-1,reason:"parse playlist error",url:e.url};if(!this._onError)throw new p.d(t.reason);this._onError(f.a.PARSE_PLAYLISTING_ERROR,t)},t.prototype._findSuitableLevels=function(e){for(var t=this.masterLevels,i=0,n=t.length-1;n>0;n--)if(t[n].bitrate<e){i=n;break}return i},t}(s.a);t.a=y},function(e,t,i){"use strict";var n=i(4),r=i.n(n);function a(e,t,i){var n=e;if(t+i<n.length){for(;i--;)if(128!=(192&n[++t]))return!1;return!0}return!1}var s,o=function(e){for(var t=[],i=e,n=0,r=e.length;n<r;)if(i[n]<128)t.push(String.fromCharCode(i[n])),++n;else{if(i[n]<192);else if(i[n]<224){if(a(i,n,1))if((s=(31&i[n])<<6|63&i[n+1])>=128){t.push(String.fromCharCode(65535&s)),n+=2;continue}}else if(i[n]<240){if(a(i,n,2))if((s=(15&i[n])<<12|(63&i[n+1])<<6|63&i[n+2])>=2048&&55296!=(63488&s)){t.push(String.fromCharCode(65535&s)),n+=3;continue}}else if(i[n]<248){var s;if(a(i,n,3))if((s=(7&i[n])<<18|(63&i[n+1])<<12|(63&i[n+2])<<6|63&i[n+3])>65536&&s<1114112){s-=65536,t.push(String.fromCharCode(s>>>10|55296)),t.push(String.fromCharCode(1023&s|56320)),n+=4;continue}}t.push(String.fromCharCode(65533)),++n}return t.join("")},u=(s=new ArrayBuffer(2),new DataView(s).setInt16(0,256,!0),256===new Int16Array(s)[0]),h=function(){function e(){}return e.parseScriptData=function(t,i,n){var r=Object.create(null);try{var a=e.parseValue(t,i,n),s=a.size||0,o=a.data||"",u=e.parseValue(t,i+s,n-s);r[o]=u.data}catch(e){}return r},e.parseObject=function(t,i,n){if(n<3)throw new Error("Data not enough when parse ScriptDataObject");var r=e.parseString(t,i,n),a=e.parseValue(t,i+r.size,n-r.size),s=a.size||0,o=a.objectEnd;return{data:{name:r.data,value:a.data},size:r.size+s,objectEnd:o}},e.parseVariable=function(t,i,n){return e.parseObject(t,i,n)},e.parseString=function(e,t,i){if(i<2)throw new Error("Data not enough when parse String");var n=new DataView(e,t,i).getUint16(0,!u);return{data:n>0?o(new Uint8Array(e,t+2,n)):"",size:2+n}},e.parseLongString=function(e,t,i){if(i<4)throw new Error("Data not enough when parse LongString");var n=new DataView(e,t,i).getUint32(0,!u);return{data:n>0?o(new Uint8Array(e,t+4,n)):"",size:4+n}},e.parseDate=function(e,t,i){if(i<10)throw new Error("Data size invalid when parse Date");var n=new DataView(e,t,i),r=n.getFloat64(0,!u),a=n.getInt16(8,!u);return{data:new Date(r+=60*a*1e3),size:10}},e.parseValue=function(t,i,n){if(n<1)throw new Error("Data not enough when parse Value");var r,a=new DataView(t,i,n),s=1,o=a.getUint8(0),h=!1;try{switch(o){case 0:r=a.getFloat64(1,!u),s+=8;break;case 1:r=!!a.getUint8(1),s+=1;break;case 2:var d=e.parseString(t,i+1,n-1);r=d.data,s+=d.size;break;case 3:r={};var l=0;for(9==(16777215&a.getUint32(n-4,!u))&&(l=3);s<n-4;){var c=e.parseObject(t,i+s,n-s-l);if(c.objectEnd)break;r[c.data.name]=c.data.value,s+=c.size}if(s<=n-3)9===(16777215&a.getUint32(s-1,!u))&&(s+=3);break;case 8:r={},s+=4;l=0;for(9==(16777215&a.getUint32(n-4,!u))&&(l=3);s<n-8;){var f=e.parseVariable(t,i+s,n-s-l);if(f.objectEnd)break;r[f.data.name]=f.data.value,s+=f.size}if(s<=n-3)9===(16777215&a.getUint32(s-1,!u))&&(s+=3);break;case 9:r=void 0,s=1,h=!0;break;case 10:r=[];var p=a.getUint32(1,!u);s+=4;for(var m=0;m<p;m++){var _=e.parseValue(t,i+s,n-s),g=_.size||0;r.push(_.data),s+=g}break;case 11:var y=e.parseDate(t,i+1,n-1);r=y.data,s+=y.size;break;case 12:var v=e.parseString(t,i+1,n-1);r=v.data,s+=v.size;break;default:s=n}}catch(e){}return{data:r,size:s,objectEnd:h}},e}(),d=i(0),l=function(){function e(e){this.Tag="ExpGolomb",this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}return e.prototype.loadWord=function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),r=Math.min(4,t);if(0===r)throw new Error("no bytes available");n.set(e.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r},e.prototype.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},e.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;return e>32&&d.a.error(this.Tag,"Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i},e.prototype.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},e.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},e.prototype.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},e.prototype.readBoolean=function(){return 1===this.readBits(1)},e.prototype.readUByte=function(){return this.readBits(8)},e.prototype.readUShort=function(){return this.readBits(16)},e.prototype.readUInt=function(){return this.readBits(32)},e.prototype.skipScalingList=function(e){var t,i=8,n=8;for(t=0;t<e;t++)0!==n&&(n=(i+this.readEG()+256)%256),i=0===n?i:n},e.prototype.readSPS=function(){var e,t,i,n=0,r=0,a=0,s=0,o=this.readUByte.bind(this),u=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),l=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();var m=o();u(5);l(3);o();if(f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var _=h();if(3===_&&l(1),f(),f(),l(1),d())for(t=3!==_?8:12,i=0;i<t;i++)d()&&p(i<6?16:64)}f();var g=h();if(0===g)h();else if(1===g)for(l(1),c(),c(),e=h(),i=0;i<e;i++)c();f(),l(1);var y=h(),v=h(),E=u(1);0===E&&l(1),l(1),d()&&(n=h(),r=h(),a=h(),s=h());var b=[1,1];if(d()&&d())switch(o()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:b=[o()<<8|o(),o()<<8|o()];break;default:b=[1,1]}return{width:Math.ceil(16*(y+1)-2*n-2*r),height:(2-E)*(v+1)*16-(E?2:4)*(a+s),pixelRatio:b}},e.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),c=function(){function e(){}return e._ebsp2rbsp=function(e){for(var t=e,i=t.byteLength,n=new Uint8Array(i),r=0,a=0;a<i;a++)a>=2&&3===t[a]&&0===t[a-1]&&0===t[a-2]||(n[r]=t[a],r++);return new Uint8Array(n.buffer,0,r)},e.parseSPS=function(t){var i=e._ebsp2rbsp(t),n=new l(i);n.readUByte();var r=n.readUByte();n.readUByte();var a=n.readUByte();n.readUEG();var s=e.getProfileString(r),o=e.getLevelString(a),u=1,h=420,d=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(3===(u=n.readUEG())&&n.readBits(1),u<=3&&(h=[0,420,422,444][u]),d=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBoolean()))for(var c=3!==u?8:12,f=0;f<c;f++)n.readBoolean()&&(f<6?e._skipScalingList(n,16):e._skipScalingList(n,64));n.readUEG();var p=n.readUEG();if(0===p)n.readUEG();else if(1===p){n.readBits(1),n.readUEG(),n.readUEG();var m=n.readUEG();for(f=0;f<m;f++)n.readUEG()}var _=n.readUEG();n.readBits(1);var g=n.readUEG(),y=n.readUEG(),v=n.readBits(1);0===v&&n.readBits(1),n.readBits(1);var E=0,b=0,S=0,A=0;n.readBoolean()&&(E=n.readUEG(),b=n.readUEG(),S=n.readUEG(),A=n.readUEG());var T=1,R=1,L=0,O=!0,C=0,w=0;if(n.readBoolean()){if(n.readBoolean()){var I=n.readUByte();I>0&&I<16?(T=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][I-1],R=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][I-1]):255===I&&(T=n.readUByte()<<8|n.readUByte(),R=n.readUByte()<<8|n.readUByte())}if(n.readBoolean()&&n.readBoolean(),n.readBoolean()&&(n.readBits(4),n.readBoolean()&&n.readBits(24)),n.readBoolean()&&(n.readUEG(),n.readUEG()),n.readBoolean()){var D=n.readBits(32),k=n.readBits(32);O=n.readBoolean(),L=(C=k)/(w=2*D)}}var P=1;1===T&&1===R||(P=T/R);var M=0,x=0;0===u?(M=1,x=2-v):(M=3===u?1:2,x=(1===u?2:1)*(2-v));var N=16*(g+1),U=16*(y+1)*(2-v);N-=(E+b)*M,U-=(S+A)*x;var B=Math.ceil(N*P);return n=null,{profileString:s,levelString:o,bitDepth:d,refFrames:_,chromaFormat:h,chromaFormatString:e.getChromaFormatString(h),frameRate:{fixed:O,fps:L,fpsDen:w,fpsNum:C},sarRatio:{width:T,height:R},codecSize:{width:N,height:U},presentSize:{width:B,height:U}}},e._skipScalingList=function(e,t){for(var i=8,n=8,r=0;r<t;r++)0!==n&&(n=(i+e.readUEG()+256)%256),i=0===n?i:n},e.getProfileString=function(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}},e.getLevelString=function(e){return(e/10).toFixed(1)},e.getChromaFormatString=function(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}},e}(),f={ERROR:"ERROR",GET_SEI_INFO:"GET_SEI_INFO",FRAG_PARSED:"FRAG_PARSED",INIT_PTS_FOUND:"INIT_PTS_FOUND",FRAG_PARSING_INIT_SEGMENT:"FRAG_PARSING_INIT_SEGMENT",FRAG_PARSING_METADATA:"FRAG_PARSING_METADATA",FRAG_PARSING_USERDATA:"FRAG_PARSING_USERDATA",MEDIA_INFO:"MEDIA_INFO",MEDIA_DATA_ARRIVED:"MEDIA_DATA_ARRIVED",SCRIPT_DATA_ARRIVED:"SCRIPT_DATA_ARRIVED",INIT_SEGMENT:"INIT_SEGMENT",MEDIA_SEGMENT:"MEDIA_SEGMENT"},p="muxError",m="FormatError",_="CodecUnsupported",g=function(){function e(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}return e.prototype.isComplete=function(){var e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t},e.prototype.isSeekable=function(){return!0===this.hasKeyframesIndex},e.prototype.getNearestKeyframe=function(e){if(null==this.keyframesIndex)return null;var t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}},e.prototype._search=function(e,t){var i=0,n=e.length-1,r=0,a=0,s=n;for(t<e[0]&&(i=0,a=s+1);a<=s;){if((r=a+Math.floor((s-a)/2))===n||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?a=r+1:s=r-1}return i},e}(),y=function(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,r,a=i.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return s},v=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(y(arguments[t]));return e},E=function(){function e(){}return e.init=function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]},Object.keys(e.types).forEach((function(t){e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]})),e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STCO=e.STTS,e.STSC=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e.box=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=8,r=null,a=v(t),s=a.length,o=0;o<s;o++)n+=a[o].byteLength;(r=new Uint8Array(n))[0]=n>>>24&255,r[1]=n>>>16&255,r[2]=n>>>8&255,r[3]=255&n,r.set(e,4);var u=8;for(o=0;o<s;o++)r.set(a[o],u),u+=a[o].byteLength;return r},e.generateInitSegment=function(t){var i=e.box(e.types.ftyp,e.FTYP),n=e.moov(t),r=new Uint8Array(i.byteLength+n.byteLength);return r.set(i,0),r.set(n,i.byteLength),r},e.moov=function(t){var i=e.mvhd(t.timescale,t.duration),n=e.trak(t),r=e.mvex(t);return e.box(e.types.moov,i,n,r)},e.mvhd=function(t,i){return void 0===i&&(i=0),e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))},e.trak=function(t){return e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.tkhd=function(t){var i=t.id,n=t.duration||0,r=t.presentWidth,a=t.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>>8&255,255&r,0,0,a>>>8&255,255&a,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t),e.hdlr(t),e.minf(t))},e.mdhd=function(t){var i=t.timescale,n=t.duration||0;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))},e.hdlr=function(t){var i=null;return i="audio"===t.type?e.HDLR_AUDIO:e.HDLR_VIDEO,e.box(e.types.hdlr,i)},e.minf=function(t){var i=null;return i="audio"===t.type?e.box(e.types.smhd,e.SMHD):e.box(e.types.vmhd,e.VMHD),e.box(e.types.minf,i,e.dinf(),e.stbl(t))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.DREF))},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.codec?e.box(e.types.stsd,e.STSD_PREFIX,e.mp3(t)):e.box(e.types.stsd,e.STSD_PREFIX,e.mp4a(t)):e.box(e.types.stsd,e.STSD_PREFIX,e.avc1(t))},e.mp3=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types[".mp3"],r)},e.mp4a=function(t){var i=t.channelCount,n=t.audioSampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types.mp4a,r,e.esds(t))},e.esds=function(t){var i=t.config||[],n=i.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,r)},e.avc1=function(t){var i=t.avcc,n=t.codecWidth,r=t.codecHeight,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,n>>>8&255,255&n,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,a,e.box(e.types.avcC,i))},e.mvex=function(t){return e.box(e.types.mvex,e.trex(t))},e.trex=function(t){var i=t.id,n=new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,n)},e.moof=func