/*! * FlvPlayer.js v1.1.8 * Github: https://github.com/zhw2590582/FlvPlayer#readme * (c) 2017-2023 Harvey Zack * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).FlvPlayer=t()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t((function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),n=e(r),o=t((function(e){var t=r.default;e.exports=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));e(o);var i=t((function(e){var t=r.default;e.exports=function(e){var r=o(e,"string");return"symbol"===t(r)?r:String(r)},e.exports.__esModule=!0,e.exports.default=e.exports}));e(i);var a=e(t((function(e){e.exports=function(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports}))),u=e(t((function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}))),c=e(t((function(e){function t(e,t){for(var r=0;r1?r-1:0),o=1;o1?n-1:0),i=1;i1?n-1:0),i=1;i3&&void 0!==arguments[3]?arguments[3]:{};if(Array.isArray(t))return t.map((function(t){return n.proxy(e,t,r,o)}));e.addEventListener(t,r,o);var i=function(){return e.removeEventListener(t,r,o)};return this.destroys.push(i),i}},{key:"destroy",value:function(){this.destroys.forEach((function(e){return e()}))}}]),e}();function j(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function _(){return/MicroMessenger/i.test(navigator.userAgent)}function C(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function T(e){var t=0;function r(n){for(var o=new Uint8Array(n),i=0;i1?t-1:0),n=1;n=1e3&&(e(t/i*1e3),r=o,t=0)}}var V=Object.freeze({__proto__:null,isMobile:j,isWechat:_,hasOwnProperty:C,readBuffer:T,mergeBuffer:D,createWorker:function(e){return new Worker(URL.createObjectURL(new Blob([e],{type:"application/javascript"})))},secondToTime:function(e){var t=Math.floor(e/3600),r=Math.floor((e-3600*t)/60),n=Math.floor(e-3600*t-60*r);return(t>0?[t,r,n]:[r,n]).map((function(e){return e<10?"0".concat(e):String(e)})).join(":")},getNowTime:M,debounce:function(e,t,r){var n;function o(){for(var o=arguments.length,i=new Array(o),a=0;a2&&void 0!==arguments[2])||arguments[2],n=getComputedStyle(e,null).getPropertyValue(t);return r?parseFloat(n):n},loadScript:L,proxyPropertys:B,calculationRate:F});var U=c((function e(t){u(this,e),function(e,t){var r=e.options,n=r.container.style.cssText;r.container.classList.add("flvplayer-container"),r.container.innerHTML='
'),e.on("destroy",(function(){r.container.innerHTML="",r.container.style.cssText=n,r.container.classList.remove("flvplayer-container")})),Object.defineProperty(t,"$container",{value:r.container}),Object.defineProperty(t,"$player",{value:r.container.querySelector(".flvplayer-player")}),Object.defineProperty(t,"$canvas",{value:r.container.querySelector(".flvplayer-canvas")})}(t,this),function(e,t){Object.defineProperty(t,"rect",{get:function(){return t.$container.getBoundingClientRect()}}),["bottom","height","left","right","top","width"].forEach((function(e){Object.defineProperty(t,e,{get:function(){return t.rect[e]}})})),Object.defineProperty(t,"currentTime",{get:function(){return e.decoder.currentTime},set:function(r){e.options.cache&&e.decoder.seeked(E(r,0,t.loaded))}}),Object.defineProperty(t,"streaming",{get:function(){return e.demuxer.streaming}}),Object.defineProperty(t,"demuxed",{get:function(){return e.demuxer.demuxed}}),Object.defineProperty(t,"videoDecoding",{get:function(){return e.decoder.video.decoding}}),Object.defineProperty(t,"audioDecoding",{get:function(){return e.decoder.audio.decoding}}),Object.defineProperty(t,"duration",{get:function(){try{return e.demuxer.scripMeta.amf2.metaData.duration||e.options.duration}catch(t){return e.options.duration}}}),Object.defineProperty(t,"frameRate",{get:function(){var t=Math.round(e.options.frameRate||30);try{return Math.round(e.demuxer.scripMeta.amf2.metaData.framerate)||t}catch(e){return t}}}),Object.defineProperty(t,"frameDuration",{get:function(){return 1e3/t.frameRate|0}}),Object.defineProperty(t,"muted",{get:function(){return e.decoder.audio.muted},set:function(t){e.decoder.audio.muted=t}}),Object.defineProperty(t,"volume",{get:function(){try{return e.decoder.audio.volume}catch(e){return 0}},set:function(r){try{return e.decoder.audio.volume=E(r,0,1),t.volume}catch(e){return r}}}),Object.defineProperty(t,"loaded",{get:function(){return e.decoder.video.loaded}}),Object.defineProperty(t,"playing",{get:function(){return e.decoder.playing}}),Object.defineProperty(t,"ended",{get:function(){return e.decoder.ended}}),Object.defineProperty(t,"play",{value:function(){t.playing||e.decoder.play()}}),Object.defineProperty(t,"pause",{value:function(){e.decoder.pause()}}),Object.defineProperty(t,"toggle",{value:function(){t.playing?t.pause():t.play()}})}(t,this),function(e,t){var r=e.events.proxy;e.on("scripMeta",(function(e){var r=e.amf2.metaData,n=r.width,o=r.height;n&&o&&(t.$canvas.width=n,t.$canvas.height=o)})),r(t.$canvas,"click",(function(){t.toggle()}))}(t,this)}));function I(e,t,r){return Math.max(Math.min(e,Math.max(t,r)),Math.min(t,r))}function z(...e){const t=e[0].constructor;return e.reduce(((e,r)=>{const n=new t((0|e.byteLength)+(0|r.byteLength));return n.set(e,0),n.set(r,0|e.byteLength),n}),new t)}class W{constructor(e={}){if(this.option=m({...W.option,...e},W.scheme),this.option.volume=I(this.option.volume,0,1),this.option.chunk=I(this.option.chunk,0,1/0),this.option.maxTimeDiff=I(this.option.maxTimeDiff,0,1/0),this.option.autoEndTime=I(this.option.autoEndTime,0,1/0),this.context=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.context.createGain(),this.gainNode.gain.value=this.option.volume,this.source=null,this.decoding=!1,this.playing=!1,this.loadLength=0,this.loadByteSize=0,this.audioDuration=0,this.pcmLength=0,this.timestamps=[],this.audiobuffers=[],this.timestampTmp=[],this.decodeErrorBuffer=new Uint8Array,this.decodeWaitingBuffer=new Uint8Array,this.autoEndDebounce=function(e,t,r){let n;return function(...o){clearTimeout(n),n=setTimeout((function(){n=null,e.apply(r,o)}),t)}}((()=>{this.end()}),this.option.autoEndTime),this.option.touchResume&&"suspended"===this.context.state&&"ontouchstart"in window){const e=()=>{this.context.resume(),this.volume=1,document.body.removeEventListener("touchstart",e,!1),document.body.removeEventListener("click",e,!1)};document.body.addEventListener("touchstart",e,!1),document.body.addEventListener("click",e,!1)}}static get option(){return{volume:.7,cache:!0,chunk:65536,maxTimeDiff:200,autoEnd:!0,autoEndTime:5e3,touchResume:!0,onNext:e=>e,onLoad:()=>null,onStop:()=>null,onPlay:()=>null,onEnd:()=>null,onDestroy:()=>null,onDecodeDone:()=>null,onDecodeError:()=>null,onVolumeChange:()=>null,onFreeMemory:()=>null}}static get scheme(){return{volume:"number",cache:"boolean",chunk:"number",maxTimeDiff:"number",autoEnd:"boolean",autoEndTime:"number",touchResume:"boolean",onNext:"function",onLoad:"function",onStop:"function",onPlay:"function",onEnd:"function",onDestroy:"function",onDecodeDone:"function",onDecodeError:"function",onVolumeChange:"function",onFreeMemory:"function"}}get volume(){return this.gainNode.gain.value}set volume(e){this.gainNode.gain.value=I(e,0,1),this.option.onVolumeChange(e)}get duration(){return this.audiobuffers.reduce(((e,t)=>e+=t.duration),0)}destroy(){return this.stop(),this.context=null,this.gainNode=null,this.source=null,this.timestamps=[],this.audiobuffers=[],this.timestampTmp=[],this.decodeErrorBuffer=new Uint8Array,this.decodeWaitingBuffer=new Uint8Array,this.option.onDestroy(),this}load(e,t){if(this.decoding=!0,this.loadLength+=1,this.loadByteSize+=e.byteLength,this.option.onLoad(e,t),this.decodeWaitingBuffer.byteLength>=this.option.chunk){this.timestamps.push(this.timestampTmp[0]),this.timestampTmp=[];const{buffer:e}=z(this.decodeErrorBuffer,this.decodeWaitingBuffer);this.decodeWaitingBuffer=new Uint8Array,this.context.decodeAudioData(e,(e=>{this.audioDuration+=e.duration,this.pcmLength+=e.length,this.audiobuffers.push(e),this.decodeErrorBuffer=new Uint8Array,this.option.onDecodeDone(e)}),(e=>{this.decodeErrorBuffer=z(this.decodeErrorBuffer,this.decodeWaitingBuffer),this.option.onDecodeError(e)}))}else this.timestampTmp.push(t),this.decodeWaitingBuffer=z(this.decodeWaitingBuffer,e);return this.option.autoEnd&&this.autoEndDebounce(),this}end(){if(this.decodeWaitingBuffer.length){this.timestamps.push(this.timestampTmp[0]),this.timestampTmp=[];const{buffer:e}=this.decodeWaitingBuffer;this.decodeWaitingBuffer=new Uint8Array,this.decodeErrorBuffer=new Uint8Array,this.context.decodeAudioData(e,(e=>{this.audioDuration+=e.duration,this.pcmLength+=e.length,this.audiobuffers.push(e),this.decoding=!1,this.option.onEnd()}))}return this}findIndex(e){return this.timestamps.findIndex(((t,r)=>{const n=this.audiobuffers[r];return n&&t+1e3*n.duration>=e}))}play(e=0){this.source&&(this.source.onended=null,this.source.stop(),this.source=null),e+=1,this.playing=!0;const t=this.findIndex(e),r=this.timestamps[t],n=this.audiobuffers[t];if(void 0===r||void 0===n)return this.stop(t,r);const o=Math.max(0,(e-r)/1e3);return this.source=this.context.createBufferSource(),this.source.connect(this.gainNode),this.gainNode.connect(this.context.destination),this.source.buffer=n,this.option.onPlay(n,e,o),this.source.start(0,o),this.source.onended=()=>{const e=this.timestamps[t+1],n=this.audiobuffers[t+1];if(void 0!==e&&void 0!==n){const t=this.option.onNext(e),r=this.findIndex(t);!this.option.cache&&r>0&&(this.option.onFreeMemory({total:this.pcmLength,pcm:this.audiobuffers.reduce(((e,t)=>e+=t.length),0),index:r}),this.audiobuffers.splice(0,r),this.timestamps.splice(0,r)),this.play(t)}else this.stop(t,r)},this}stop(e,t){return this.playing=!1,this.source&&(this.source.onended=null,this.source.stop(),this.source=null),this.option.onStop(e,t),this}}var q=function(){function e(t,r){var n=this;u(this,e),this.flv=t,this.dida=new W({volume:t.options.muted?0:t.options.volume,cache:t.options.cache,chunk:t.options.audioChunk,maxTimeDiff:t.options.maxTimeDiff,touchResume:t.options.touchResume,onNext:function(e){var n=e-1e3*r.currentTime;return t.debug.log("time-diff",n),Math.abs(n)>=t.options.maxTimeDiff&&(t.debug.log("time-sync",n),r.currentTime=e/1e3),e},onVolumeChange:function(e){t.emit("volumechange",e)},onFreeMemory:function(e){t.debug.log("free-audio-memory",e),t.emit("freeAudioMemory",e)}}),t.on("audioData",(function(e,t){n.dida.load(e,t)})),t.on("destroy",(function(){n.dida.destroy()}))}return c(e,[{key:"muted",get:function(){return 0===this.volume},set:function(e){this.volume=e?0:.7}},{key:"volume",get:function(){return this.dida.volume},set:function(e){this.dida.volume=e}},{key:"decoding",get:function(){return this.dida.decoding}},{key:"playing",get:function(){return this.dida.playing}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.dida.play(1e3*e)}},{key:"stop",value:function(){this.dida.stop()}}]),e}(),N=function(){function e(t){var r=this;u(this,e),this.flv=t,this.ended=!1,this.playing=!1,this.waiting=!1,this.animationFrameTimer=null,this.waitingTimer=null,this.currentTime=0,this.lastUpdateTime=0,this.video=new window.FlvplayerDecoder(t,this),t.options.hasAudio?this.audio=new q(t,this):this.audio={play:function(){return null},stop:function(){return null},playing:!0,decoding:!1},t.on("ready",(function(){t.options.autoPlay?r.play():r.video.draw(0)})),t.on("destroy",(function(){r.pause()})),t.on("timeupdate",(function(e){!t.options.live&&e>=t.player.duration&&r.pause()}));var n=!1;t.events.proxy(document,"visibilitychange",(function(){document.hidden?(n=r.playing,r.pause()):n&&r.play()}))}return c(e,[{key:"play",value:function(){this.lastUpdateTime=M(),this.video.play(this.currentTime),this.audio.play(this.currentTime),this.animationFrame(),this.flv.emit("play")}},{key:"animationFrame",value:function(){var e=this,t=this.flv,r=t.options,n=t.player,o=t.debug;this.animationFrameTimer=requestAnimationFrame((function(){if(!e.video.playing||!e.audio.playing)return n.streaming||e.video.decoding||e.audio.decoding?(e.ended=!1,e.playing=!0,e.waiting=!0,e.flv.emit("waiting",e.currentTime),void(e.waitingTimer=setTimeout((function(){o.log("play-retry",{streaming:n.streaming,playing:{video:e.video.playing,audio:e.audio.playing},decoding:{video:e.video.decoding,audio:e.audio.decoding}}),e.play()}),r.live?3e3:1e3))):(e.ended=!0,e.playing=!1,e.waiting=!1,e.pause(),e.flv.emit("ended",e.currentTime),void(r.loop&&r.cache&&!r.live&&(e.currentTime=0,e.play(),e.flv.emit("loop"))));e.ended=!1,e.playing=!0,e.waiting=!1;var t=M();e.currentTime+=(t-e.lastUpdateTime)/1e3,e.lastUpdateTime=t,e.flv.emit("timeupdate",e.currentTime),e.animationFrame()}))}},{key:"pause",value:function(){cancelAnimationFrame(this.animationFrameTimer),clearTimeout(this.waitingTimer),this.animationFrameTimer=null,this.waitingTimer=null,this.video.stop(),this.audio.stop(),this.ended=!1,this.playing=!1,this.waiting=!1,this.flv.emit("pause")}},{key:"seeked",value:function(e){var t=this.flv,r=t.player,n=t.options;n.cache&&!n.live&&(cancelAnimationFrame(this.animationFrameTimer),clearTimeout(this.waitingTimer),this.animationFrameTimer=null,this.waitingTimer=null,this.currentTime=e,this.video.draw(Math.floor(e*r.frameRate)),this.playing&&this.play(),this.flv.emit("seeked",e))}}]),e}();var H=c((function e(t){var r=this;u(this,e);var n=t.options,o=t.debug;this.header=null,this.streaming=!1,this.demuxed=!1,this.videoDataSize=0,this.audioDataSize=0,this.videoDataLength=0,this.audioDataLength=0,this.streamStartTime=0,this.streamEndTime=0,this.scripMeta=null,this.AudioSpecificConfig=null,this.AVCDecoderConfigurationRecord=null,this.demuxWorker=new Worker(URL.createObjectURL(new Blob(['"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperties(a,b){for(var c,d=0;d=a}function read(a){for(var b=new Uint8Array(a),c=0;c>4,codecID:15&a.body[0]};debug.error(7===b.codecID,"[videoTrack] Unsupported codec in video frame: ".concat(b.codecID));var c=a.body.slice(1,5);debug.error(4<=c.length,"[H264] Invalid AVC packet, missing AVCPacketType or/and CompositionTime");var d=new DataView(c.buffer),e=d.getUint8(0),f=(16777215&d.getUint32(0))<<8>>8,g=f+a.timestamp,h=a.body.subarray(5);if(0===e){debug.warn(!AVCDecoderConfigurationRecord,"[h264] Find another one AVCDecoderConfigurationRecord"),debug.error(7<=h.length,"[H264] AVCDecoderConfigurationRecord parse length is not enough");var j=readBuffer(h),k={};k.configurationVersion=j(1)[0],debug.error(1===k.configurationVersion,"[H264] Invalid configurationVersion: ".concat(k.configurationVersion)),k.AVCProfileIndication=j(1)[0],debug.error(0!==k.AVCProfileIndication,"[H264] Invalid AVCProfileIndication: ".concat(k.AVCProfileIndication)),k.profile_compatibility=j(1)[0],k.AVCLevelIndication=j(1)[0],k.lengthSizeMinusOne=(3&j(1)[0])+1,debug.error(4===k.lengthSizeMinusOne||3!==k.lengthSizeMinusOne,"[H264] Invalid lengthSizeMinusOne: ".concat(k.lengthSizeMinusOne)),k.numOfSequenceParameterSets=31&j(1)[0],debug.error(0!==k.numOfSequenceParameterSets,"[H264] Invalid numOfSequenceParameterSets: ".concat(k.numOfSequenceParameterSets)),debug.warn(1===k.numOfSequenceParameterSets,"[H264] Strange numOfSequenceParameterSets: ".concat(k.numOfSequenceParameterSets));for(var l=0;l>4,soundRate:(12&a.body[0])>>2,soundSize:(2&a.body[0])>>1,soundType:(1&a.body[0])>>0};debug.error(10===b.soundFormat,"[audioTrack] unsupported audio format: ".concat(b.soundFormat));var c=a.body.subarray(1),d=c[0];if(0===d){var e=c.subarray(1);debug.warn(!AudioSpecificConfig,"[AAC] Find another one AudioSpecificConfig"),debug.error(2<=e.length,"[AAC] AudioSpecificConfig parse length is not enough");var f={};f.audioObjectType=(248&e[0])>>3,f.samplingFrequencyIndex=((7&e[0])<<1)+(1&(128&e[1])>>7),f.channelConfiguration=(127&e[1])>>3,AudioSpecificConfig=f,postMessage({type:"AudioSpecificConfig",data:f})}else{var g=AudioSpecificConfig,h=g.audioObjectType,i=g.samplingFrequencyIndex,j=g.channelConfiguration,k=a.dataSize-2+7,l=new Uint8Array(7);l[0]=255,l[1]=240,l[1]|=0,l[1]|=0,l[1]|=1,l[2]=h-1<<6,l[2]|=(15&i)<<2,l[2]|=0,l[2]|=(4&j)>>2,l[3]=(3&j)<<6,l[3]|=0,l[3]|=0,l[3]|=0,l[3]|=0,l[3]|=(6144&k)>>11,l[4]=(2040&k)>>3,l[5]=(7&k)<<5,l[5]|=31,l[6]=252;var m=a.body.subarray(2);postMessage({type:"audioData",data:mergeBuffer(l,m),timestamp:a.timestamp})}}onmessage=function onmessage(a){if(uint8=mergeBuffer(uint8,a.data.uint8),!header&&readable(13)){header=Object.create(null),header.signature=readString(read(3)),header.version=read(1)[0],debug.error("FLV"===header.signature&&1===header.version,"FLV header not found"),header.flags=read(1)[0];var b=0!=(4&header.flags)>>>2,c=0!=(1&header.flags);debug.warn(c,"[FLV header] flags not found video"),debug.warn(b,"[FLV header] flags not found audio"),header.headersize=readBufferSum(read(4));var d=readBufferSum(read(4));debug.error(0===d,"PrevTagSize0 should be equal to 0, but got ".concat(d)),postMessage({type:"flvHeader",data:header})}for(;indexthis.chunkStart){var t=this.data.subarray(this.chunkStart,e);this.flv.emit("streaming",t),this.chunkStart=e}}},{key:"initFetchStream",value:function(){var e=this,t=this.flv,r=t.options,n=t.debug;return this.flv.emit("streamStart"),this.controller=new AbortController,n.log("this.controller",this.controller),fetch(r.url,{credentials:r.withCredentials?"include":"omit",mode:r.cors?"cors":"no-cors",headers:r.headers,signal:this.controller.signal}).then((function(t){return t.body&&"function"==typeof t.body.getReader?(e.reader=t.body.getReader(),function e(){var t=this;return this.reader.read().then((function(o){var i=o.done,a=o.value;if(i)return t.flv.emit("streamEnd"),n.log("stream-end","".concat(t.byteLength," byte")),null;var u=new Uint8Array(a);return t.byteLength+=u.byteLength,t.streamRate(u.byteLength),r.live?t.flv.emit("streaming",u):(t.data=D(t.data,u),0===t.chunkStart&&t.data.length>=t.chunkSize&&t.readChunk()),e.call(t)})).catch((function(e){throw t.flv.emit("streamError",e),e}))}.call(e)):(n.log("stream-type","Try use response arrayBuffer"),t.arrayBuffer())})).then((function(t){t&&t.byteLength&&!r.live&&(e.data=new Uint8Array(t),e.byteLength+=e.data.byteLength,e.flv.emit("streamEnd",e.data),n.log("stream-end","".concat(e.byteLength," byte")))})).catch((function(t){throw e.flv.emit("streamError",t),t}))}},{key:"initFetchRange",value:function(e,t){var r=this,n=this.flv,o=n.options,i=n.debug;return this.controller=new AbortController,i.log("this.controller",this.controller),fetch(o.url,{credentials:o.withCredentials?"include":"omit",mode:o.cors?"cors":"no-cors",headers:G(G({},o.headers),{},{range:"bytes=".concat(e,"-").concat(t)}),signal:this.controller.signal}).then((function(e){return e.arrayBuffer()})).then((function(e){var n=new Uint8Array(e);r.byteLength+=n.byteLength,r.streamRate(n.byteLength),o.live?r.flv.emit("streaming",n):(r.data=D(r.data,n),0===r.chunkStart&&r.data.length>=r.chunkSize&&r.readChunk());var i=Math.min(r.contentLength,t+1),a=Math.min(r.contentLength,i+r.chunkSize);a>i&&r.initFetchRange(i,a)})).catch((function(e){throw r.flv.emit("streamError",e),e}))}}]),e}(),J=c((function e(t){var r=this;u(this,e);var n=t.debug,o=t.options,i=t.events.proxy;this.byteLength=0,this.streamRate=F((function(e){t.emit("streamRate",e)})),this.socket=new WebSocket(t.options.url),this.socket.binaryType="arraybuffer",t.emit("streamStart"),i(this.socket,"open",(function(){r.socket.send(o.socketSend)})),i(this.socket,"message",(function(e){var n=new Uint8Array(e.data);r.byteLength+=n.byteLength,r.streamRate(n.byteLength),t.emit("streaming",n)})),i(this.socket,"close",(function(){t.emit("streamEnd"),n.log("stream-end","".concat(r.byteLength," byte"))})),i(this.socket,"error",(function(e){throw t.emit("streamError",e),e})),t.on("destroy",(function(){r.socket.close()}))})),Q=c((function e(t){u(this,e);var r=new FileReader,n=t.events.proxy;n(r,"load",(function(e){var r=new Uint8Array(e.target.result);t.emit("streamEnd",r),t.debug.log("stream-end","".concat(r.byteLength," byte"))})),n(r,"error",(function(e){t.emit("streamError",e)})),t.on("destroy",(function(){r.abort()})),t.emit("streamStart"),r.readAsArrayBuffer(t.options.url)})),X=function(){function e(t){u(this,e);var r=e.getLoaderFactory(t.options.url);return t.debug.log("stream-loader",r.name),new r(t,this)}return c(e,null,[{key:"getLoaderFactory",value:function(e){return e instanceof File?Q:/^ws{1,2}:\/\//i.test(e)?J:K}}]),e}();function Y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Z(e){for(var t=1;t