1 line
35 KiB
JavaScript
1 line
35 KiB
JavaScript
|
(()=>{var e,n;e=t=>{!function(){"use strict";function e(){this.init()}function n(e){e.src&&0!==e.src.length?this.init(e):console.error("An array of source files must be passed with any new Howl.")}e.prototype={init:function(){var e=this||v;return e._counter=1e3,e._html5AudioPool=[],e.html5PoolSize=10,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator=typeof window<"u"&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.autoUnlock=!0,e._setup(),e},volume:function(e){var n=this||v;if(e=parseFloat(e),n.ctx||l(),typeof e<"u"&&0<=e&&e<=1){if(n._volume=e,!n._muted){n.usingWebAudio&&n.masterGain.gain.setValueAtTime(e,v.ctx.currentTime);for(var t=0;t<n._howls.length;t++)if(!n._howls[t]._webAudio)for(var o=n._howls[t]._getSoundIds(),r=0;r<o.length;r++){var a=n._howls[t]._soundById(o[r]);a&&a._node&&(a._node.volume=a._volume*e)}}return n}return n._volume},mute:function(e){var n=this||v;n.ctx||l(),n._muted=e,n.usingWebAudio&&n.masterGain.gain.setValueAtTime(e?0:n._volume,v.ctx.currentTime);for(var t=0;t<n._howls.length;t++)if(!n._howls[t]._webAudio)for(var o=n._howls[t]._getSoundIds(),r=0;r<o.length;r++){var a=n._howls[t]._soundById(o[r]);a&&a._node&&(a._node.muted=!!e||a._muted)}return n},stop:function(){for(var e=this||v,n=0;n<e._howls.length;n++)e._howls[n].stop();return e},unload:function(){for(var e=this||v,n=e._howls.length-1;0<=n;n--)e._howls[n].unload();return e.usingWebAudio&&e.ctx&&typeof e.ctx.close<"u"&&(e.ctx.close(),e.ctx=null,l()),e},codecs:function(e){return(this||v)._codecs[e.replace(/^x-/,"")]},_setup:function(){var e=this||v;if(e.state=e.ctx&&e.ctx.state||"suspended",e._autoSuspend(),!e.usingWebAudio)if(typeof Audio<"u")try{"u"<typeof(new Audio).oncanplaythrough&&(e._canPlayEvent="canplay")}catch{e.noAudio=!0}else e.noAudio=!0;try{(new Audio).muted&&(e.noAudio=!0)}catch{}return e.noAudio||e._setupCodecs(),e},_setupCodecs:function(){var e,n,t,o,r=this||v,a=null;try{a=typeof Audio<"u"?new Audio:null}catch{return r}return a&&"function"==typeof a.canPlayType&&(e=a.canPlayType("audio/mpeg;").replace(/^no$/,""),n=(n=(t=r._navigator?r._navigator.userAgent:"").match(/OPR\/(\d+)/g))&&parseInt(n[0].split("/")[1],10)<33,o=-1!==t.indexOf("Safari")&&-1===t.indexOf("Chrome"),t=t.match(/Version\/(.*?) /),o=o&&t&&parseInt(t[1],10)<15,r._codecs={mp3:!(n||!e&&!a.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!e,opus:!!a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(a.canPlayType('audio/wav; codecs="1"')||a.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!a.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!a.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(a.canPlayType("audio/x-m4b;")||a.canPlayType("audio/m4b;")||a.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(a.canPlayType("audio/x-mp4;")||a.canPlayType("audio/mp4;")||a.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(o||!a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(o||!a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!a.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(a.canPlayType("audio/x-flac;")||a.canPlayType("audio/flac;")).replace(/^no$/,"")}),r},_unlockAudio:function(){var u,s=this||v;if(!s._audioUnlocked&&s.ctx)return s._audioUnlocked=!1,s.autoUnlock=!1,s._mobileUnloaded||44100===s.ctx.sampleRate||(s._mobileUnloaded=!0,s.unload()),s._scratchBuffer=s.ctx.createBuffer(1,1,22050),u=function(e){for(;s._html5AudioPool.length<s.html5PoolSize;)try{var n=new Audio;n._unlocked=!0,s._releaseHtml5Audio(n)}catch{s.noAudio=!0;break}for(var t=0;t<s._howls.length;t++)if(!s._howls[t]._webAudio)for(var o=s._howls[t]._getSoundIds(),r=0;r<o.length;r++){var a=s._howls[t]._soundById(o[r]);a&&a._node&&!a._node._unlocked&&(
|