Comparing version 1.0.10-beta.9 to 1.0.10-beta.10
@@ -1,5 +0,6 @@ | ||
var K=Object.defineProperty;var V=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var I=(s,e,t)=>e in s?K(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,R=(s,e)=>{for(var t in e||(e={}))oe.call(e,t)&&I(s,t,e[t]);if(V)for(var t of V(e))le.call(e,t)&&I(s,t,e[t]);return s};var o=(s,e)=>K(s,"name",{value:e,configurable:!0});var u=(s,e,t)=>I(s,typeof e!="symbol"?e+"":e,t);var p=(s,e,t)=>new Promise((a,i)=>{var r=A=>{try{h(t.next(A));}catch(m){i(m);}},c=A=>{try{h(t.throw(A));}catch(m){i(m);}},h=A=>A.done?a(A.value):Promise.resolve(A.value).then(r,c);h((t=t.apply(s,e)).next());});var Y=[{frequency:31,type:"lowshelf",gain:0},{frequency:63,type:"peaking",gain:0},{frequency:125,type:"peaking",gain:0},{frequency:250,type:"peaking",gain:0},{frequency:500,type:"peaking",gain:0},{frequency:1e3,type:"peaking",gain:0},{frequency:2e3,type:"peaking",gain:0},{frequency:4e3,type:"peaking",gain:0},{frequency:8e3,type:"peaking",gain:0},{frequency:16e3,type:"highshelf",gain:0}],F=[{name:"Default",id:"default",default:!0,gains:[0,0,0,0,0,0,0,0,0,0]},{name:"Club",id:"club",default:!0,gains:[0,0,4.8,3.36,3.36,3.36,1.92,0,0,0]},{name:"Live",id:"live",default:!0,gains:[-2.88,0,2.4,3.36,3.36,3.36,2.4,1.44,1.44,1.44]},{name:"Party",id:"Party",default:!0,gains:[4.32,4.32,0,0,0,0,0,0,4.32,4.32]},{name:"Pop",id:"pop",default:!0,gains:[.96,2.88,4.32,4.8,3.36,0,-1.44,-1.44,.96,.96]},{name:"Soft",id:"soft",default:!0,gains:[2.88,.96,0,-1.44,0,2.4,4.8,5.76,6.72,7.2]},{name:"Ska",id:"ska",default:!0,gains:[-1.44,-2.88,-2.4,0,2.4,3.36,5.28,5.76,6.72,5.76]},{name:"Reggae",id:"reggae",default:!0,gains:[0,0,0,-3.36,0,3.84,3.84,0,0,0]},{name:"Rock",id:"rock",default:!0,gains:[4.8,2.88,-3.36,-4.8,-1.92,2.4,5.28,6.72,6.72,6.72]},{name:"Dance",id:"dance",default:!0,gains:[5.76,4.32,1.44,0,0,-3.36,-4.32,-4.32,0,0]},{name:"Techno",id:"techno",default:!0,gains:[4.8,3.36,0,-3.36,-2.88,0,4.8,5.76,5.76,5.28]},{name:"Headphones",id:"headphones",default:!0,gains:[2.88,6.72,3.36,-1.92,-1.44,.96,2.88,5.76,7.68,8.64]},{name:"Soft rock",id:"soft_rock",default:!0,gains:[2.4,2.4,1.44,0,-2.4,-3.36,-1.92,0,1.44,5.28]},{name:"Classical",id:"classical",default:!0,gains:[0,0,0,0,0,0,-4.32,-4.32,-4.32,-5.76]},{name:"Large Hall",id:"large_hall",default:!0,gains:[6.24,6.24,3.36,3.36,0,-2.88,-2.88,-2.88,0,0]},{name:"Full Bass",id:"full_base",default:!0,gains:[4.8,5.76,5.76,3.36,.96,-2.4,-4.8,-6.24,-6.72,-6.72]},{name:"Full Treble",id:"full_treble",default:!0,gains:[-5.76,-5.76,-5.76,-2.4,1.44,6.72,9.6,9.6,9.6,10.08]},{name:"Laptop Speakers",id:"laptop_speakers",default:!0,gains:[2.88,6.72,3.36,-1.92,-1.44,.96,2.88,5.76,7.68,8.64]},{name:"Full Bass & Treble",id:"bass_treble",default:!0,gains:[4.32,3.36,0,-4.32,-2.88,.96,4.8,6.72,7.2,7.2]}];var k=Object.freeze({REACT:"REACT",VANILLA:"VANILLA",DEVELOPMENT:"development"}),l=Object.freeze({BUFFERING:"buffering",PLAYING:"playing",PAUSED:"paused",READY:"ready",IDLE:"idle",ENDED:"ended",STALLED:"stalled",ERROR:"error",TRACK_CHANGE:"trackchanged",DURATION_CHANGE:"durationchanged",QUEUE_ENDED:"queueended"}),b=Object.freeze({MEDIA_ERR_ABORTED:"The user canceled the audio.",MEDIA_ERR_DECODE:"An error occurred while decoding the audio.",MEDIA_ERR_NETWORK:"A network error occurred while fetching the audio.",MEDIA_ERR_SRC_NOT_SUPPORTED:"The audio is missing or is in a format not supported by your browser.",DEFAULT:"An unknown error occurred."}),Q={HLS:"https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.11/hls.min.js",CAST:"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"};var E,ue=(E=class{static validateEventName(e){if(!e||typeof e!="string")throw new Error("Invalid event name")}static notify(e,t,a="audiox_notifier_default"){this.validateEventName(e);let i=E.listeners[e];i&&t!==null&&(E.notifierState[e]=R(R({},E.notifierState[e]||{}),t),i.forEach(r=>{r(E.notifierState[e]);}));}static listen(e,t,a={}){if(this.validateEventName(e),typeof t!="function")throw new Error("Callback must be a function");return E.listeners[e]?E.listeners[e].add(t):(E.notifierState[e]=a,E.listeners[e]=new Set([t])),()=>{let i=E.listeners[e];i&&(i.delete(t),i.size===0&&delete E.listeners[e]);}}static multiListen(e,t,a={}){if(this.validateEventName(e),!Array.isArray(t)||t.length===0)throw new Error("Callbacks must be a non-empty array of functions");let i=t.map(r=>E.listen(e,r,a));return ()=>{i.forEach(r=>r());}}static getLatestState(e){return this.validateEventName(e),E.notifierState[e]}},o(E,"ChangeNotifier"),u(E,"listeners",{}),u(E,"notifierState",{}),E),f=ue;var _=o(s=>s&&Array.isArray(s)&&s.length,"isValidArray"),X=o(s=>s instanceof Function&&typeof s=="function","isValidFunction");var z={},j=o(s=>{let e="",t=s.error;switch(t==null?void 0:t.code){case MediaError.MEDIA_ERR_ABORTED:e+=b.MEDIA_ERR_ABORTED;break;case MediaError.MEDIA_ERR_NETWORK:e+=b.MEDIA_ERR_NETWORK;break;case MediaError.MEDIA_ERR_DECODE:e+=b.MEDIA_ERR_DECODE;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:e+=b.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:e+=b.DEFAULT;break}return e},"getReadableErrorMessage"),$=o(s=>{var m;let{title:e,album:t,artist:a,artwork:i}=s,r=i?(m=i[0])==null?void 0:m.src:"",h=["96x96","128x128","192x192","256x256","384x384","512x512"].map(P=>({src:r,sizes:P,type:"image/png"}));return {title:e,album:t,artist:a,artwork:h}},"metaDataCreator"),x=0,L=o((s,e)=>{let t=new Set;for(let r=0;r<s.played.length;r++){let c=s.played.start(r),A=s.played.end(r)-c;t.add(A);}let i=[...t].reduce((r,c)=>r+c,0);x=["ENDED","TRACK_CHANGE","PAUSE"].includes(e)?i:x,f.notify("AUDIO_STATE",{currentTrackPlayTime:i,previousTrackPlayTime:x});},"calculateActualPlayedLength"),W=o((s,e,t)=>new Promise((a,i)=>{if(window instanceof Window&&window.document)if(z[t])e(),a();else {z[t]=!0;let r=document.createElement("script");r.type="text/javascript",r.src=s,r.async=!0,r.onload=()=>{e(),a();},document.head.appendChild(r);}else i(`Window not ready unable to initialize ${t}`);}),"loadScript"),J=o(()=>{let s=new T,e=!1,t=o(a=>{if(a.playbackState==="ended"&&!e){let i=s.getQueue();e=!0,i&&_(i)&&e&&s.playNext();}a.playbackState!=="ended"&&(e=!1);},"audioStateListener");f.listen("AUDIO_STATE",t);},"handleQueuePlayback"),y=o(s=>{let{buffered:e}=s,t=0;for(let a=0;a<e.length;a++)t+=e.end(a)-e.start(a);return t},"getBufferedDuration"),Z=o(s=>{let e=[...s];for(let t=e.length-1;t>0;t--){let a=Math.floor(Math.random()*t);[e[t],e[a]]=[e[a],e[t]];}return e},"shuffle"),N=o((s,e)=>{if(s===null&&e===null)return !0;if(s===null||e===null||typeof s!=typeof e)return !1;if(typeof s!="object")return s===e;if(Array.isArray(s)&&Array.isArray(e))return s.length!==e.length?!1:s.every((i,r)=>N(i,e[r]));let t=Object.keys(s),a=Object.keys(e);return t.length!==a.length?!1:t.every(i=>a.includes(i)?N(s[i],e[i]):!1)},"diffChecker");var g,H=(g=class{constructor(){u(this,"audioCtx");u(this,"audioCtxStatus");u(this,"eqFilterBands");u(this,"bassBoostFilter");if(g._instance)return g._instance;this.initializeAudioContext(),g._instance=this;}initializeAudioContext(){let e={latencyHint:"playback",sampleRate:44100};typeof AudioContext!="undefined"?this.audioCtx=new AudioContext(e):typeof window.webkitAudioContext!="undefined"&&(this.audioCtx=new window.webkitAudioContext(e)),this.audioCtxStatus="ACTIVE",this.init(),this.audioCtx.state==="suspended"&&this.addResumeListener();}addResumeListener(){let e=o(()=>{this.audioCtx.resume(),setTimeout(()=>{this.audioCtx.state==="running"&&document.body.removeEventListener("click",e,!1);},0);},"resume");document.body.addEventListener("click",e,!1);}init(){try{let e=T.getAudioInstance(),t=this.audioCtx.createMediaElementSource(e),a=Y.map(r=>{let c=this.audioCtx.createBiquadFilter();return c.type=r.type,c.frequency.value=r.frequency,c.gain.value=r.gain,c.Q.value=1,c}),i=this.audioCtx.createGain();i.gain.value=1,this.bassBoostFilter=this.audioCtx.createBiquadFilter(),this.bassBoostFilter.type="lowshelf",this.bassBoostFilter.frequency.value=80,this.bassBoostFilter.gain.value=0,t.connect(a[0]);for(let r=0;r<a.length-1;r++)a[r].connect(a[r+1]);a[a.length-1].connect(this.bassBoostFilter),this.bassBoostFilter.connect(i),i.connect(this.audioCtx.destination),this.audioCtxStatus="ACTIVE",this.eqFilterBands=a;}catch(e){this.audioCtxStatus="FAILED";}}setPreset(e){let t=F.find(i=>i.id===e);if(!t||!this.eqFilterBands||this.eqFilterBands.length!==t.gains.length)return;let a=this.audioCtx.currentTime;this.eqFilterBands.forEach((i,r)=>{let c=t.gains[r];i.gain.linearRampToValueAtTime(c,a+.015);});}static getPresets(){return F}status(){return this.audioCtx.state==="suspended"&&this.audioCtx.resume(),this.audioCtxStatus}setCustomEQ(e){if(_(e)){let t=this.audioCtx.currentTime;this.eqFilterBands.forEach((a,i)=>{a.gain.linearRampToValueAtTime(e[i],t+.015);});}}setBassBoost(e,t=6){let a=this.audioCtx.currentTime;e?this.bassBoostFilter.gain.linearRampToValueAtTime(t,a+.015):this.bassBoostFilter.gain.linearRampToValueAtTime(0,a+.015);}},o(g,"Equalizer"),u(g,"_instance"),g);var ee={ERROR:o((s,e)=>{let t=e.type,a=e.details,i=e.fatal;f.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{type:t,isFatal:i,detail:a}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),FRAG_CHANGED:o(()=>{},"FRAG_CHANGED")};var w=Object.freeze({ABORT:"abort",TIME_UPDATE:"timeupdate",CAN_PLAY:"canplay",CAN_PLAY_THROUGH:"canplaythrough",DURATION_CHANGE:"durationchange",ENDED:"ended",EMPTIED:"emptied",PLAYING:"playing",WAITING:"waiting",SEEKING:"seeking",SEEKED:"seeked",LOADED_META_DATA:"loadedmetadata",LOADED_DATA:"loadeddata",PLAY:"play",PAUSE:"pause",RATE_CHANGE:"ratechange",VOLUME_CHANGE:"volumechange",SUSPEND:"suspend",STALLED:"stalled",PROGRESS:"progress",LOAD_START:"loadstart",ERROR:"error",TRACK_CHANGE:"trackchange",QUEUE_ENDED:"queueended"}),te={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVELS_UPDATED:"hlsLevelsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACKS_CLEARED:"hlsSubtitleTracksCleared",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",CUES_PARSED:"hlsCuesParsed",NON_NATIVE_TEXT_TRACKS_FOUND:"hlsNonNativeTextTracksFound",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached",BACK_BUFFER_REACHED:"hlsBackBufferReached"};var v=o((s,e=!1)=>{let t=T.getAudioInstance();_(Object.keys(s))&&Object.keys(s).forEach(a=>{let i=a;t==null||t.addEventListener(w[i],r=>{if(a&&s[i]){let c=s[i];typeof c=="function"&&c(r,t,e);}});});},"attachEventListeners");var se=o((s,e=!1)=>{let a=new O().getHlsInstance();_(Object.keys(s))&&Object.keys(s).forEach(i=>{let r=i;a.on(te[r],(c,h)=>{if(r&&s[r]){let A=s[r];typeof A=="function"&&A(c,h,a,e);}});});},"attachHlsEventsListeners");var C,S,ce=(S=class{constructor(){u(this,"HlsClass");if(S._instance)return S._instance;S._instance=this;}load(){return p(this,null,function*(){return yield W(Q.HLS,()=>{},"hls").then(()=>{this.HlsClass=window.Hls,window.Hls=void 0;}).catch(e=>{}),this.HlsClass})}init(){return p(this,arguments,function*(e={},t){let a=yield this.load();a.isSupported()&&(C=new a(e),se(ee,t));})}addHlsMedia(e){let t=this.HlsClass,a=T.getAudioInstance();C.loadSource(e.source),C.attachMedia(a),C.on(t.Events.MEDIA_ATTACHED,function(){});}getHlsInstance(){return C}},o(S,"HlsAdapter"),u(S,"_instance"),S),O=ce;var ae=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var d=f,ie={LOAD_START:o((s,e)=>{let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOAD_START"),DURATION_CHANGE:o((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="playing"?l.PLAYING:l.DURATION_CHANGE,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"DURATION_CHANGE"),LOADED_META_DATA:o((s,e)=>{let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOADED_META_DATA"),LOADED_DATA:o((s,e)=>{let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOADED_DATA"),CAN_PLAY:o((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?l.PAUSED:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"CAN_PLAY"),CAN_PLAY_THROUGH:o((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=e.paused,i=y(e);d.notify("AUDIO_STATE",{playbackState:a?l.PAUSED:t.playbackState==="playing"?l.PLAYING:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:i},`audiox_baseEvents_state_${s.type}`);},"CAN_PLAY_THROUGH"),PLAY:o((s,e)=>{d.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"PLAY"),PLAYING:o((s,e)=>{d.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"PLAYING"),PAUSE:o((s,e,t)=>{d.notify("AUDIO_STATE",{playbackState:l.PAUSED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&L(e,"PAUSE");},"PAUSE"),ENDED:o((s,e,t)=>{d.notify("AUDIO_STATE",{playbackState:l.ENDED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&L(e,"ENDED");},"ENDED"),ERROR:o((s,e)=>{var i;let t=(i=e.error)==null?void 0:i.code,a=j(e);d.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{code:t,message:ae[t],readable:a}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),TIME_UPDATE:o((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:e.paused?t==null?void 0:t.playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"TIME_UPDATE"),WAITING:o((s,e)=>{d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"WAITING"),VOLUME_CHANGE:o(s=>{d.notify("AUDIO_STATE",{},"audiox_baseEvents_state");},"VOLUME_CHANGE"),SEEKED:o((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?"paused":t.playbackState,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"SEEKED")};var re=o(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata($(s)));},"updateMetaData"),B=o(()=>{let s=new T;"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",()=>{T.getAudioInstance().play();}),navigator.mediaSession.setActionHandler("pause",()=>{T.getAudioInstance().pause();}),s.getQueue().length&&(navigator.mediaSession.setActionHandler("previoustrack",()=>{s.playPrevious();}),navigator.mediaSession.setActionHandler("nexttrack",()=>{s.playNext();})));},"attachMediaSessionHandlers");var G={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},q={playbackState:l.IDLE,duration:0,bufferedDuration:0,progress:0,volume:50,playbackRate:1,error:{code:null,message:"",readable:""},currentTrack:{},currentTrackPlayTime:0,previousTrackPlayTime:0};f.listen("AUDIO_STATE",s=>{let e=f.getLatestState("AUDIO_X_STATE");N(e,s)||f.notify("AUDIO_X_STATE",R(R({},q),s));},q);var n,U=f,D,T=(D=class{constructor(){u(this,"_audio");u(this,"isPlayLogEnabled");u(this,"_queue");u(this,"_currentQueueIndex",0);u(this,"_fetchFn");u(this,"eqStatus","IDEAL");u(this,"isEqEnabled",!1);u(this,"eqInstance");u(this,"showNotificationsActions",!1);var e;if(D._instance)return D._instance;if(process.env.NODE_ENV!==((e=k)==null?void 0:e.DEVELOPMENT)&&n)throw new Error("Cannot create multiple audio instance");D._instance=this,this._audio=new Audio,n=this._audio;}init(e){return p(this,null,function*(){var M;let{preloadStrategy:t="auto",autoPlay:a=!1,useDefaultEventListeners:i=!0,customEventListeners:r=null,showNotificationActions:c=!1,enablePlayLog:h=!1,enableHls:A=!1,enableEQ:m=!1,crossOrigin:P="anonymous",hlsConfig:ne={}}=e;(M=this._audio)==null||M.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=a,this._audio.crossOrigin=P,this.isPlayLogEnabled=h,this.isEqEnabled=m,r!==null?v(r,!1):v(ie,h),c&&(this.showNotificationsActions=!0,B()),A&&new O().init(ne,h);})}addMedia(e){return p(this,null,function*(){if(!e)return;let t=this.getQueue();if(_(t)){let i=t.findIndex(r=>e.id===r.id);i>-1&&(this._currentQueueIndex=i);}let a=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&L(n,"TRACK_CHANGE"),a==="HLS"){let i=new O,r=i.getHlsInstance();r?(r.detachMedia(),i.addHlsMedia(e)):yield this.reset();}else n.src=e.source;U.notify("AUDIO_STATE",{playbackState:l.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),re(e),n.load();})}attachEq(){if(this.eqStatus==="IDEAL")try{let e=new H;this.eqStatus=e.status(),this.eqInstance=e;}catch(e){}}play(){return p(this,null,function*(){let e=n.src!=="";n!=null&&n.paused&&n.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&e&&(yield n.play().then(()=>{}).catch(()=>{})),this.isEqEnabled&&this.attachEq();})}addMediaAndPlay(e,t){return p(this,null,function*(){let a=e||(this._queue.length>0?this._queue[0]:void 0);t&&X(t)&&a&&(this._fetchFn=t,yield t(a));try{a&&this.addMedia(a).then(()=>{n.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&setTimeout(()=>p(this,null,function*(){yield this.play(),this.isEqEnabled&&this.attachEq();}),950);});}catch(i){}})}pause(){n&&!(n!=null&&n.paused)&&(n==null||n.pause());}stop(){n&&!n.paused&&(n==null||n.pause(),n.currentTime=0);}reset(){return p(this,null,function*(){n&&(this.stop(),n.src="",n.srcObject=null);})}setVolume(e){let t=e/100;n&&(n.volume=t,U.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){n&&(n.playbackRate=e,U.notify("AUDIO_STATE",{playbackRate:e}));}mute(){n&&!n.muted&&(n.muted=!0);}seek(e){n&&(n.currentTime=e);}seekBy(e){if(n&&n.currentTime){let t=n.currentTime;n.currentTime=t+e;}}destroy(){return p(this,null,function*(){n&&(yield this.reset(),n.removeAttribute("src"),n.load());})}subscribe(e,t,a={}){return U.listen(e,t,a)}addEventListener(e,t){n.addEventListener(e,t);}getPresets(){return H.getPresets()}setPreset(e){this.isEqEnabled&&this.eqInstance.setPreset(e);}setCustomEQ(e){this.isEqEnabled&&this.eqInstance.setCustomEQ(e);}setBassBoost(e,t){this.isEqEnabled&&this.eqInstance.setBassBoost(e,t);}addQueue(e,t){this.clearQueue();let a=_(e)?e.slice():[];switch(t){case"DEFAULT":this._queue=a;break;case"REVERSE":this._queue=a.reverse();break;case"SHUFFLE":this._queue=Z(a);break;default:this._queue=a;break}J(),this.showNotificationsActions&&B();}playNext(){let e=this._currentQueueIndex+1;if(this._queue.length>e){let t=this._queue[e];this.addMediaAndPlay(t,this._fetchFn),this._currentQueueIndex=e;}else this.stop(),U.notify("AUDIO_STATE",{playbackState:l.QUEUE_ENDED});}playPrevious(){let e=this._currentQueueIndex-1;if(e>0){let t=this._queue[e];this.addMediaAndPlay(t,this._fetchFn),this._currentQueueIndex=e;}}clearQueue(){this._queue&&_(this._queue)&&(this._queue=[],this._currentQueueIndex=0);}addToQueue(e){this._queue&&_(this._queue)&&(Array.isArray(e)?this._queue=[...this._queue,...e]:this._queue.push(e));}removeFromQueue(e){if(this._queue&&_(this._queue)){let t=this._queue.filter(a=>a.id==e.id);this._queue=t;}}getQueue(){return this._queue&&_(this._queue)?this._queue:[]}get id(){return n==null?void 0:n.getAttribute("id")}static getAudioInstance(){return n}},o(D,"AudioX"),u(D,"_instance"),D); | ||
var K=Object.defineProperty;var V=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var I=(s,e,t)=>e in s?K(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,R=(s,e)=>{for(var t in e||(e={}))ne.call(e,t)&&I(s,t,e[t]);if(V)for(var t of V(e))le.call(e,t)&&I(s,t,e[t]);return s};var n=(s,e)=>K(s,"name",{value:e,configurable:!0});var u=(s,e,t)=>I(s,typeof e!="symbol"?e+"":e,t);var p=(s,e,t)=>new Promise((a,i)=>{var r=A=>{try{h(t.next(A));}catch(m){i(m);}},c=A=>{try{h(t.throw(A));}catch(m){i(m);}},h=A=>A.done?a(A.value):Promise.resolve(A.value).then(r,c);h((t=t.apply(s,e)).next());});var Y=[{frequency:31,type:"lowshelf",gain:0},{frequency:63,type:"peaking",gain:0},{frequency:125,type:"peaking",gain:0},{frequency:250,type:"peaking",gain:0},{frequency:500,type:"peaking",gain:0},{frequency:1e3,type:"peaking",gain:0},{frequency:2e3,type:"peaking",gain:0},{frequency:4e3,type:"peaking",gain:0},{frequency:8e3,type:"peaking",gain:0},{frequency:16e3,type:"highshelf",gain:0}],F=[{name:"Default",id:"default",default:!0,gains:[0,0,0,0,0,0,0,0,0,0]},{name:"Club",id:"club",default:!0,gains:[0,0,4.8,3.36,3.36,3.36,1.92,0,0,0]},{name:"Live",id:"live",default:!0,gains:[-2.88,0,2.4,3.36,3.36,3.36,2.4,1.44,1.44,1.44]},{name:"Party",id:"Party",default:!0,gains:[4.32,4.32,0,0,0,0,0,0,4.32,4.32]},{name:"Pop",id:"pop",default:!0,gains:[.96,2.88,4.32,4.8,3.36,0,-1.44,-1.44,.96,.96]},{name:"Soft",id:"soft",default:!0,gains:[2.88,.96,0,-1.44,0,2.4,4.8,5.76,6.72,7.2]},{name:"Ska",id:"ska",default:!0,gains:[-1.44,-2.88,-2.4,0,2.4,3.36,5.28,5.76,6.72,5.76]},{name:"Reggae",id:"reggae",default:!0,gains:[0,0,0,-3.36,0,3.84,3.84,0,0,0]},{name:"Rock",id:"rock",default:!0,gains:[4.8,2.88,-3.36,-4.8,-1.92,2.4,5.28,6.72,6.72,6.72]},{name:"Dance",id:"dance",default:!0,gains:[5.76,4.32,1.44,0,0,-3.36,-4.32,-4.32,0,0]},{name:"Techno",id:"techno",default:!0,gains:[4.8,3.36,0,-3.36,-2.88,0,4.8,5.76,5.76,5.28]},{name:"Headphones",id:"headphones",default:!0,gains:[2.88,6.72,3.36,-1.92,-1.44,.96,2.88,5.76,7.68,8.64]},{name:"Soft rock",id:"soft_rock",default:!0,gains:[2.4,2.4,1.44,0,-2.4,-3.36,-1.92,0,1.44,5.28]},{name:"Classical",id:"classical",default:!0,gains:[0,0,0,0,0,0,-4.32,-4.32,-4.32,-5.76]},{name:"Large Hall",id:"large_hall",default:!0,gains:[6.24,6.24,3.36,3.36,0,-2.88,-2.88,-2.88,0,0]},{name:"Full Bass",id:"full_base",default:!0,gains:[4.8,5.76,5.76,3.36,.96,-2.4,-4.8,-6.24,-6.72,-6.72]},{name:"Full Treble",id:"full_treble",default:!0,gains:[-5.76,-5.76,-5.76,-2.4,1.44,6.72,9.6,9.6,9.6,10.08]},{name:"Laptop Speakers",id:"laptop_speakers",default:!0,gains:[2.88,6.72,3.36,-1.92,-1.44,.96,2.88,5.76,7.68,8.64]},{name:"Full Bass & Treble",id:"bass_treble",default:!0,gains:[4.32,3.36,0,-4.32,-2.88,.96,4.8,6.72,7.2,7.2]}];var k=Object.freeze({REACT:"REACT",VANILLA:"VANILLA",DEVELOPMENT:"development"}),l=Object.freeze({BUFFERING:"buffering",PLAYING:"playing",PAUSED:"paused",READY:"ready",IDLE:"idle",ENDED:"ended",STALLED:"stalled",ERROR:"error",TRACK_CHANGE:"trackchanged",DURATION_CHANGE:"durationchanged",QUEUE_ENDED:"queueended"}),b=Object.freeze({MEDIA_ERR_ABORTED:"The user canceled the audio.",MEDIA_ERR_DECODE:"An error occurred while decoding the audio.",MEDIA_ERR_NETWORK:"A network error occurred while fetching the audio.",MEDIA_ERR_SRC_NOT_SUPPORTED:"The audio is missing or is in a format not supported by your browser.",DEFAULT:"An unknown error occurred."}),Q={HLS:"https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.11/hls.min.js",CAST:"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"};var E,ue=(E=class{static validateEventName(e){if(!e||typeof e!="string")throw new Error("Invalid event name")}static notify(e,t,a="audiox_notifier_default"){this.validateEventName(e);let i=E.listeners[e];i&&t!==null&&(console.log(`NOTIFYING TO EVENT : ${e} - CALLER : ${a}`),E.notifierState[e]=R(R({},E.notifierState[e]||{}),t),i.forEach(r=>{r(E.notifierState[e]);}));}static listen(e,t,a={}){if(this.validateEventName(e),typeof t!="function")throw new Error("Callback must be a function");return E.listeners[e]?E.listeners[e].add(t):(E.notifierState[e]=a,E.listeners[e]=new Set([t])),()=>{let i=E.listeners[e];if(!i){console.log(`EVENT NOT FOUND : ${e}`);return}console.log(`REMOVING EVENT LISTENER FOR EVENT : ${e}`),i.delete(t),i.size===0&&delete E.listeners[e];}}static multiListen(e,t,a={}){if(this.validateEventName(e),!Array.isArray(t)||t.length===0)throw new Error("Callbacks must be a non-empty array of functions");let i=t.map(r=>E.listen(e,r,a));return ()=>{i.forEach(r=>r());}}static getLatestState(e){return this.validateEventName(e),E.notifierState[e]}},n(E,"ChangeNotifier"),u(E,"listeners",{}),u(E,"notifierState",{}),E),f=ue;var _=n(s=>s&&Array.isArray(s)&&s.length,"isValidArray"),X=n(s=>s instanceof Function&&typeof s=="function","isValidFunction");var z={},j=n(s=>{let e="",t=s.error;switch(t==null?void 0:t.code){case MediaError.MEDIA_ERR_ABORTED:e+=b.MEDIA_ERR_ABORTED;break;case MediaError.MEDIA_ERR_NETWORK:e+=b.MEDIA_ERR_NETWORK;break;case MediaError.MEDIA_ERR_DECODE:e+=b.MEDIA_ERR_DECODE;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:e+=b.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:e+=b.DEFAULT;break}return e},"getReadableErrorMessage"),$=n(s=>{var m;let{title:e,album:t,artist:a,artwork:i}=s,r=i?(m=i[0])==null?void 0:m.src:"",h=["96x96","128x128","192x192","256x256","384x384","512x512"].map(P=>({src:r,sizes:P,type:"image/png"}));return {title:e,album:t,artist:a,artwork:h}},"metaDataCreator"),x=0,L=n((s,e)=>{let t=new Set;for(let r=0;r<s.played.length;r++){let c=s.played.start(r),A=s.played.end(r)-c;t.add(A);}let i=[...t].reduce((r,c)=>r+c,0);x=["ENDED","TRACK_CHANGE","PAUSE"].includes(e)?i:x,f.notify("AUDIO_STATE",{currentTrackPlayTime:i,previousTrackPlayTime:x});},"calculateActualPlayedLength"),W=n((s,e,t)=>new Promise((a,i)=>{if(window instanceof Window&&window.document)if(z[t])e(),a();else {z[t]=!0;let r=document.createElement("script");r.type="text/javascript",r.src=s,r.async=!0,r.onload=()=>{e(),a();},document.head.appendChild(r);}else i(`Window not ready unable to initialize ${t}`);}),"loadScript"),J=n(()=>{let s=new T,e=!1,t=n(a=>{if(a.playbackState==="ended"&&!e){let i=s.getQueue();e=!0,i&&_(i)&&e&&s.playNext();}a.playbackState!=="ended"&&(e=!1);},"audioStateListener");f.listen("AUDIO_STATE",t);},"handleQueuePlayback"),y=n(s=>{let{buffered:e}=s,t=0;for(let a=0;a<e.length;a++)t+=e.end(a)-e.start(a);return t},"getBufferedDuration"),Z=n(s=>{let e=[...s];for(let t=e.length-1;t>0;t--){let a=Math.floor(Math.random()*t);[e[t],e[a]]=[e[a],e[t]];}return e},"shuffle"),N=n((s,e)=>{if(s===null&&e===null)return !0;if(s===null||e===null||typeof s!=typeof e)return !1;if(typeof s!="object")return s===e;if(Array.isArray(s)&&Array.isArray(e))return s.length!==e.length?!1:s.every((i,r)=>N(i,e[r]));let t=Object.keys(s),a=Object.keys(e);return t.length!==a.length?!1:t.every(i=>a.includes(i)?N(s[i],e[i]):!1)},"diffChecker");var g,H=(g=class{constructor(){u(this,"audioCtx");u(this,"audioCtxStatus");u(this,"eqFilterBands");u(this,"bassBoostFilter");if(g._instance)return console.warn("Instantiation failed: cannot create multiple instances of Equalizer. Returning existing instance."),g._instance;this.initializeAudioContext(),g._instance=this;}initializeAudioContext(){let e={latencyHint:"playback",sampleRate:44100};typeof AudioContext!="undefined"?this.audioCtx=new AudioContext(e):typeof window.webkitAudioContext!="undefined"?this.audioCtx=new window.webkitAudioContext(e):console.error("Web Audio API is not supported in this browser."),this.audioCtxStatus="ACTIVE",this.init(),this.audioCtx.state==="suspended"&&this.addResumeListener();}addResumeListener(){let e=n(()=>{this.audioCtx.resume(),setTimeout(()=>{this.audioCtx.state==="running"&&document.body.removeEventListener("click",e,!1);},0);},"resume");document.body.addEventListener("click",e,!1);}init(){try{let e=T.getAudioInstance(),t=this.audioCtx.createMediaElementSource(e),a=Y.map(r=>{let c=this.audioCtx.createBiquadFilter();return c.type=r.type,c.frequency.value=r.frequency,c.gain.value=r.gain,c.Q.value=1,c}),i=this.audioCtx.createGain();i.gain.value=1,this.bassBoostFilter=this.audioCtx.createBiquadFilter(),this.bassBoostFilter.type="lowshelf",this.bassBoostFilter.frequency.value=80,this.bassBoostFilter.gain.value=0,t.connect(a[0]);for(let r=0;r<a.length-1;r++)a[r].connect(a[r+1]);a[a.length-1].connect(this.bassBoostFilter),this.bassBoostFilter.connect(i),i.connect(this.audioCtx.destination),this.audioCtxStatus="ACTIVE",this.eqFilterBands=a;}catch(e){console.error("Equalizer initialization failed:",e),this.audioCtxStatus="FAILED";}}setPreset(e){let t=F.find(i=>i.id===e);if(!t){console.error("Preset not found:",e);return}if(!this.eqFilterBands||this.eqFilterBands.length!==t.gains.length){console.error("Invalid data provided.");return}let a=this.audioCtx.currentTime;this.eqFilterBands.forEach((i,r)=>{let c=t.gains[r];i.gain.linearRampToValueAtTime(c,a+.015);});}static getPresets(){return F}status(){return this.audioCtx.state==="suspended"&&this.audioCtx.resume(),this.audioCtxStatus}setCustomEQ(e){if(_(e)){let t=this.audioCtx.currentTime;this.eqFilterBands.forEach((a,i)=>{a.gain.linearRampToValueAtTime(e[i],t+.015);});}else console.error("Invalid array of gains provided.");}setBassBoost(e,t=6){let a=this.audioCtx.currentTime;e?this.bassBoostFilter.gain.linearRampToValueAtTime(t,a+.015):this.bassBoostFilter.gain.linearRampToValueAtTime(0,a+.015);}},n(g,"Equalizer"),u(g,"_instance"),g);var ee={ERROR:n((s,e)=>{let t=e.type,a=e.details,i=e.fatal;console.log("STATUS",s.type),f.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{type:t,isFatal:i,detail:a}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),FRAG_CHANGED:n(()=>{console.log("FRAG_CHANGED");},"FRAG_CHANGED")};var w=Object.freeze({ABORT:"abort",TIME_UPDATE:"timeupdate",CAN_PLAY:"canplay",CAN_PLAY_THROUGH:"canplaythrough",DURATION_CHANGE:"durationchange",ENDED:"ended",EMPTIED:"emptied",PLAYING:"playing",WAITING:"waiting",SEEKING:"seeking",SEEKED:"seeked",LOADED_META_DATA:"loadedmetadata",LOADED_DATA:"loadeddata",PLAY:"play",PAUSE:"pause",RATE_CHANGE:"ratechange",VOLUME_CHANGE:"volumechange",SUSPEND:"suspend",STALLED:"stalled",PROGRESS:"progress",LOAD_START:"loadstart",ERROR:"error",TRACK_CHANGE:"trackchange",QUEUE_ENDED:"queueended"}),te={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVELS_UPDATED:"hlsLevelsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACKS_CLEARED:"hlsSubtitleTracksCleared",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",CUES_PARSED:"hlsCuesParsed",NON_NATIVE_TEXT_TRACKS_FOUND:"hlsNonNativeTextTracksFound",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached",BACK_BUFFER_REACHED:"hlsBackBufferReached"};var B=n((s,e=!1)=>{let t=T.getAudioInstance();_(Object.keys(s))&&Object.keys(s).forEach(a=>{let i=a;t==null||t.addEventListener(w[i],r=>{if(a&&s[i]){let c=s[i];typeof c=="function"&&c(r,t,e);}});});},"attachEventListeners");var se=n((s,e=!1)=>{let a=new O().getHlsInstance();_(Object.keys(s))&&Object.keys(s).forEach(i=>{let r=i;a.on(te[r],(c,h)=>{if(r&&s[r]){let A=s[r];typeof A=="function"&&A(c,h,a,e);}});});},"attachHlsEventsListeners");var C,S,ce=(S=class{constructor(){u(this,"HlsClass");if(S._instance)return console.warn("Instantiation failed: cannot create multiple instance of HLS returning existing instance"),S._instance;S._instance=this;}load(){return p(this,null,function*(){return yield W(Q.HLS,()=>{console.log("HLS Loaded");},"hls").then(()=>{this.HlsClass=window.Hls,window.Hls=void 0;}).catch(e=>{console.log(e);}),this.HlsClass})}init(){return p(this,arguments,function*(e={},t){let a=yield this.load();a.isSupported()&&(C=new a(e),se(ee,t));})}addHlsMedia(e){let t=this.HlsClass,a=T.getAudioInstance();C.loadSource(e.source),C.attachMedia(a),C.on(t.Events.MEDIA_ATTACHED,function(){console.log("hls media attached");});}getHlsInstance(){return C}},n(S,"HlsAdapter"),u(S,"_instance"),S),O=ce;var ae=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var d=f,ie={LOAD_START:n((s,e)=>{console.log("STATUS",s.type);let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOAD_START"),DURATION_CHANGE:n((s,e)=>{console.log("STATUS",s.type);let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="playing"?l.PLAYING:l.DURATION_CHANGE,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"DURATION_CHANGE"),LOADED_META_DATA:n((s,e)=>{console.log("STATUS",s.type);let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOADED_META_DATA"),LOADED_DATA:n((s,e)=>{console.log("STATUS",s.type);let t=y(e);d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,duration:e==null?void 0:e.duration,error:{code:null,message:"",readable:""},bufferedDuration:t},`audiox_baseEvents_state_${s.type}`);},"LOADED_DATA"),CAN_PLAY:n((s,e)=>{console.log("STATUS",s.type);let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?l.PAUSED:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"CAN_PLAY"),CAN_PLAY_THROUGH:n((s,e)=>{console.log("STATUS",s.type);let t=d.getLatestState("AUDIO_X_STATE"),a=e.paused,i=y(e);d.notify("AUDIO_STATE",{playbackState:a?l.PAUSED:t.playbackState==="playing"?l.PLAYING:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:i},`audiox_baseEvents_state_${s.type}`);},"CAN_PLAY_THROUGH"),PLAY:n((s,e)=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"PLAY"),PLAYING:n((s,e)=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"PLAYING"),PAUSE:n((s,e,t)=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{playbackState:l.PAUSED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&L(e,"PAUSE");},"PAUSE"),ENDED:n((s,e,t)=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{playbackState:l.ENDED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&L(e,"ENDED");},"ENDED"),ERROR:n((s,e)=>{var i;console.log("STATUS",s.type);let t=(i=e.error)==null?void 0:i.code,a=j(e);d.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{code:t,message:ae[t],readable:a}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),TIME_UPDATE:n((s,e)=>{console.log("STATUS",s.type);let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:e.paused?t==null?void 0:t.playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"TIME_UPDATE"),WAITING:n((s,e)=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{playbackState:l.BUFFERING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},"WAITING"),VOLUME_CHANGE:n(s=>{console.log("STATUS",s.type),d.notify("AUDIO_STATE",{},"audiox_baseEvents_state");},"VOLUME_CHANGE"),SEEKED:n((s,e)=>{let t=d.getLatestState("AUDIO_X_STATE"),a=y(e);d.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?"paused":t.playbackState,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""},bufferedDuration:a},`audiox_baseEvents_state_${s.type}`);},"SEEKED")};var re=n(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata($(s)));},"updateMetaData"),q=n(()=>{let s=new T;"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",()=>{T.getAudioInstance().play();}),navigator.mediaSession.setActionHandler("pause",()=>{T.getAudioInstance().pause();}),s.getQueue().length&&(navigator.mediaSession.setActionHandler("previoustrack",()=>{s.playPrevious();}),navigator.mediaSession.setActionHandler("nexttrack",()=>{s.playNext();})));},"attachMediaSessionHandlers");var G={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},v={playbackState:l.IDLE,duration:0,bufferedDuration:0,progress:0,volume:50,playbackRate:1,error:{code:null,message:"",readable:""},currentTrack:{},currentTrackPlayTime:0,previousTrackPlayTime:0};f.listen("AUDIO_STATE",s=>{let e=f.getLatestState("AUDIO_X_STATE");N(e,s)||f.notify("AUDIO_X_STATE",R(R({},v),s));},v);var o,U=f,D,T=(D=class{constructor(){u(this,"_audio");u(this,"isPlayLogEnabled");u(this,"_queue");u(this,"_currentQueueIndex",0);u(this,"_fetchFn");u(this,"eqStatus","IDEAL");u(this,"isEqEnabled",!1);u(this,"eqInstance");u(this,"showNotificationsActions",!1);var e;if(D._instance)return console.warn("Instantiation failed: cannot create multiple instance of AudioX returning existing instance"),D._instance;if(process.env.NODE_ENV!==((e=k)==null?void 0:e.DEVELOPMENT)&&o)throw new Error("Cannot create multiple audio instance");D._instance=this,this._audio=new Audio,o=this._audio;}init(e){return p(this,null,function*(){var M;let{preloadStrategy:t="auto",autoPlay:a=!1,useDefaultEventListeners:i=!0,customEventListeners:r=null,showNotificationActions:c=!1,enablePlayLog:h=!1,enableHls:A=!1,enableEQ:m=!1,crossOrigin:P="anonymous",hlsConfig:oe={}}=e;(M=this._audio)==null||M.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=a,this._audio.crossOrigin=P,this.isPlayLogEnabled=h,this.isEqEnabled=m,r!==null?(i&&console.warn(`useDefaultEventListeners is set to true at init, are you trying to use the default event listeners? | ||
set customEventListeners to null to use default event listeners`),B(r,!1)):B(ie,h),c&&(this.showNotificationsActions=!0,q()),A&&new O().init(oe,h);})}addMedia(e){return p(this,null,function*(){if(!e)return;let t=this.getQueue();if(_(t)){let i=t.findIndex(r=>e.id===r.id);i>-1&&(this._currentQueueIndex=i);}let a=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&L(o,"TRACK_CHANGE"),a==="HLS"){let i=new O,r=i.getHlsInstance();r?(r.detachMedia(),i.addHlsMedia(e)):(console.warn("The source provided seems to be a HLS stream but, hls playback is not enabled. Please have a look at init method of AudioX"),yield this.reset());}else o.src=e.source;U.notify("AUDIO_STATE",{playbackState:l.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),re(e),o.load();})}attachEq(){if(this.eqStatus==="IDEAL")try{let e=new H;this.eqStatus=e.status(),this.eqInstance=e;}catch(e){console.log("failed to enable equalizer");}}play(){return p(this,null,function*(){let e=o.src!=="";o!=null&&o.paused&&o.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&e&&(yield o.play().then(()=>{console.log("PLAYING");}).catch(()=>{console.warn("cancelling current audio playback, track changed");})),this.isEqEnabled&&this.attachEq();})}addMediaAndPlay(e,t){return p(this,null,function*(){let a=e||(this._queue.length>0?this._queue[0]:void 0);t&&X(t)&&a&&(this._fetchFn=t,yield t(a));try{a?this.addMedia(a).then(()=>{o.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&setTimeout(()=>p(this,null,function*(){yield this.play(),this.isEqEnabled&&this.attachEq();}),950);}):console.error("Playback Failed, No MediaTrack Provided");}catch(i){console.error("Playback Failed");}})}pause(){o&&!(o!=null&&o.paused)&&(o==null||o.pause());}stop(){o&&!o.paused&&(o==null||o.pause(),o.currentTime=0);}reset(){return p(this,null,function*(){o&&(this.stop(),o.src="",o.srcObject=null);})}setVolume(e){let t=e/100;o&&(o.volume=t,U.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){o&&(o.playbackRate=e,U.notify("AUDIO_STATE",{playbackRate:e}));}mute(){o&&!o.muted&&(o.muted=!0);}seek(e){o&&(o.currentTime=e);}seekBy(e){if(o&&o.currentTime){let t=o.currentTime;o.currentTime=t+e;}}destroy(){return p(this,null,function*(){o&&(yield this.reset(),o.removeAttribute("src"),o.load());})}subscribe(e,t,a={}){return U.listen(e,t,a)}addEventListener(e,t){o.addEventListener(e,t);}getPresets(){return H.getPresets()}setPreset(e){this.isEqEnabled?this.eqInstance.setPreset(e):console.error("Equalizer not initialized, please set enableEq at init");}setCustomEQ(e){this.isEqEnabled?this.eqInstance.setCustomEQ(e):console.error("Equalizer not initialized, please set enableEq at init");}setBassBoost(e,t){this.isEqEnabled?this.eqInstance.setBassBoost(e,t):console.error("Equalizer not initialized, please set enableEq at init");}addQueue(e,t){this.clearQueue();let a=_(e)?e.slice():[];switch(t){case"DEFAULT":this._queue=a;break;case"REVERSE":this._queue=a.reverse();break;case"SHUFFLE":this._queue=Z(a);break;default:this._queue=a;break}J(),this.showNotificationsActions&&q();}playNext(){let e=this._currentQueueIndex+1;if(this._queue.length>e){let t=this._queue[e];this.addMediaAndPlay(t,this._fetchFn),this._currentQueueIndex=e;}else this.stop(),U.notify("AUDIO_STATE",{playbackState:l.QUEUE_ENDED});}playPrevious(){let e=this._currentQueueIndex-1;if(e>=0){let t=this._queue[e];this.addMediaAndPlay(t,this._fetchFn),this._currentQueueIndex=e;}else console.log("At the beginning of the queue");}clearQueue(){this._queue&&_(this._queue)&&(this._queue=[],this._currentQueueIndex=0);}addToQueue(e){this._queue&&_(this._queue)&&(Array.isArray(e)?this._queue=[...this._queue,...e]:this._queue.push(e));}removeFromQueue(e){if(this._queue&&_(this._queue)){let t=this._queue.filter(a=>a.id==e.id);this._queue=t;}}getQueue(){return this._queue&&_(this._queue)?this._queue:[]}get id(){return o==null?void 0:o.getAttribute("id")}static getAudioInstance(){return o}},n(D,"AudioX"),u(D,"_instance"),D); | ||
export { w as AUDIO_EVENTS, q as AUDIO_STATE, k as AUDIO_X_CONSTANTS, T as AudioX }; | ||
export { w as AUDIO_EVENTS, v as AUDIO_STATE, k as AUDIO_X_CONSTANTS, T as AudioX }; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "audio_x", | ||
"version": "1.0.10-beta.9", | ||
"version": "1.0.10-beta.10", | ||
"description": "The audio player for the gen-x", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246060
3302