|
Server : Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 System : Windows NT SERVER-PC 10.0 build 26200 (Windows 11) AMD64 User : ServerPC ( 0) PHP Version : 8.2.12 Disable Function : NONE Directory : C:/Users/ServerPC/AppData/Roaming/Emby-Server/system/dashboard-ui/modules/howlerjs/ |
Upload File : |
define(["exports"],function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;function HowlerGlobal(){this._counter=1e3,this._howls=[],this._muted=!1,this._volume=1,this.masterGain=null,this.noAudio=!1,this.autoSuspend=!0,this.ctx=null,this.bound_onAutoSuspendTimeout=this._onAutoSuspendTimeout.bind(this),this.bound_handleSuspension=this._handleSuspension.bind(this),this.bound_onCtxResume=this._onCtxResume.bind(this),this._setup()}function decodeAudioData(arraybuffer,self){function error(){console.log("loaderror")}function success(buffer){buffer&&0<self._sounds.length?(cache[self._src]=buffer,loadSound(self,buffer)):error()}1===Howler.ctx.decodeAudioData.length?Howler.ctx.decodeAudioData(arraybuffer).then(success).catch(error):Howler.ctx.decodeAudioData(arraybuffer,success,error)}function Sound(howl){this._parent=howl,this.init()}function Howl(o){o.src&&0!==o.src.length?this.init(o):console.error("An array of source files must be passed with any new Howl.")}HowlerGlobal.prototype={_setup:function(){return this.state=this.ctx&&this.ctx.state||"suspended",this._autoSuspend(),this},_handleSuspension:function(){this.state="suspended",this._resumeAfterSuspend&&(delete this._resumeAfterSuspend,this._autoResume())},_onAutoSuspendTimeout:function(){this.autoSuspend&&(this._suspendTimer=null,this.state="suspending",this.ctx.suspend().then(this.bound_handleSuspension,this.bound_handleSuspension))},_autoSuspend:function(){if(this.autoSuspend&&this.ctx&&void 0!==this.ctx.suspend){for(var i=0;i<this._howls.length;i++)for(var j=0;j<this._howls[i]._sounds.length;j++)if(!this._howls[i]._sounds[j]._paused)return this;return this._suspendTimer&&clearTimeout(this._suspendTimer),this._suspendTimer=setTimeout(this.bound_onAutoSuspendTimeout,3e4),this}},_onCtxResume:function(){this.state="running";for(var i=0;i<this._howls.length;i++)this._howls[i]._onResume&&this._howls[i]._onResume()},_autoResume:function(){if(this.ctx&&void 0!==this.ctx.resume)return"running"===this.state&&"interrupted"!==this.ctx.state&&this._suspendTimer?(clearTimeout(this._suspendTimer),this._suspendTimer=null):"suspended"===this.state||"running"===this.state&&"interrupted"===this.ctx.state?(this.ctx.resume().then(this.bound_onCtxResume),this._suspendTimer&&(clearTimeout(this._suspendTimer),this._suspendTimer=null)):"suspending"===this.state&&(this._resumeAfterSuspend=!0),this}};var Howler=new HowlerGlobal,cache={},loadSound=function(self,buffer){buffer&&!self._duration&&(self._duration=buffer.duration),0===Object.keys(self._sprite).length&&(self._sprite={__default:[0,1e3*self._duration]}),"loaded"!==self._state&&(self._state="loaded",self._loadQueue())};Sound.prototype={init:function(){var parent=this._parent;return this._muted=parent._muted,this._volume=parent._volume,this._paused=!0,this._ended=!0,this._sprite="__default",this._id=++Howler._counter,parent._sounds.push(this),this.create(),this},create:function(){var volume=Howler._muted||this._muted||this._parent._muted?0:this._volume;return this._node=Howler.ctx.createGain(),this._node.gain.setValueAtTime(volume,Howler.ctx.currentTime),this._node.paused=!0,this._node.connect(Howler.masterGain),this},reset:function(){var parent=this._parent;return this._muted=parent._muted,this._volume=parent._volume,this._paused=!0,this._ended=!0,this._sprite="__default",this._id=++Howler._counter,this}},Howl.prototype={init:function(o){var self=this;if(!Howler.ctx&&!Howler.noAudio){try{"undefined"!=typeof AudioContext?Howler.ctx=new AudioContext:Howler.noAudio=!0}catch(e){Howler.noAudio=!0}Howler.ctx||(Howler.noAudio=!0),Howler.noAudio||(Howler.masterGain=Howler.ctx.createGain(),Howler.masterGain.gain.setValueAtTime(Howler._muted?0:Howler._volume,Howler.ctx.currentTime),Howler.masterGain.connect(Howler.ctx.destination)),Howler._setup()}return self.boundPlaySoundAfterResume=self.playSoundAfterResume.bind(self),self._autoplay=o.autoplay||!1,self._format="string"!=typeof o.format?o.format:[o.format],self._muted=o.mute||!1,self._pool=o.pool||5,self._preload="boolean"!=typeof o.preload&&"metadata"!==o.preload||o.preload,self._sprite=o.sprite||{},self._src="string"!=typeof o.src?o.src:[o.src],self._volume=void 0!==o.volume?o.volume:1,self._xhr={method:o.xhr&&o.xhr.method?o.xhr.method:"GET",headers:o.xhr&&o.xhr.headers?o.xhr.headers:null,withCredentials:!(!o.xhr||!o.xhr.withCredentials)&&o.xhr.withCredentials},self._duration=0,self._state="unloaded",self._sounds=[],self._queue=[],self._playLock=!1,Howler._howls.push(self),self._autoplay&&self._queue.push({event:"play",action:function(){self.play()}}),self._preload&&"none"!==self._preload&&self.load(),self},load:function(){var url=null;if(!Howler.noAudio&&(url=this._src.length?this._src[0]:url))return this._src=url,this._state="loading",new Sound(this),function(self){var url=self._src;if(cache[url])self._duration=cache[url].duration,loadSound(self);else{var xhr=new XMLHttpRequest;xhr.open(self._xhr.method,url,!0),xhr.withCredentials=self._xhr.withCredentials,xhr.responseType="arraybuffer",self._xhr.headers&&Object.keys(self._xhr.headers).forEach(function(key){xhr.setRequestHeader(key,self._xhr.headers[key])}),xhr.onload=function(){var code=(xhr.status+"")[0];"0"!==code&&"2"!==code&&"3"!==code?console.log("loaderror"):decodeAudioData(xhr.response,self)},xhr.onerror=function(){self.noAudio=!0,self._sounds=[],delete cache[url],self.load()};try{xhr.send()}catch(e){xhr.onerror()}}}(this),this;console.log("loaderror")},playSoundInternal:function(sound){var node=sound._node,vol=(this._onResume=null,this._playLock=!1,sound._paused=!1,this._refreshBuffer(sound),sound._muted||this._muted?0:sound._volume);node.gain.setValueAtTime(vol,Howler.ctx.currentTime),sound._playStart=Howler.ctx.currentTime,node.bufferSource.start(0),node.bufferSource.onended=this._ended.bind(this,sound),this._loadQueue("play"),this._loadQueue()},playSoundAfterResume:function(){var sound=this._onResumeSound;sound&&(this.playSoundInternal(sound),this._onResumeSound=null)},play:function(sprite){var self=this,id=null;if("number"==typeof sprite)id=sprite,sprite=null;else if(void 0===sprite&&(sprite="__default",!self._playLock)){for(var num=0,i=0;i<self._sounds.length;i++)self._sounds[i]._paused&&!self._sounds[i]._ended&&(num++,id=self._sounds[i]._id);1===num?sprite=null:id=null}var soundId,sound=id?self._soundById(id):self._inactiveSound();return sound?(id&&!sprite&&(sprite=sound._sprite||"__default"),"loaded"!==self._state?(sound._sprite=sprite,sound._ended=!1,soundId=sound._id,self._queue.push({event:"play",action:function(){self.play(soundId)}}),soundId):(id&&!sound._paused?self._loadQueue("play"):(Howler._autoResume(),sound._sprite=sprite,sound._ended=!1,"running"===Howler.state&&"interrupted"!==Howler.ctx.state?self.playSoundInternal(sound):(self._playLock=!0,self._onResumeSound=sound,self._onResume=self.boundPlaySoundAfterResume)),sound._id)):null},_loadQueue:function(event){var task;return 0<this._queue.length&&((task=this._queue[0]).event===event&&(this._queue.shift(),this._loadQueue()),event||task.action()),this},_ended:function(sound){return sound._paused=!0,sound._ended=!0,this._cleanBuffer(sound._node),Howler._autoSuspend(),this},_soundById:function(id){for(var i=0;i<this._sounds.length;i++)if(id===this._sounds[i]._id)return this._sounds[i];return null},_inactiveSound:function(){this._drain();for(var i=0;i<this._sounds.length;i++)if(this._sounds[i]._ended)return this._sounds[i].reset();return new Sound(this)},_drain:function(){var limit=this._pool,cnt=0,i=0;if(!(this._sounds.length<limit)){for(i=0;i<this._sounds.length;i++)this._sounds[i]._ended&&cnt++;for(i=this._sounds.length-1;0<=i;i--){if(cnt<=limit)return;this._sounds[i]._ended&&(this._sounds[i]._node&&this._sounds[i]._node.disconnect(0),this._sounds.splice(i,1),cnt--)}}},_refreshBuffer:function(sound){return sound._node.bufferSource=Howler.ctx.createBufferSource(),sound._node.bufferSource.buffer=cache[this._src],sound._node.bufferSource.connect(sound._node),sound._node.bufferSource.playbackRate.setValueAtTime(1,Howler.ctx.currentTime),this},_cleanBuffer:function(node){var isIOS=0<=navigator.vendor.indexOf("Apple");if(node.bufferSource){if(Howler._scratchBuffer&&node.bufferSource&&(node.bufferSource.onended=null,node.bufferSource.disconnect(0),isIOS))try{node.bufferSource.buffer=Howler._scratchBuffer}catch(e){}node.bufferSource=null}return this}},_exports.default=Howl});