diff --git a/dist/index.d.ts b/dist/index.d.ts index 22e23e4..404e163 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3268,6 +3268,7 @@ interface AudioEvents { LOAD_START: 'loadstart'; ERROR: 'error'; TRACK_CHANGE: 'trackchange'; + QUEUE_ENDED: 'queueended'; } interface CustomAudioState { AUDIO_X_STATE: 'AUDIO_X_STATE'; @@ -3280,7 +3281,7 @@ type EventListenerCallbackMap = { type InitMode = 'REACT' | 'VANILLA'; type PlaybackRate = 1.0 | 1.25 | 1.5 | 1.75 | 2.0 | 2.5 | 3.0; type Preload = 'none' | 'metadata' | 'auto' | ''; -type PlayBackState = 'idle' | 'playing' | 'ended' | 'ready' | 'paused' | 'stalled' | 'error' | 'buffering' | 'trackchanged' | 'durationchanged'; +type PlayBackState = 'idle' | 'playing' | 'ended' | 'ready' | 'paused' | 'stalled' | 'error' | 'buffering' | 'trackchanged' | 'durationchanged' | 'queueended'; type MediaArtwork = { src: string; name?: string; @@ -3309,7 +3310,7 @@ interface AudioInit { enablePlayLog?: boolean; enableHls?: boolean; enableEQ?: boolean; - crossOrigin?: string; + crossOrigin?: 'anonymous' | 'use-credentials' | null; hlsConfig?: HlsConfig | {}; } interface AudioError { @@ -3335,6 +3336,7 @@ interface Band { frequency: number; type: BiquadFilterType; gain: number; + q: number; } interface Preset { id: string | number; @@ -3356,7 +3358,7 @@ declare class AudioX { private showNotificationsActions; constructor(); init(initProps: AudioInit): Promise; - addMedia(mediaTrack: MediaTrack): Promise; + addMedia(mediaTrack: MediaTrack, mediaFetchFn?: (mediaTrack: MediaTrack) => Promise): Promise; attachEq(): void; play(): Promise; addMediaAndPlay(mediaTrack?: MediaTrack | null, fetchFn?: (mediaTrack: MediaTrack) => Promise): Promise; @@ -3379,6 +3381,7 @@ declare class AudioX { }[]; setPreset(id: keyof Preset): void; setCustomEQ(gains: number[]): void; + setBassBoost(enabled: boolean, boost: number): void; addQueue(queue: MediaTrack[], playbackType: QueuePlaybackType): void; playNext(): void; playPrevious(): void; diff --git a/dist/index.js b/dist/index.js index 09af596..cb8ccb6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,5 @@ -var V=Object.defineProperty;var B=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var P=(s,e,t)=>e in s?V(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)&&P(s,t,e[t]);if(B)for(var t of B(e))ne.call(e,t)&&P(s,t,e[t]);return s};var n=(s,e)=>V(s,"name",{value:e,configurable:!0});var u=(s,e,t)=>(P(s,typeof e!="symbol"?e+"":e,t),t);var p=(s,e,t)=>new Promise((a,r)=>{var o=A=>{try{h(t.next(A));}catch(S){r(S);}},d=A=>{try{h(t.throw(A));}catch(S){r(S);}},h=A=>A.done?a(A.value):Promise.resolve(A.value).then(o,d);h((t=t.apply(s,e)).next());});var K=[{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}],I=[{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 F=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"}),L=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."}),Y={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,le=(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 r=E.listeners[e];r&&t!==null&&(E.notifierState[e]=R(R({},E.notifierState[e]||{}),t),r.forEach(o=>{o(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 r=E.listeners[e];r&&(r.delete(t),r.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 r=t.map(o=>E.listen(e,o,a));return ()=>{r.forEach(o=>o());}}static getLatestState(e){return this.validateEventName(e),E.notifierState[e]}},n(E,"ChangeNotifier"),u(E,"listeners",{}),u(E,"notifierState",{}),E),f=le;var _=n(s=>s&&Array.isArray(s)&&s.length,"isValidArray"),Q=n(s=>s instanceof Function&&typeof s=="function","isValidFunction");var X={},j=n(s=>{let e="",t=s.error;switch(t==null?void 0:t.code){case MediaError.MEDIA_ERR_ABORTED:e+=L.MEDIA_ERR_ABORTED;break;case MediaError.MEDIA_ERR_NETWORK:e+=L.MEDIA_ERR_NETWORK;break;case MediaError.MEDIA_ERR_DECODE:e+=L.MEDIA_ERR_DECODE;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:e+=L.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:e+=L.DEFAULT;break}return e},"getReadableErrorMessage"),z=n(s=>{var S;let{title:e,album:t,artist:a,artwork:r}=s,o=r?(S=r[0])==null?void 0:S.src:"",h=["96x96","128x128","192x192","256x256","384x384","512x512"].map(U=>({src:o,sizes:U,type:"image/png"}));return {title:e,album:t,artist:a,artwork:h}},"metaDataCreator"),k=0,b=n((s,e)=>{let t=new Set;for(let o=0;oo+d,0);k=["ENDED","TRACK_CHANGE","PAUSE"].includes(e)?r:k,f.notify("AUDIO_STATE",{currentTrackPlayTime:r,previousTrackPlayTime:k});},"calculateActualPlayedLength"),$=n((s,e,t)=>new Promise((a,r)=>{if(window instanceof Window&&window.document)if(X[t])e(),a();else {X[t]=!0;let o=document.createElement("script");o.type="text/javascript",o.src=s,o.async=!0,o.onload=()=>{e(),a();},document.head.appendChild(o);}else r(`Window not ready unable to initialize ${t}`);}),"loadScript"),W=n(()=>{let s=new T,e=!1,t=n(a=>{if(a.playbackState==="ended"&&!e){let r=s.getQueue();e=!0,r&&_(r)&&s.playNext();}a.playbackState!=="ended"&&(e=!1);},"audioStateListener");f.listen("AUDIO_STATE",t);},"handleQueuePlayback"),g=n(s=>{let{buffered:e}=s,t=0;for(let a=0;a{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");var D,x=(D=class{constructor(){u(this,"audioCtx");u(this,"audioCtxStatus");u(this,"eqFilterBands");if(D._instance)return D._instance;this.initializeAudioContext(),D._instance=this;}initializeAudioContext(){typeof AudioContext!="undefined"?this.audioCtx=new AudioContext:typeof window.webkitAudioContext!="undefined"&&(this.audioCtx=new window.webkitAudioContext),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=K.map(o=>{let d=this.audioCtx.createBiquadFilter();return d.type=o.type,d.frequency.value=o.frequency,d.gain.value=o.gain,d.Q.value=1,d}),r=this.audioCtx.createGain();r.gain.value=1,t.connect(a[0]);for(let o=0;oa.id===e);t&&(!this.eqFilterBands||this.eqFilterBands.length!==t.gains.length||this.eqFilterBands.forEach((a,r)=>{a.gain.value=t.gains[r];}));}static getPresets(){return I}status(){return this.audioCtx.state==="suspended"&&this.audioCtx.resume(),this.audioCtxStatus}setCustomEQ(e){_(e)&&this.eqFilterBands.forEach((t,a)=>{t.gain.value=e[a];});}},n(D,"Equalizer"),u(D,"_instance"),D);var Z={ERROR:(s,e)=>{let t=e.type,a=e.details,r=e.fatal;f.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{type:t,isFatal:r,detail:a}},`audiox_baseEvents_state_${s.type}`);},FRAG_CHANGED:()=>{}};var H=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"}),ee={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 w=n((s,e=!1)=>{let t=T.getAudioInstance();_(Object.keys(s))&&Object.keys(s).forEach(a=>{let r=a;t==null||t.addEventListener(H[r],o=>{if(a&&s[r]){let d=s[r];typeof d=="function"&&d(o,t,e);}});});},"attachEventListeners");var te=n((s,e=!1)=>{let a=new O().getHlsInstance();_(Object.keys(s))&&Object.keys(s).forEach(r=>{let o=r;a.on(ee[o],(d,h)=>{if(o&&s[o]){let A=s[o];typeof A=="function"&&A(d,h,a,e);}});});},"attachHlsEventsListeners");var C,y,ue=(y=class{constructor(){u(this,"HlsClass");if(y._instance)return y._instance;y._instance=this;}load(){return p(this,null,function*(){return yield $(Y.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),te(Z,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}},n(y,"HlsAdapter"),u(y,"_instance"),y),O=ue;var se=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var c=f,ae={LOAD_START:(s,e)=>{let t=g(e);c.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}`);},DURATION_CHANGE:(s,e)=>{let t=c.getLatestState("AUDIO_X_STATE"),a=g(e);c.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}`);},LOADED_META_DATA:(s,e)=>{let t=g(e);c.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:(s,e)=>{let t=g(e);c.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}`);},CAN_PLAY:(s,e)=>{let t=c.getLatestState("AUDIO_X_STATE"),a=g(e);c.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_THROUGH:(s,e)=>{let t=c.getLatestState("AUDIO_X_STATE"),a=e.paused,r=g(e);c.notify("AUDIO_STATE",{playbackState:a?l.PAUSED:t.playbackState==="playing"?l.PLAYING:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:r},`audiox_baseEvents_state_${s.type}`);},PLAY:(s,e)=>{c.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PLAYING:(s,e)=>{c.notify("AUDIO_STATE",{playbackState:l.PLAYING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PAUSE:(s,e,t)=>{c.notify("AUDIO_STATE",{playbackState:l.PAUSED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&b(e,"PAUSE");},ENDED:(s,e,t)=>{c.notify("AUDIO_STATE",{playbackState:l.ENDED,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&b(e,"ENDED");},ERROR:(s,e)=>{var r;let t=(r=e.error)==null?void 0:r.code,a=j(e);c.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{code:t,message:se[t],readable:a}},`audiox_baseEvents_state_${s.type}`);},TIME_UPDATE:(s,e)=>{let t=c.getLatestState("AUDIO_X_STATE"),a=g(e);c.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}`);},WAITING:(s,e)=>{c.notify("AUDIO_STATE",{playbackState:l.BUFFERING,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},VOLUME_CHANGE:s=>{c.notify("AUDIO_STATE",{},"audiox_baseEvents_state");},SEEKED:(s,e)=>{let t=c.getLatestState("AUDIO_X_STATE"),a=g(e);c.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}`);}};var re=n(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata(z(s)));},"updateMetaData"),v=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 M={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},G={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=>{f.notify("AUDIO_X_STATE",R(R({},G),s));},G);var i,N=f,m,T=(m=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(m._instance)return m._instance;if(process.env.NODE_ENV!==((e=F)==null?void 0:e.DEVELOPMENT)&&i)throw new Error("Cannot create multiple audio instance");m._instance=this,this._audio=new Audio,i=this._audio;}init(e){return p(this,null,function*(){var q;let{preloadStrategy:t="auto",autoPlay:a=!1,useDefaultEventListeners:r=!0,customEventListeners:o=null,showNotificationActions:d=!1,enablePlayLog:h=!1,enableHls:A=!1,enableEQ:S=!1,crossOrigin:U="anonymous",hlsConfig:ie={}}=e;(q=this._audio)==null||q.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=a,this._audio.crossOrigin=U,this.isPlayLogEnabled=h,o!==null?w(o,!1):w(ae,h),d&&(this.showNotificationsActions=!0,v()),S&&(this.isEqEnabled=S),A&&new O().init(ie,h);})}addMedia(e){return p(this,null,function*(){if(!e)return;let t=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&b(i,"TRACK_CHANGE"),t==="HLS"){let a=new O,r=a.getHlsInstance();r?(r.detachMedia(),a.addHlsMedia(e)):yield this.reset();}else i.src=e.source;N.notify("AUDIO_STATE",{playbackState:l.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),re(e),i.load();})}attachEq(){if(this.isEqEnabled&&this.eqStatus==="IDEAL")try{let e=new x;this.eqStatus=e.status(),this.eqInstance=e;}catch(e){}}play(){return p(this,null,function*(){let e=i.src!=="";i!=null&&i.paused&&i.HAVE_ENOUGH_DATA===M.HAVE_ENOUGH_DATA&&e&&(yield i.play().then(()=>{}).catch(()=>{}));})}addMediaAndPlay(e,t){return p(this,null,function*(){let a=e||(this._queue.length>0?this._queue[0]:void 0);t&&Q(t)&&a&&(this._fetchFn=t,yield t(a)),this._queue&&_(this._queue)&&(this._currentQueueIndex=this._queue.findIndex(r=>r.id===(a==null?void 0:a.id)));try{a&&this.addMedia(a).then(()=>{i.HAVE_ENOUGH_DATA===M.HAVE_ENOUGH_DATA&&setTimeout(()=>p(this,null,function*(){this.attachEq(),yield this.play();}),950);});}catch(r){}})}pause(){i&&!(i!=null&&i.paused)&&(i==null||i.pause());}stop(){i&&!i.paused&&(i==null||i.pause(),i.currentTime=0);}reset(){return p(this,null,function*(){i&&(this.stop(),i.src="",i.srcObject=null);})}setVolume(e){let t=e/100;i&&(i.volume=t,N.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){i&&(i.playbackRate=e,N.notify("AUDIO_STATE",{playbackRate:e}));}mute(){i&&!i.muted&&(i.muted=!0);}seek(e){i&&(i.currentTime=e);}seekBy(e){if(i&&i.currentTime){let t=i.currentTime;i.currentTime=t+e;}}destroy(){return p(this,null,function*(){i&&(yield this.reset(),i.removeAttribute("src"),i.load());})}subscribe(e,t,a={}){return N.listen(e,t,a)}addEventListener(e,t){i.addEventListener(e,t);}getPresets(){return x.getPresets()}setPreset(e){this.eqInstance.setPreset(e);}setCustomEQ(e){this.eqInstance.setCustomEQ(e);}addQueue(e,t){let a=_(e)?e.slice():[];switch(t){case"DEFAULT":this._queue=a;break;case"REVERSE":this._queue=a.reverse();break;case"SHUFFLE":this._queue=J(a);break;default:this._queue=a;break}W(),this.showNotificationsActions&&v();}playNext(){if(this._queue.length>this._currentQueueIndex+1){this._currentQueueIndex++;let e=this._queue[this._currentQueueIndex];this.addMediaAndPlay(e,this._fetchFn);}}playPrevious(){if(this._currentQueueIndex>0){this._currentQueueIndex--;let e=this._queue[this._currentQueueIndex];this.addMediaAndPlay(e,this._fetchFn);}}clearQueue(){this._queue&&_(this._queue)&&(this._queue=[]);}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 i==null?void 0:i.getAttribute("id")}static getAudioInstance(){return i}},n(m,"AudioX"),u(m,"_instance"),m); +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 c=(s,e,t)=>I(s,typeof e!="symbol"?e+"":e,t);var p=(s,e,t)=>new Promise((r,i)=>{var o=A=>{try{_(t.next(A));}catch(y){i(y);}},u=A=>{try{_(t.throw(A));}catch(y){i(y);}},_=A=>A.done?r(A.value):Promise.resolve(A.value).then(o,u);_((t=t.apply(s,e)).next());});var Y=[{frequency:31,type:"lowshelf",gain:0,q:1.2},{frequency:63,type:"peaking",gain:0,q:1.2},{frequency:125,type:"peaking",gain:0,q:1.2},{frequency:250,type:"peaking",gain:0,q:1.2},{frequency:500,type:"peaking",gain:0,q:1.2},{frequency:1e3,type:"peaking",gain:0,q:1.2},{frequency:2e3,type:"peaking",gain:0,q:1.2},{frequency:4e3,type:"peaking",gain:0,q:1.2},{frequency:8e3,type:"peaking",gain:0,q:1.2},{frequency:16e3,type:"highshelf",gain:0,q:1.2}],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 d,ce=(d=class{static validateEventName(e){if(!e||typeof e!="string")throw new Error("Invalid event name")}static notify(e,t,r="audiox_notifier_default"){this.validateEventName(e);let i=d.listeners[e];i&&t!==null&&(d.notifierState[e]=R(R({},d.notifierState[e]||{}),t),i.forEach(o=>{o(d.notifierState[e]);}));}static listen(e,t,r={}){if(this.validateEventName(e),typeof t!="function")throw new Error("Callback must be a function");return d.listeners[e]?d.listeners[e].add(t):(d.notifierState[e]=r,d.listeners[e]=new Set([t])),()=>{let i=d.listeners[e];i&&(i.delete(t),i.size===0&&delete d.listeners[e]);}}static multiListen(e,t,r={}){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(o=>d.listen(e,o,r));return ()=>{i.forEach(o=>o());}}static getLatestState(e){return this.validateEventName(e),d.notifierState[e]}},n(d,"ChangeNotifier"),c(d,"listeners",{}),c(d,"notifierState",{}),d),f=ce;var h=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 y;let{title:e,album:t,artist:r,artwork:i}=s,o=i?(y=i[0])==null?void 0:y.src:"",_=["96x96","128x128","192x192","256x256","384x384","512x512"].map(P=>({src:o,sizes:P,type:"image/png"}));return {title:e,album:t,artist:r,artwork:_}},"metaDataCreator"),x=0,L=n((s,e)=>{let t=new Set;for(let o=0;oo+u,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((r,i)=>{if(window instanceof Window&&window.document)if(z[t])e(),r();else {z[t]=!0;let o=document.createElement("script");o.type="text/javascript",o.src=s,o.async=!0,o.onload=()=>{e(),r();},document.head.appendChild(o);}else i(`Window not ready unable to initialize ${t}`);}),"loadScript"),J=n(()=>{let s=new T,e=!1,t=n(r=>{if(r.playbackState==="ended"&&!e){let i=s.getQueue();e=!0,i&&h(i)&&e&&s.playNext();}r.playbackState!=="ended"&&(e=!1);},"audioStateListener");f.listen("AUDIO_STATE",t);},"handleQueuePlayback"),m=n(s=>{let{buffered:e}=s,t=0;for(let r=0;r{let e=[...s];for(let t=e.length-1;t>0;t--){let r=Math.floor(Math.random()*t);[e[t],e[r]]=[e[r],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,o)=>N(i,e[o]));let t=Object.keys(s),r=Object.keys(e);return t.length!==r.length?!1:t.every(i=>r.includes(i)?N(s[i],e[i]):!1)},"diffChecker");var g,q=(g=class{constructor(){c(this,"audioCtx");c(this,"audioCtxStatus");c(this,"eqFilterBands");c(this,"bassBoostFilter");c(this,"compressor");if(g._instance)return g._instance;this.initializeAudioContext(),g._instance=this;}initializeAudioContext(){let e={latencyHint:"playback"};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=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),r=Y.map(i=>{let o=this.audioCtx.createBiquadFilter();return o.type=i.type,o.frequency.value=i.frequency,o.gain.value=i.gain,o.Q.value=i.q||1,o});this.compressor=this.audioCtx.createDynamicsCompressor(),this.compressor.threshold.value=-24,this.compressor.knee.value=30,this.compressor.ratio.value=12,this.compressor.attack.value=.003,this.compressor.release.value=.25,this.bassBoostFilter=this.audioCtx.createBiquadFilter(),this.bassBoostFilter.type="lowshelf",this.bassBoostFilter.frequency.value=100,this.bassBoostFilter.gain.value=0,t.connect(r[0]);for(let i=0;ii.id===e);if(!t||!this.eqFilterBands||this.eqFilterBands.length!==t.gains.length)return;let r=this.audioCtx.currentTime;this.eqFilterBands.forEach((i,o)=>{let u=t.gains[o];i.gain.setTargetAtTime(u,r,.05);});}static getPresets(){return F}status(){return this.audioCtx.state==="suspended"&&this.audioCtx.resume(),this.audioCtxStatus}setCustomEQ(e){if(h(e)&&e.length===this.eqFilterBands.length){let t=this.audioCtx.currentTime;this.eqFilterBands.forEach((r,i)=>{r.gain.setTargetAtTime(e[i],t,.05);});}}setBassBoost(e,t=6){let r=this.audioCtx.currentTime;e?this.bassBoostFilter.gain.setTargetAtTime(t,r,.05):this.bassBoostFilter.gain.setTargetAtTime(0,r,.05);}setCompressorSettings(e){this.compressor&&(e.threshold!==void 0&&this.compressor.threshold.setTargetAtTime(e.threshold,this.audioCtx.currentTime,.01),e.knee!==void 0&&this.compressor.knee.setTargetAtTime(e.knee,this.audioCtx.currentTime,.01),e.ratio!==void 0&&this.compressor.ratio.setTargetAtTime(e.ratio,this.audioCtx.currentTime,.01),e.attack!==void 0&&this.compressor.attack.setTargetAtTime(e.attack,this.audioCtx.currentTime,.01),e.release!==void 0&&this.compressor.release.setTargetAtTime(e.release,this.audioCtx.currentTime,.01));}reset(){let e=this.audioCtx.currentTime;this.eqFilterBands.forEach(t=>{t.gain.setTargetAtTime(0,e,.05);}),this.bassBoostFilter.gain.setTargetAtTime(0,e,.05);}},n(g,"Equalizer"),c(g,"_instance"),g);var ee={ERROR:n((s,e)=>{let t=e.type,r=e.details,i=e.fatal;f.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{type:t,isFatal:i,detail:r}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),FRAG_CHANGED:n(()=>{},"FRAG_CHANGED")};var v=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 H=n((s,e=!1)=>{let t=T.getAudioInstance();h(Object.keys(s))&&Object.keys(s).forEach(r=>{let i=r;t==null||t.addEventListener(v[i],o=>{if(r&&s[i]){let u=s[i];typeof u=="function"&&u(o,t,e);}});});},"attachEventListeners");var se=n((s,e=!1)=>{let r=new C().getHlsInstance();h(Object.keys(s))&&Object.keys(s).forEach(i=>{let o=i;r.on(te[o],(u,_)=>{if(o&&s[o]){let A=s[o];typeof A=="function"&&A(u,_,r,e);}});});},"attachHlsEventsListeners");var O,S,ue=(S=class{constructor(){c(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 r=yield this.load();r.isSupported()&&(O=new r(e),se(ee,t));})}addHlsMedia(e){let t=this.HlsClass,r=T.getAudioInstance();O.loadSource(e.source),O.attachMedia(r),O.on(t.Events.MEDIA_ATTACHED,function(){});}getHlsInstance(){return O}},n(S,"HlsAdapter"),c(S,"_instance"),S),C=ue;var re=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var E=f,ie={LOAD_START:n((s,e)=>{let t=m(e);E.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)=>{let t=E.getLatestState("AUDIO_X_STATE"),r=m(e);E.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:r},`audiox_baseEvents_state_${s.type}`);},"DURATION_CHANGE"),LOADED_META_DATA:n((s,e)=>{let t=m(e);E.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)=>{let t=m(e);E.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)=>{let t=E.getLatestState("AUDIO_X_STATE"),r=m(e);E.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?l.PAUSED:l.READY,error:{code:null,message:"",readable:""},bufferedDuration:r},`audiox_baseEvents_state_${s.type}`);},"CAN_PLAY"),CAN_PLAY_THROUGH:n((s,e)=>{let t=E.getLatestState("AUDIO_X_STATE"),r=e.paused,i=m(e);E.notify("AUDIO_STATE",{playbackState:r?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)=>{E.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)=>{E.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)=>{E.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)=>{E.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;let t=(i=e.error)==null?void 0:i.code,r=j(e);E.notify("AUDIO_STATE",{playbackState:l.ERROR,error:{code:t,message:re[t],readable:r}},`audiox_baseEvents_state_${s.type}`);},"ERROR"),TIME_UPDATE:n((s,e)=>{let t=E.getLatestState("AUDIO_X_STATE"),r=m(e);E.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:r},`audiox_baseEvents_state_${s.type}`);},"TIME_UPDATE"),WAITING:n((s,e)=>{E.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=>{E.notify("AUDIO_STATE",{},"audiox_baseEvents_state");},"VOLUME_CHANGE"),SEEKED:n((s,e)=>{let t=E.getLatestState("AUDIO_X_STATE"),r=m(e);E.notify("AUDIO_STATE",{playbackState:t.playbackState==="paused"?"paused":t.playbackState,progress:e==null?void 0:e.currentTime,error:{code:null,message:"",readable:""},bufferedDuration:r},`audiox_baseEvents_state_${s.type}`);},"SEEKED")};var ae=n(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata($(s)));},"updateMetaData"),w=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},B={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({},B),s));},B);var a,U=f,D,T=(D=class{constructor(){c(this,"_audio");c(this,"isPlayLogEnabled");c(this,"_queue");c(this,"_currentQueueIndex",0);c(this,"_fetchFn");c(this,"eqStatus","IDEAL");c(this,"isEqEnabled",!1);c(this,"eqInstance");c(this,"showNotificationsActions",!1);var e;if(D._instance)return D._instance;if(process.env.NODE_ENV!==((e=k)==null?void 0:e.DEVELOPMENT)&&a)throw new Error("Cannot create multiple audio instance");D._instance=this,this._audio=new Audio,a=this._audio;}init(e){return p(this,null,function*(){var M;let{preloadStrategy:t="auto",autoPlay:r=!1,useDefaultEventListeners:i=!0,customEventListeners:o=null,showNotificationActions:u=!1,enablePlayLog:_=!1,enableHls:A=!1,enableEQ:y=!1,crossOrigin:P=null,hlsConfig:oe={}}=e;(M=this._audio)==null||M.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=r,this._audio.crossOrigin=P,this.isPlayLogEnabled=_,this.isEqEnabled=y,o!==null?H(o,!1):H(ie,_),u&&(this.showNotificationsActions=!0,w()),A&&new C().init(oe,_);})}addMedia(e,t){return p(this,null,function*(){if(!e)return;t&&!e.source.length&&(this._fetchFn=t);let r=this.getQueue();if(h(r)){let o=r.findIndex(u=>e.id===u.id);o>-1&&(this._currentQueueIndex=o);}let i=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&L(a,"TRACK_CHANGE"),i==="HLS"&&!a.canPlayType("application/vnd.apple.mpegurl")){let o=new C,u=o.getHlsInstance();u?(u.detachMedia(),o.addHlsMedia(e)):yield this.reset();}else a.src=e.source;U.notify("AUDIO_STATE",{playbackState:l.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),ae(e),a.load();})}attachEq(){if(this.eqStatus==="IDEAL")try{let e=new q;this.eqStatus=e.status(),this.eqInstance=e;}catch(e){}}play(){return p(this,null,function*(){let e=a.src!=="";a!=null&&a.paused&&a.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&e&&(yield a.play().then(()=>{}).catch(()=>{})),this.isEqEnabled&&this.attachEq();})}addMediaAndPlay(e,t){return p(this,null,function*(){let r=e||(this._queue.length>0?this._queue[0]:void 0);t&&X(t)&&(r!=null&&r.source.length)&&(this._fetchFn=t,yield t(r));try{r&&this.addMedia(r).then(()=>{a.HAVE_ENOUGH_DATA===G.HAVE_ENOUGH_DATA&&setTimeout(()=>p(this,null,function*(){yield this.play(),this.isEqEnabled&&this.attachEq();}),950);});}catch(i){}})}pause(){a&&!(a!=null&&a.paused)&&(a==null||a.pause());}stop(){a&&!a.paused&&(a==null||a.pause(),a.currentTime=0);}reset(){return p(this,null,function*(){a&&(this.stop(),a.src="",a.srcObject=null);})}setVolume(e){let t=e/100;a&&(a.volume=t,U.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){a&&(a.playbackRate=e,U.notify("AUDIO_STATE",{playbackRate:e}));}mute(){a&&!a.muted&&(a.muted=!0);}seek(e){a&&(a.currentTime=e);}seekBy(e){if(a&&a.currentTime){let t=a.currentTime;a.currentTime=t+e;}}destroy(){return p(this,null,function*(){a&&(yield this.reset(),a.removeAttribute("src"),a.load());})}subscribe(e,t,r={}){return U.listen(e,t,r)}addEventListener(e,t){a.addEventListener(e,t);}getPresets(){return q.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 r=h(e)?e.slice():[];switch(t){case"DEFAULT":this._queue=r;break;case"REVERSE":this._queue=r.reverse();break;case"SHUFFLE":this._queue=Z(r);break;default:this._queue=r;break}J(),this.showNotificationsActions&&w();}playNext(){var t;let e=this._currentQueueIndex+1;if(((t=this==null?void 0:this._queue)==null?void 0:t.length)>e){let r=this._queue[e];this.addMediaAndPlay(r,this._fetchFn),this._currentQueueIndex=e;}else this.stop(),U.notify("AUDIO_STATE",{playbackState:l.QUEUE_ENDED});}playPrevious(){let e=(this==null?void 0:this._currentQueueIndex)-1;if(e>=0){let t=this==null?void 0:this._queue[e];this.addMediaAndPlay(t,this._fetchFn),this._currentQueueIndex=e;}}clearQueue(){this._queue&&h(this._queue)&&(this._queue=[],this._currentQueueIndex=0);}addToQueue(e){this._queue&&h(this._queue)&&(Array.isArray(e)?this._queue=[...this._queue,...e]:this._queue.push(e));}removeFromQueue(e){if(this._queue&&h(this._queue)){let t=this._queue.filter(r=>r.id==e.id);this._queue=t;}}getQueue(){return this._queue&&h(this._queue)?this._queue:[]}get id(){return a==null?void 0:a.getAttribute("id")}static getAudioInstance(){return a}},n(D,"AudioX"),c(D,"_instance"),D); -export { H as AUDIO_EVENTS, G as AUDIO_STATE, F as AUDIO_X_CONSTANTS, T as AudioX }; -//# sourceMappingURL=out.js.map +export { v as AUDIO_EVENTS, B as AUDIO_STATE, k as AUDIO_X_CONSTANTS, T as AudioX }; +//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index ebf9aed..d9cf3b8 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/constants/equalizer.ts","../src/constants/common.ts","../src/helpers/notifier.ts","../src/helpers/common.ts","../src/adapters/equalizer.ts","../src/events/hlsEvents.ts","../src/events/audioEvents.ts","../src/events/listeners.ts","../src/adapters/hls.ts","../src/events/errorEvents.ts","../src/events/baseEvents.ts","../src/mediasession/mediasessionHandler.ts","../src/states/audioState.ts","../src/audio.ts"],"names":["bands","frequency","type","gain","presets","name","id","default","gains","AUDIO_X_CONSTANTS","Object","freeze","REACT","VANILLA","DEVELOPMENT","PLAYBACK_STATE","BUFFERING","PLAYING","PAUSED","READY","IDLE","ENDED","STALLED","ERROR","TRACK_CHANGE","DURATION_CHANGE","ERROR_MSG_MAP","MEDIA_ERR_ABORTED","MEDIA_ERR_DECODE","MEDIA_ERR_NETWORK","MEDIA_ERR_SRC_NOT_SUPPORTED","DEFAULT","URLS","HLS","CAST","_a","ChangeNotifier","validateEventName","eventName","Error","notify","data","caller","listenerCbs","listeners","notifierState","__spreadValues","forEach","cb","listen","callback","state","add","Set","eventListeners","delete","size","multiListen","callbacks","Array","isArray","length","unsubscribeFunctions","map","unsubscribe","getLatestState","__publicField","notifier_default","isValidArray","__name","arr","isValidFunction","fn","Function","isValidWindow","window","undefined","Window","loadedScripts","getReadableErrorMessage","audioInstance","message","err","error","code","MediaError","metaDataCreator","mediaTrack","title","album","artist","artwork","artworkUrl","src","artworkMap","el","sizes","previousTrackPlayTime","calculateActualPlayedLength","event","lengthSet","i","played","startX","start","width","end","currentTrackPlayTime","reduce","acc","val","includes","loadScript","url","onLoad","Promise","resolve","reject","document","script","createElement","async","onload","head","appendChild","handleQueuePlayback","audio","AudioX","hasEnded","audioStateListener","playbackState","queue","getQueue","playNext","getBufferedDuration","buffered","bufferedDuration","shuffle","array","shuffledArray","j","Math","floor","random","Equalizer","constructor","audioCtx","audioCtxStatus","eqFilterBands","_instance","initializeAudioContext","AudioContext","webkitAudioContext","init","addResumeListener","resume","setTimeout","body","removeEventListener","addEventListener","getAudioInstance","audioSource","createMediaElementSource","equalizerBands","band","filter","createBiquadFilter","value","Q","gainNode","createGain","connect","destination","setPreset","preset","find","index","getPresets","status","setCustomEQ","HLS_EVENTS_CALLBACK_MAP","e","detail","details","isFatal","fatal","FRAG_CHANGED","AUDIO_EVENTS","ABORT","TIME_UPDATE","CAN_PLAY","CAN_PLAY_THROUGH","EMPTIED","WAITING","SEEKING","SEEKED","LOADED_META_DATA","LOADED_DATA","PLAY","PAUSE","RATE_CHANGE","VOLUME_CHANGE","SUSPEND","PROGRESS","LOAD_START","HLS_EVENTS","MEDIA_ATTACHING","MEDIA_ATTACHED","MEDIA_DETACHING","MEDIA_DETACHED","BUFFER_RESET","BUFFER_CODECS","BUFFER_CREATED","BUFFER_APPENDING","BUFFER_APPENDED","BUFFER_EOS","BUFFER_FLUSHING","BUFFER_FLUSHED","MANIFEST_LOADING","MANIFEST_LOADED","MANIFEST_PARSED","LEVEL_SWITCHING","LEVEL_SWITCHED","LEVEL_LOADING","LEVEL_LOADED","LEVEL_UPDATED","LEVEL_PTS_UPDATED","LEVELS_UPDATED","AUDIO_TRACKS_UPDATED","AUDIO_TRACK_SWITCHING","AUDIO_TRACK_SWITCHED","AUDIO_TRACK_LOADING","AUDIO_TRACK_LOADED","SUBTITLE_TRACKS_UPDATED","SUBTITLE_TRACKS_CLEARED","SUBTITLE_TRACK_SWITCH","SUBTITLE_TRACK_LOADING","SUBTITLE_TRACK_LOADED","SUBTITLE_FRAG_PROCESSED","CUES_PARSED","NON_NATIVE_TEXT_TRACKS_FOUND","INIT_PTS_FOUND","FRAG_LOADING","FRAG_LOAD_EMERGENCY_ABORTED","FRAG_LOADED","FRAG_DECRYPTED","FRAG_PARSING_INIT_SEGMENT","FRAG_PARSING_USERDATA","FRAG_PARSING_METADATA","FRAG_PARSED","FRAG_BUFFERED","FPS_DROP","FPS_DROP_LEVEL_CAPPING","DESTROYING","KEY_LOADING","KEY_LOADED","LIVE_BACK_BUFFER_REACHED","BACK_BUFFER_REACHED","CUSTOM_AUDIO_EVENTS","AUDIO_X_STATE","attachEventListeners","eventListenersCallbackMap","playLogEnabled","keys","evt","listenerCallback","attachHlsEventsListeners","hlsEventlistenerCallbackMap","hlsInstance","HlsAdapter","getHlsInstance","on","HlsClass","load","__async","then","Hls","catch","msg","config","enablePlayLog","isSupported","addHlsMedia","loadSource","source","attachMedia","Events","hls_default","ERROR_EVENTS","notifier","BASE_EVENT_CALLBACK_MAP","duration","readable","audioState","isPaused","paused","progress","currentTime","errorCode","updateMetaData","navigator","mediaSession","metadata","MediaMetadata","attachMediaSessionHandlers","setActionHandler","play","pause","playPrevious","READY_STATE","HAVE_NOTHING","HAVE_METADATA","HAVE_CURRENT_DATA","HAVE_FUTURE_DATA","HAVE_ENOUGH_DATA","AUDIO_STATE","volume","playbackRate","currentTrack","_audio","isPlayLogEnabled","_queue","_currentQueueIndex","_fetchFn","eqStatus","isEqEnabled","eqInstance","showNotificationsActions","process","env","NODE_ENV","Audio","initProps","preloadStrategy","autoPlay","useDefaultEventListeners","customEventListeners","showNotificationActions","enableHls","enableEQ","crossOrigin","hlsConfig","setAttribute","preload","autoplay","addMedia","mediaType","hls","detachMedia","reset","attachEq","eq","isSourceAvailable","addMediaAndPlay","fetchFn","findIndex","track","stop","srcObject","setVolume","actualVolume","setPlaybackRate","mute","muted","seek","time","seekBy","currentProgress","destroy","removeAttribute","subscribe","addQueue","playbackType","playerQueue","slice","reverse","nextTrack","previousTrack","clearQueue","addToQueue","mediaTracks","push","removeFromQueue","getAttribute"],"mappings":"ipBAEA,IAAMA,EAAgB,CACpB,CAAEC,UAAW,GAAIC,KAAM,WAAYC,KAAM,CAAE,EAC3C,CAAEF,UAAW,GAAIC,KAAM,UAAWC,KAAM,CAAE,EAC1C,CAAEF,UAAW,IAAKC,KAAM,UAAWC,KAAM,CAAE,EAC3C,CAAEF,UAAW,IAAKC,KAAM,UA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gBuB,EAAW,KAAKrD,QAAQ,CAC/C,CAGF,CAEAf,cAAe,CACb,GAAI,KAAKc,mBAAqB,EAAG,CAC/B,KAAKA,qBACL,IAAMuD,EAAgB,KAAKxD,OAAO,KAAKC,kBAAkB,EACzD,KAAK+B,gBAAgBwB,EAAe,KAAKtD,QAAQ,CACnD,CAGF,CAEAuD,YAAa,CACP,KAAKzD,QAAU7P,EAAa,KAAK6P,MAAM,IACzC,KAAKA,OAAS,CAAA,EAElB,CAEA0D,WAAWC,EAAwC,CAC7C,KAAK3D,QAAU7P,EAAa,KAAK6P,MAAM,IACrCtQ,MAAMC,QAAQgU,CAAAA,EAChB,KAAK3D,OAAS,IAAI,KAAKA,UAAW2D,GAElC,KAAK3D,OAAO4D,KAAKD,CAAAA,EAGvB,CAEAE,gBAAgBvS,EAAwB,CACtC,GAAI,KAAK0O,QAAU7P,EAAa,KAAK6P,MAAM,EAAG,CAC5C,IAAM9L,EAAQ,KAAK8L,OAAO5J,OACvB+L,GAAsBA,EAAM9V,IAAMiF,EAAWjF,EAAE,EAElD,KAAK2T,OAAS9L,CAChB,CACF,CAEAC,UAAW,CACT,OAAO,KAAK6L,QAAU7P,EAAa,KAAK6P,MAAM,EAAI,KAAKA,OAAS,CAAA,CAClE,CAEA,IAAI3T,IAAK,CACP,OAAO0E,GAAAA,YAAAA,EAAe+S,aAAa,KACrC,CAEA,OAAO/N,kBAAmB,CACxB,OAAOhF,CACT,CACF,EAnYM+C,EAAAA,EAAAA,UAGJ7D,EAHF/B,EAGiBkH,aAHjBlH","sourcesContent":["import { Band } from 'types/equalizer.types';\n\nconst bands: Band[] = [\n { frequency: 31, type: 'lowshelf', gain: 0 },\n { frequency: 63, type: 'peaking', gain: 0 },\n { frequency: 125, type: 'peaking', gain: 0 },\n { frequency: 250, type: 'peaking', gain: 0 },\n { frequency: 500, type: 'peaking', gain: 0 },\n { frequency: 1000, type: 'peaking', gain: 0 },\n { frequency: 2000, type: 'peaking', gain: 0 },\n { frequency: 4000, type: 'peaking', gain: 0 },\n { frequency: 8000, type: 'peaking', gain: 0 },\n { frequency: 16000, type: 'highshelf', gain: 0 }\n];\n\nconst presets = [\n {\n name: 'Default',\n id: 'default',\n default: true,\n gains: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n },\n {\n name: 'Club',\n id: 'club',\n default: true,\n gains: [0.0, 0.0, 4.8, 3.36, 3.36, 3.36, 1.92, 0.0, 0.0, 0.0]\n },\n {\n name: 'Live',\n id: 'live',\n default: true,\n gains: [-2.88, 0.0, 2.4, 3.36, 3.36, 3.36, 2.4, 1.44, 1.44, 1.44]\n },\n {\n name: 'Party',\n id: 'Party',\n default: true,\n gains: [4.32, 4.32, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.32, 4.32]\n },\n {\n name: 'Pop',\n id: 'pop',\n default: true,\n gains: [0.96, 2.88, 4.32, 4.8, 3.36, 0.0, -1.44, -1.44, 0.96, 0.96]\n },\n {\n name: 'Soft',\n id: 'soft',\n default: true,\n gains: [2.88, 0.96, 0.0, -1.44, 0.0, 2.4, 4.8, 5.76, 6.72, 7.2]\n },\n {\n name: 'Ska',\n id: 'ska',\n default: true,\n gains: [-1.44, -2.88, -2.4, 0.0, 2.4, 3.36, 5.28, 5.76, 6.72, 5.76]\n },\n {\n name: 'Reggae',\n id: 'reggae',\n default: true,\n gains: [0.0, 0.0, 0.0, -3.36, 0.0, 3.84, 3.84, 0.0, 0.0, 0.0]\n },\n\n {\n name: 'Rock',\n id: 'rock',\n default: true,\n gains: [4.8, 2.88, -3.36, -4.8, -1.92, 2.4, 5.28, 6.72, 6.72, 6.72]\n },\n {\n name: 'Dance',\n id: 'dance',\n default: true,\n gains: [5.76, 4.32, 1.44, 0.0, 0.0, -3.36, -4.32, -4.32, 0.0, 0.0]\n },\n {\n name: 'Techno',\n id: 'techno',\n default: true,\n gains: [4.8, 3.36, 0.0, -3.36, -2.88, 0.0, 4.8, 5.76, 5.76, 5.28]\n },\n {\n name: 'Headphones',\n id: 'headphones',\n default: true,\n gains: [2.88, 6.72, 3.36, -1.92, -1.44, 0.96, 2.88, 5.76, 7.68, 8.64]\n },\n {\n name: 'Soft rock',\n id: 'soft_rock',\n default: true,\n gains: [2.4, 2.4, 1.44, 0.0, -2.4, -3.36, -1.92, 0.0, 1.44, 5.28]\n },\n {\n name: 'Classical',\n id: 'classical',\n default: true,\n gains: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.32, -4.32, -4.32, -5.76]\n },\n {\n name: 'Large Hall',\n id: 'large_hall',\n default: true,\n gains: [6.24, 6.24, 3.36, 3.36, 0.0, -2.88, -2.88, -2.88, 0.0, 0.0]\n },\n {\n name: 'Full Bass',\n id: 'full_base',\n default: true,\n gains: [4.8, 5.76, 5.76, 3.36, 0.96, -2.4, -4.8, -6.24, -6.72, -6.72]\n },\n {\n name: 'Full Treble',\n id: 'full_treble',\n default: true,\n gains: [-5.76, -5.76, -5.76, -2.4, 1.44, 6.72, 9.6, 9.6, 9.6, 10.08]\n },\n {\n name: 'Laptop Speakers',\n id: 'laptop_speakers',\n default: true,\n gains: [2.88, 6.72, 3.36, -1.92, -1.44, 0.96, 2.88, 5.76, 7.68, 8.64]\n },\n {\n name: 'Full Bass & Treble',\n id: 'bass_treble',\n default: true,\n gains: [4.32, 3.36, 0.0, -4.32, -2.88, 0.96, 4.8, 6.72, 7.2, 7.2]\n }\n];\n\nexport { bands, presets };\n","import { InitMode } from 'types';\nimport { ErrorMessageMap } from 'types/errorEvents.types';\n\nconst AUDIO_X_CONSTANTS = Object.freeze({\n REACT: 'REACT' as InitMode,\n VANILLA: 'VANILLA' as InitMode,\n DEVELOPMENT: 'development'\n});\n\nconst PLAYBACK_STATE = Object.freeze({\n BUFFERING: 'buffering',\n PLAYING: 'playing',\n PAUSED: 'paused',\n READY: 'ready',\n IDLE: 'idle',\n ENDED: 'ended',\n STALLED: 'stalled',\n ERROR: 'error',\n TRACK_CHANGE: 'trackchanged',\n DURATION_CHANGE: 'durationchanged'\n});\n\nconst ERROR_MSG_MAP: ErrorMessageMap = Object.freeze({\n MEDIA_ERR_ABORTED: 'The user canceled the audio.',\n MEDIA_ERR_DECODE: 'An error occurred while decoding the audio.',\n MEDIA_ERR_NETWORK: 'A network error occurred while fetching the audio.',\n MEDIA_ERR_SRC_NOT_SUPPORTED:\n 'The audio is missing or is in a format not supported by your browser.',\n DEFAULT: 'An unknown error occurred.'\n});\n\nconst URLS = {\n HLS: 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.11/hls.min.js',\n CAST: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'\n};\n\nexport { AUDIO_X_CONSTANTS, ERROR_MSG_MAP, PLAYBACK_STATE, URLS };\n","type ListenerCallback = (data: T) => void;\n\nclass ChangeNotifier {\n private static listeners: Record>> = {};\n private static notifierState: Record = {};\n\n private static validateEventName(eventName: string): void {\n if (!eventName || typeof eventName !== 'string') {\n throw new Error('Invalid event name');\n }\n }\n\n static notify(\n eventName: string,\n data: T,\n caller: string = 'audiox_notifier_default'\n ): void {\n this.validateEventName(eventName);\n\n const listenerCbs = ChangeNotifier.listeners[eventName];\n\n if (!listenerCbs) return;\n\n if (data !== null) {\n console.log(`NOTIFYING TO EVENT : ${eventName} - CALLER : ${caller}`);\n\n ChangeNotifier.notifierState[eventName] = {\n ...(ChangeNotifier.notifierState[eventName] || {}),\n ...data\n };\n\n listenerCbs.forEach((cb: ListenerCallback) => {\n cb(ChangeNotifier.notifierState[eventName]);\n });\n }\n }\n\n static listen(\n eventName: string,\n callback: ListenerCallback,\n state = {}\n ): () => void {\n this.validateEventName(eventName);\n\n if (typeof callback !== 'function') {\n throw new Error('Callback must be a function');\n }\n\n if (!ChangeNotifier.listeners[eventName]) {\n ChangeNotifier.notifierState[eventName] = state;\n ChangeNotifier.listeners[eventName] = new Set([callback]);\n } else {\n ChangeNotifier.listeners[eventName].add(callback);\n }\n\n return (): void => {\n const eventListeners = ChangeNotifier.listeners[eventName];\n\n if (!eventListeners) {\n console.log(`EVENT NOT FOUND : ${eventName}`);\n return;\n }\n\n console.log(`REMOVING EVENT LISTENER FOR EVENT : ${eventName}`);\n\n eventListeners.delete(callback);\n\n if (eventListeners.size === 0) {\n delete ChangeNotifier.listeners[eventName];\n }\n };\n }\n\n static multiListen(\n eventName: string,\n callbacks: ListenerCallback[],\n state = {}\n ): () => void {\n this.validateEventName(eventName);\n\n if (!Array.isArray(callbacks) || callbacks.length === 0) {\n throw new Error('Callbacks must be a non-empty array of functions');\n }\n\n const unsubscribeFunctions = callbacks.map((callback) =>\n ChangeNotifier.listen(eventName, callback, state)\n );\n\n return (): void => {\n unsubscribeFunctions.forEach((unsubscribe) => unsubscribe());\n };\n }\n\n // Retrieve the latest state data for a specific event\n static getLatestState(eventName: string): T | undefined {\n this.validateEventName(eventName);\n\n return ChangeNotifier.notifierState[eventName];\n }\n}\n\nexport default ChangeNotifier;\n","import { AudioX } from 'audio';\nimport { ERROR_MSG_MAP } from 'constants/common';\nimport { AudioEvents, AudioState, MediaTrack } from 'types';\nimport ChangeNotifier from './notifier';\n\nconst isValidArray = (arr: any[]) => arr && Array.isArray(arr) && arr.length;\nconst isValidFunction = (fn: any) =>\n fn instanceof Function && typeof fn === 'function';\n\nconst isValidObject = (obj: any) =>\n typeof obj === 'object' &&\n obj !== null &&\n obj instanceof Object &&\n Object.keys(obj).length;\n\nconst isValidWindow = typeof window !== undefined && window instanceof Window;\nconst loadedScripts: any = {};\n\nconst getReadableErrorMessage = (audioInstance: HTMLAudioElement) => {\n let message = '';\n const err = audioInstance.error;\n\n switch (err?.code) {\n case MediaError.MEDIA_ERR_ABORTED:\n message += ERROR_MSG_MAP['MEDIA_ERR_ABORTED'];\n break;\n case MediaError.MEDIA_ERR_NETWORK:\n message += ERROR_MSG_MAP['MEDIA_ERR_NETWORK'];\n break;\n case MediaError.MEDIA_ERR_DECODE:\n message += ERROR_MSG_MAP['MEDIA_ERR_DECODE'];\n break;\n case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:\n message += ERROR_MSG_MAP['MEDIA_ERR_SRC_NOT_SUPPORTED'];\n break;\n default:\n message += ERROR_MSG_MAP['DEFAULT'];\n break;\n }\n\n return message;\n};\n\nconst metaDataCreator = (mediaTrack: MediaTrack) => {\n const { title, album, artist, artwork } = mediaTrack;\n const artworkUrl = artwork ? artwork[0]?.src : '';\n const sizes = [\n '96x96',\n '128x128',\n '192x192',\n '256x256',\n '384x384',\n '512x512'\n ];\n const artworkMap = sizes.map((el) => {\n return { src: artworkUrl, sizes: el, type: 'image/png' };\n });\n const metaData = {\n title,\n album,\n artist,\n artwork: artworkMap\n };\n return metaData;\n};\n\nlet previousTrackPlayTime = 0;\nexport const calculateActualPlayedLength = (\n audioInstance: HTMLAudioElement,\n event?: keyof AudioEvents\n) => {\n const lengthSet = new Set();\n for (let i = 0; i < audioInstance.played.length; i++) {\n const startX = audioInstance.played.start(i);\n const endX = audioInstance.played.end(i);\n const width = endX - startX;\n lengthSet.add(width);\n }\n const lengthArr = [...lengthSet] as number[];\n const currentTrackPlayTime = lengthArr.reduce((acc, val) => acc + val, 0);\n\n previousTrackPlayTime = ['ENDED', 'TRACK_CHANGE', 'PAUSE'].includes(\n event as keyof AudioEvents\n )\n ? currentTrackPlayTime\n : previousTrackPlayTime;\n ChangeNotifier.notify('AUDIO_STATE', {\n currentTrackPlayTime,\n previousTrackPlayTime\n });\n};\n\nconst loadScript = (\n url: string,\n onLoad: () => void,\n name: string\n): Promise => {\n return new Promise((resolve, reject) => {\n if (window instanceof Window && window.document) {\n if (!loadedScripts[name]) {\n loadedScripts[name] = true;\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = url;\n script.async = true;\n script.onload = () => {\n onLoad();\n resolve();\n };\n document.head.appendChild(script);\n } else {\n onLoad();\n resolve();\n }\n } else {\n reject(`Window not ready unable to initialize ${name}`);\n }\n });\n};\n\nconst handleQueuePlayback = () => {\n const audio = new AudioX();\n let hasEnded = false;\n\n const audioStateListener = (state: AudioState) => {\n if (state.playbackState === 'ended' && !hasEnded) {\n const queue = audio.getQueue();\n hasEnded = true;\n if (queue && isValidArray(queue)) {\n audio.playNext();\n }\n }\n if (state.playbackState !== 'ended') {\n hasEnded = false;\n }\n };\n\n ChangeNotifier.listen('AUDIO_STATE', audioStateListener);\n};\n\nconst getBufferedDuration = (audioInstance: HTMLAudioElement) => {\n const { buffered } = audioInstance;\n let bufferedDuration = 0;\n\n for (let i = 0; i < buffered.length; i++) {\n bufferedDuration += buffered.end(i) - buffered.start(i);\n }\n\n return bufferedDuration;\n};\n\nconst shuffle = (array: T[]): T[] => {\n const shuffledArray = [...array];\n\n for (let i = shuffledArray.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * i);\n\n [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];\n }\n\n return shuffledArray;\n};\n\nexport {\n getBufferedDuration,\n getReadableErrorMessage,\n handleQueuePlayback,\n isValidArray,\n isValidFunction,\n isValidObject,\n isValidWindow,\n loadScript,\n metaDataCreator,\n shuffle\n};\n","import { AudioX } from 'audio';\nimport { bands, presets } from 'constants/equalizer';\nimport { isValidArray } from 'helpers/common';\n\nimport { EqualizerStatus, Preset } from 'types/equalizer.types';\n\nclass Equalizer {\n private static _instance: Equalizer;\n private audioCtx: AudioContext;\n private audioCtxStatus: EqualizerStatus;\n private eqFilterBands: BiquadFilterNode[];\n\n /**\n * Creates an instance of Equalizer or returns the existing instance.\n */\n constructor() {\n if (Equalizer._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instances of Equalizer. Returning existing instance.'\n );\n return Equalizer._instance;\n }\n\n this.initializeAudioContext();\n\n Equalizer._instance = this;\n }\n\n /**\n * Initializes the AudioContext, ensuring compatibility with older browsers.\n * @private\n */\n private initializeAudioContext() {\n if (typeof AudioContext !== 'undefined') {\n this.audioCtx = new AudioContext();\n } else if (typeof (window as any).webkitAudioContext !== 'undefined') {\n this.audioCtx = new (window as any).webkitAudioContext();\n } else {\n console.error('Web Audio API is not supported in this browser.');\n }\n\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n\n if (this.audioCtx.state === 'suspended') {\n this.addResumeListener();\n }\n }\n\n /**\n * Adds a listener to resume the AudioContext on user interaction.\n * @private\n */\n private addResumeListener() {\n const resume = () => {\n this.audioCtx.resume();\n setTimeout(() => {\n if (this.audioCtx.state === 'running') {\n document.body.removeEventListener('click', resume, false);\n }\n }, 0);\n };\n\n document.body.addEventListener('click', resume, false);\n }\n\n /**\n * Initializes the equalizer by setting up the audio source and filter bands.\n */\n init() {\n try {\n const audioInstance = AudioX.getAudioInstance();\n const audioSource = this.audioCtx.createMediaElementSource(audioInstance);\n\n const equalizerBands = bands.map((band) => {\n const filter = this.audioCtx.createBiquadFilter();\n filter.type = band.type;\n filter.frequency.value = band.frequency;\n filter.gain.value = band.gain;\n filter.Q.value = 1;\n return filter;\n });\n\n const gainNode = this.audioCtx.createGain();\n gainNode.gain.value = 1; // TODO: Normalize sound output\n\n audioSource.connect(equalizerBands[0]);\n\n for (let i = 0; i < equalizerBands.length - 1; i++) {\n equalizerBands[i].connect(equalizerBands[i + 1]);\n }\n\n equalizerBands[equalizerBands.length - 1].connect(gainNode);\n gainNode.connect(this.audioCtx.destination);\n\n this.audioCtxStatus = 'ACTIVE';\n this.eqFilterBands = equalizerBands;\n } catch (error) {\n console.error('Equalizer initialization failed:', error);\n this.audioCtxStatus = 'FAILED';\n }\n }\n\n /**\n * Sets the equalizer to a predefined preset.\n * @param {keyof Preset} id - The ID of the preset to apply.\n */\n setPreset(id: keyof Preset) {\n const preset = presets.find((el) => el.id === id);\n if (!preset) {\n console.error('Preset not found:', id);\n return;\n }\n\n if (\n !this.eqFilterBands ||\n this.eqFilterBands.length !== preset.gains.length\n ) {\n console.error('Invalid data provided.');\n return;\n }\n\n this.eqFilterBands.forEach((band, index) => {\n band.gain.value = preset.gains[index];\n });\n }\n\n /**\n * Retrieves the list of available presets.\n * @returns {Preset[]} The list of available presets.\n */\n static getPresets() {\n return presets;\n }\n\n /**\n * Gets the current status of the AudioContext.\n * @returns {EqualizerStatus} The current status of the AudioContext.\n */\n status() {\n if (this.audioCtx.state === 'suspended') {\n this.audioCtx.resume();\n }\n return this.audioCtxStatus;\n }\n\n /**\n * Sets a custom equalizer configuration.\n * @param {number[]} gains - The gain values for each band.\n */\n setCustomEQ(gains: number[]) {\n if (isValidArray(gains)) {\n this.eqFilterBands.forEach((band: BiquadFilterNode, index: number) => {\n band.gain.value = gains[index];\n });\n } else {\n console.error('Invalid array of gains provided.');\n }\n }\n}\n\nexport { Equalizer };\n","import { PLAYBACK_STATE } from 'constants/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { HlsEventsCallbackMap } from 'types/audioEvents.types';\n\nexport const HLS_EVENTS_CALLBACK_MAP: HlsEventsCallbackMap = {\n ERROR: (e: Event, data: any) => {\n const type = data.type;\n const detail = data.details;\n const isFatal = data.fatal;\n console.log('STATUS', e.type);\n\n ChangeNotifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ERROR,\n error: {\n type,\n isFatal,\n detail\n }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n FRAG_CHANGED: () => {\n console.log('FRAG_CHANGED');\n }\n};\n","import { AudioEvents } from 'types';\n\nexport const AUDIO_EVENTS: AudioEvents = Object.freeze({\n ABORT: 'abort',\n TIME_UPDATE: 'timeupdate',\n CAN_PLAY: 'canplay',\n CAN_PLAY_THROUGH: 'canplaythrough',\n DURATION_CHANGE: 'durationchange',\n ENDED: 'ended',\n EMPTIED: 'emptied',\n PLAYING: 'playing',\n WAITING: 'waiting',\n SEEKING: 'seeking',\n SEEKED: 'seeked',\n LOADED_META_DATA: 'loadedmetadata',\n LOADED_DATA: 'loadeddata',\n PLAY: 'play',\n PAUSE: 'pause',\n RATE_CHANGE: 'ratechange',\n VOLUME_CHANGE: 'volumechange',\n SUSPEND: 'suspend',\n STALLED: 'stalled',\n PROGRESS: 'progress',\n LOAD_START: 'loadstart',\n ERROR: 'error',\n TRACK_CHANGE: 'trackchange' // this is a custom event added to support track change\n});\n\nexport const HLS_EVENTS = {\n MEDIA_ATTACHING: 'hlsMediaAttaching',\n MEDIA_ATTACHED: 'hlsMediaAttached',\n MEDIA_DETACHING: 'hlsMediaDetaching',\n MEDIA_DETACHED: 'hlsMediaDetached',\n BUFFER_RESET: 'hlsBufferReset',\n BUFFER_CODECS: 'hlsBufferCodecs',\n BUFFER_CREATED: 'hlsBufferCreated',\n BUFFER_APPENDING: 'hlsBufferAppending',\n BUFFER_APPENDED: 'hlsBufferAppended',\n BUFFER_EOS: 'hlsBufferEos',\n BUFFER_FLUSHING: 'hlsBufferFlushing',\n BUFFER_FLUSHED: 'hlsBufferFlushed',\n MANIFEST_LOADING: 'hlsManifestLoading',\n MANIFEST_LOADED: 'hlsManifestLoaded',\n MANIFEST_PARSED: 'hlsManifestParsed',\n LEVEL_SWITCHING: 'hlsLevelSwitching',\n LEVEL_SWITCHED: 'hlsLevelSwitched',\n LEVEL_LOADING: 'hlsLevelLoading',\n LEVEL_LOADED: 'hlsLevelLoaded',\n LEVEL_UPDATED: 'hlsLevelUpdated',\n LEVEL_PTS_UPDATED: 'hlsLevelPtsUpdated',\n LEVELS_UPDATED: 'hlsLevelsUpdated',\n AUDIO_TRACKS_UPDATED: 'hlsAudioTracksUpdated',\n AUDIO_TRACK_SWITCHING: 'hlsAudioTrackSwitching',\n AUDIO_TRACK_SWITCHED: 'hlsAudioTrackSwitched',\n AUDIO_TRACK_LOADING: 'hlsAudioTrackLoading',\n AUDIO_TRACK_LOADED: 'hlsAudioTrackLoaded',\n SUBTITLE_TRACKS_UPDATED: 'hlsSubtitleTracksUpdated',\n SUBTITLE_TRACKS_CLEARED: 'hlsSubtitleTracksCleared',\n SUBTITLE_TRACK_SWITCH: 'hlsSubtitleTrackSwitch',\n SUBTITLE_TRACK_LOADING: 'hlsSubtitleTrackLoading',\n SUBTITLE_TRACK_LOADED: 'hlsSubtitleTrackLoaded',\n SUBTITLE_FRAG_PROCESSED: 'hlsSubtitleFragProcessed',\n CUES_PARSED: 'hlsCuesParsed',\n NON_NATIVE_TEXT_TRACKS_FOUND: 'hlsNonNativeTextTracksFound',\n INIT_PTS_FOUND: 'hlsInitPtsFound',\n FRAG_LOADING: 'hlsFragLoading',\n FRAG_LOAD_EMERGENCY_ABORTED: 'hlsFragLoadEmergencyAborted',\n FRAG_LOADED: 'hlsFragLoaded',\n FRAG_DECRYPTED: 'hlsFragDecrypted',\n FRAG_PARSING_INIT_SEGMENT: 'hlsFragParsingInitSegment',\n FRAG_PARSING_USERDATA: 'hlsFragParsingUserdata',\n FRAG_PARSING_METADATA: 'hlsFragParsingMetadata',\n FRAG_PARSED: 'hlsFragParsed',\n FRAG_BUFFERED: 'hlsFragBuffered',\n FRAG_CHANGED: 'hlsFragChanged',\n FPS_DROP: 'hlsFpsDrop',\n FPS_DROP_LEVEL_CAPPING: 'hlsFpsDropLevelCapping',\n ERROR: 'hlsError',\n DESTROYING: 'hlsDestroying',\n KEY_LOADING: 'hlsKeyLoading',\n KEY_LOADED: 'hlsKeyLoaded',\n LIVE_BACK_BUFFER_REACHED: 'hlsLiveBackBufferReached',\n BACK_BUFFER_REACHED: 'hlsBackBufferReached'\n};\n\nexport const CUSTOM_AUDIO_EVENTS = Object.freeze({\n AUDIO_X_STATE: 'AUDIO_X_STATE'\n});\n","import HlsAdapter from 'adapters/hls';\nimport { AudioX } from 'audio';\nimport { isValidArray } from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport {\n AudioEvents,\n EventListenerCallbackMap,\n EventListenersList,\n HlsEvents,\n HlsEventsCallbackMap\n} from 'types/audioEvents.types';\nimport { HlsListeners } from '../types/hls.js.js';\nimport { AUDIO_EVENTS, HLS_EVENTS } from './audioEvents';\n\n/**\n * this attaches event listeners, for audio also sends a flag to calculate playLog\n * loops through the event listeners map and attaches it to the audio element\n */\nconst attachEventListeners = (\n eventListenersCallbackMap: EventListenerCallbackMap,\n playLogEnabled: boolean = false\n) => {\n const audioInstance = AudioX.getAudioInstance();\n isValidArray(Object.keys(eventListenersCallbackMap)) &&\n Object.keys(eventListenersCallbackMap).forEach((evt) => {\n let event = evt as keyof AudioEvents;\n audioInstance?.addEventListener(AUDIO_EVENTS[event], (e: Event) => {\n if (evt && eventListenersCallbackMap[event]) {\n const listenerCallback = eventListenersCallbackMap[event];\n if (typeof listenerCallback === 'function') {\n listenerCallback(e, audioInstance, playLogEnabled);\n }\n }\n });\n });\n};\n\nconst attachCustomEventListeners = (\n eventListenersList: EventListenersList,\n enablePlayLog: boolean = false\n) => {\n const audioInstance = AudioX.getAudioInstance();\n if (isValidArray(eventListenersList)) {\n eventListenersList.forEach((evt) => {\n let event = evt as keyof AudioEvents;\n if (Object.keys(AUDIO_EVENTS).includes(event)) {\n audioInstance?.addEventListener(AUDIO_EVENTS[event], (e: Event) => {\n ChangeNotifier.notify(AUDIO_EVENTS[event], {\n e,\n audioInstance,\n enablePlayLog\n });\n });\n }\n });\n }\n};\n\nconst attachHlsEventsListeners = (\n hlsEventlistenerCallbackMap: HlsEventsCallbackMap,\n playLogEnabled: boolean = false\n) => {\n const hls = new HlsAdapter();\n const hlsInstance = hls.getHlsInstance();\n isValidArray(Object.keys(hlsEventlistenerCallbackMap)) &&\n Object.keys(hlsEventlistenerCallbackMap).forEach((evt) => {\n let event = evt as keyof HlsEvents;\n hlsInstance.on(\n HLS_EVENTS[event] as keyof HlsListeners,\n (e: any, data: any) => {\n if (event && hlsEventlistenerCallbackMap[event]) {\n const listenerCallback = hlsEventlistenerCallbackMap[event];\n if (typeof listenerCallback === 'function') {\n listenerCallback(e, data, hlsInstance, playLogEnabled);\n }\n }\n }\n );\n });\n};\n\nexport {\n attachCustomEventListeners,\n attachEventListeners,\n attachHlsEventsListeners\n};\n","declare global {\n interface Window {\n Hls: any;\n }\n}\n\nimport { AudioX } from 'audio';\nimport { URLS } from 'constants/common';\nimport { HLS_EVENTS_CALLBACK_MAP } from 'events/hlsEvents';\nimport { attachHlsEventsListeners } from 'events/listeners';\nimport { loadScript } from 'helpers/common';\nimport { MediaTrack } from 'types';\nimport type Hls from 'types/hls.js.js';\nimport type { HlsConfig } from 'types/hls.js.js';\n\nlet hlsInstance: Hls;\n\nclass HlsAdapter {\n private static _instance: HlsAdapter;\n private HlsClass: typeof Hls;\n\n constructor() {\n if (HlsAdapter._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of HLS returning existing instance'\n );\n return HlsAdapter._instance;\n }\n HlsAdapter._instance = this;\n }\n\n async load() {\n await loadScript(\n URLS.HLS,\n () => {\n console.log('HLS Loaded');\n },\n 'hls'\n )\n .then(() => {\n this.HlsClass = window.Hls;\n window.Hls = undefined;\n })\n .catch((msg: string) => {\n console.log(msg);\n });\n\n return this.HlsClass;\n }\n\n async init(config: HlsConfig | {} = {}, enablePlayLog: boolean) {\n const Hls = await this.load();\n if (Hls.isSupported()) {\n hlsInstance = new Hls(config);\n attachHlsEventsListeners(HLS_EVENTS_CALLBACK_MAP, enablePlayLog);\n }\n }\n\n addHlsMedia(mediaTrack: MediaTrack) {\n const Hls = this.HlsClass;\n const audioInstance = AudioX.getAudioInstance();\n hlsInstance.loadSource(mediaTrack.source);\n hlsInstance.attachMedia(audioInstance);\n hlsInstance.on(Hls.Events.MEDIA_ATTACHED, function () {\n console.log('hls media attached');\n });\n }\n\n getHlsInstance() {\n return hlsInstance;\n }\n}\n\nexport default HlsAdapter;\n","import { ErrorEvents } from 'types/errorEvents.types';\n\nexport const ERROR_EVENTS: ErrorEvents = Object.freeze({\n 1: 'MEDIA_ERR_ABORTED',\n 3: 'MEDIA_ERR_DECODE',\n 2: 'MEDIA_ERR_NETWORK',\n 4: 'MEDIA_ERR_SRC_NOT_SUPPORTED',\n});\n","import { PLAYBACK_STATE } from 'constants/common';\nimport {\n calculateActualPlayedLength,\n getBufferedDuration,\n getReadableErrorMessage\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState, EventListenerCallbackMap } from 'types';\nimport { ERROR_EVENTS } from './errorEvents';\n\nconst notifier = ChangeNotifier;\n\nconst BASE_EVENT_CALLBACK_MAP: EventListenerCallbackMap = {\n LOAD_START: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n DURATION_CHANGE: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'playing'\n ? PLAYBACK_STATE.PLAYING // fix for live streams where duration change is fired even when audio is playing\n : PLAYBACK_STATE.DURATION_CHANGE,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n LOADED_META_DATA: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n LOADED_DATA: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'paused'\n ? PLAYBACK_STATE.PAUSED\n : PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n } as AudioState,\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY_THROUGH: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const isPaused = audioInstance.paused;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n // below we check if the audio was already in paused state then we keep it as paused instead going to ready this make sure ready is fired only on the first load.\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: isPaused\n ? PLAYBACK_STATE.PAUSED\n : audioState.playbackState === 'playing'\n ? PLAYBACK_STATE.PLAYING // fix for live streams as canplaythrough event is can be behave weirdly as there is no known end to the media\n : PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PLAY: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PLAYING: (e, audioInstance) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PAUSE: (e: Event, audioInstance: HTMLAudioElement, playLogEnabled) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PAUSED,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n if (playLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'PAUSE');\n }\n },\n\n ENDED: (e: Event, audioInstance: HTMLAudioElement, playLogEnabled) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ENDED,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n if (playLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'ENDED');\n }\n },\n\n ERROR: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const errorCode = audioInstance.error?.code as keyof typeof ERROR_EVENTS;\n const message = getReadableErrorMessage(audioInstance);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ERROR,\n error: {\n code: errorCode,\n message: ERROR_EVENTS[errorCode],\n readable: message\n }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n TIME_UPDATE: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: audioInstance.paused\n ? audioState?.playbackState\n : PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n WAITING: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n VOLUME_CHANGE: (e: Event) => {\n console.log('STATUS', e.type);\n notifier.notify('AUDIO_STATE', {}, `audiox_baseEvents_state`);\n },\n\n SEEKED: (e: any, audioInstance: HTMLAudioElement) => {\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'paused'\n ? 'paused'\n : audioState.playbackState,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n } as AudioState,\n `audiox_baseEvents_state_${e.type}`\n );\n }\n};\n\nexport { BASE_EVENT_CALLBACK_MAP };\n","import { AudioX } from 'audio';\nimport { metaDataCreator } from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState } from 'types';\n\nexport const updateMetaData = (data: any) => {\n if ('mediaSession' in navigator) {\n navigator.mediaSession.metadata = new MediaMetadata(metaDataCreator(data));\n }\n};\n\nexport const attachMediaSessionHandlers = () => {\n const audio = new AudioX();\n if ('mediaSession' in navigator) {\n navigator.mediaSession.setActionHandler('play', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.play();\n });\n\n navigator.mediaSession.setActionHandler('pause', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.pause();\n });\n\n // Only add next and previous handler if there is a valid queue\n if (audio.getQueue().length) {\n navigator.mediaSession.setActionHandler('previoustrack', () => {\n audio.playPrevious();\n });\n\n navigator.mediaSession.setActionHandler('nexttrack', () => {\n audio.playNext();\n });\n }\n }\n};\n\nexport const updatePositionState = () => {\n ChangeNotifier.listen('AUDIO_X_STATE', (audioState: AudioState) => {\n if (\n audioState?.duration &&\n audioState?.playbackRate &&\n audioState?.progress\n ) {\n navigator.mediaSession.setPositionState({\n duration: audioState.duration,\n playbackRate: audioState.playbackRate,\n position: audioState.progress\n });\n }\n });\n};\n","import { PLAYBACK_STATE } from 'constants/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { ReadyState } from 'types';\nimport { AudioState, MediaTrack } from 'types/audio.types';\n\nexport const READY_STATE: ReadyState = {\n HAVE_NOTHING: 0,\n HAVE_METADATA: 1,\n HAVE_CURRENT_DATA: 2,\n HAVE_FUTURE_DATA: 3,\n HAVE_ENOUGH_DATA: 4\n};\n\nexport const AUDIO_STATE: AudioState = {\n playbackState: PLAYBACK_STATE.IDLE,\n duration: 0,\n bufferedDuration: 0,\n progress: 0,\n volume: 50,\n playbackRate: 1,\n error: {\n code: null,\n message: '',\n readable: ''\n },\n currentTrack: {} as MediaTrack,\n currentTrackPlayTime: 0,\n previousTrackPlayTime: 0\n};\n\n/* Listen to state changes and update global audio state that is being exposed to outer world\n Do not subscribe to this event, this may cause unexpected behavior instead attach your own custom\n event listener, if you wish to have granular control on audio state. See: attachCustomEventListener \n*/\nChangeNotifier.listen(\n 'AUDIO_STATE',\n (audioState: AudioState) => {\n ChangeNotifier.notify('AUDIO_X_STATE', { ...AUDIO_STATE, ...audioState });\n },\n AUDIO_STATE\n);\n","import { Equalizer } from 'adapters/equalizer';\nimport HlsAdapter from 'adapters/hls';\nimport { AUDIO_X_CONSTANTS, PLAYBACK_STATE } from 'constants/common';\nimport { BASE_EVENT_CALLBACK_MAP } from 'events/baseEvents';\nimport { attachEventListeners } from 'events/listeners';\nimport {\n calculateActualPlayedLength,\n handleQueuePlayback,\n isValidArray,\n isValidFunction,\n shuffle\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\n\nimport {\n attachMediaSessionHandlers,\n updateMetaData\n} from 'mediasession/mediasessionHandler';\nimport { READY_STATE } from 'states/audioState';\nimport {\n AudioInit,\n MediaTrack,\n PlaybackRate,\n QueuePlaybackType\n} from 'types/audio.types';\nimport { EqualizerStatus, Preset } from 'types/equalizer.types';\n\nlet audioInstance: HTMLAudioElement;\nconst notifier = ChangeNotifier;\n\nclass AudioX {\n private _audio: HTMLAudioElement;\n private isPlayLogEnabled: Boolean;\n private static _instance: AudioX;\n private _queue: MediaTrack[];\n private _currentQueueIndex: number = 0;\n private _fetchFn: (mediaTrack: MediaTrack) => Promise;\n private eqStatus: EqualizerStatus = 'IDEAL';\n private isEqEnabled: boolean = false;\n private eqInstance: Equalizer;\n private showNotificationsActions: boolean = false;\n\n constructor() {\n if (AudioX._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of AudioX returning existing instance'\n );\n return AudioX._instance;\n }\n if (\n process.env.NODE_ENV !== AUDIO_X_CONSTANTS?.DEVELOPMENT &&\n audioInstance\n ) {\n throw new Error('Cannot create multiple audio instance');\n }\n\n AudioX._instance = this;\n this._audio = new Audio();\n audioInstance = this._audio;\n }\n\n /**\n *\n * @param initProps initial config to initialize AudioX\n * @param initProps.mediaTrack mediaTrack Object containing metadata and source of the media\n * @param initProps.mediaTrack.title title of the Audio\n * @param initProps.mediaTrack.source URI of the Audio\n * @param initProps.mediaTrack.artwork artwork of the Audio\n * @param initProps.mediaTrack.duration duration of the audio\n * @param initProps.mediaTrack.genre genre of the audio\n * @param initProps.mediaTrack.album album of the audio\n * @param initProps.mediaTrack.comment comment for the audio\n * @param initProps.mediaTrack.year release year of the audio\n * @param initProps.mediaTrack.artist artist of the audio\n * @param mode mode of operation for AudioX\n * @param autoplay flag for autoplay\n * @param preloadStrategy strategy for preloading audio\n * @param playbackRate default playbackRate of the audio\n * @param attachAudioEventListeners flag for registering audio events\n * @param attachMediaSessionHandlers flag for registering mediaSession handlers\n */\n\n async init(initProps: AudioInit) {\n const {\n preloadStrategy = 'auto',\n autoPlay = false,\n useDefaultEventListeners = true,\n customEventListeners = null,\n showNotificationActions = false,\n enablePlayLog = false,\n enableHls = false,\n enableEQ = false,\n crossOrigin = 'anonymous',\n hlsConfig = {}\n } = initProps;\n\n this._audio?.setAttribute('id', 'audio_x_instance');\n this._audio.preload = preloadStrategy;\n this._audio.autoplay = autoPlay;\n this._audio.crossOrigin = crossOrigin;\n this.isPlayLogEnabled = enablePlayLog;\n\n if (customEventListeners !== null) {\n if (useDefaultEventListeners) {\n console.warn(\n `useDefaultEventListeners is set to true at init, are you trying to use the default event listeners?\n set customEventListeners to null to use default event listeners`\n );\n }\n attachEventListeners(customEventListeners, false);\n } else {\n attachEventListeners(BASE_EVENT_CALLBACK_MAP, enablePlayLog);\n }\n\n if (showNotificationActions) {\n this.showNotificationsActions = true;\n attachMediaSessionHandlers();\n }\n\n if (enableEQ) {\n this.isEqEnabled = enableEQ;\n }\n\n if (enableHls) {\n const hls = new HlsAdapter();\n hls.init(hlsConfig, enablePlayLog);\n }\n }\n\n async addMedia(mediaTrack: MediaTrack) {\n if (!mediaTrack) {\n return;\n }\n\n const mediaType = mediaTrack.source.includes('.m3u8') ? 'HLS' : 'DEFAULT';\n\n if (this.isPlayLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'TRACK_CHANGE');\n }\n\n if (mediaType === 'HLS') {\n const hls = new HlsAdapter();\n const hlsInstance = hls.getHlsInstance();\n if (hlsInstance) {\n hlsInstance.detachMedia();\n hls.addHlsMedia(mediaTrack);\n } else {\n console.warn(\n 'The source provided seems to be a HLS stream but, hls playback is not enabled. Please have a look at init method of AudioX'\n );\n await this.reset();\n }\n } else {\n audioInstance.src = mediaTrack.source;\n }\n\n notifier.notify('AUDIO_STATE', {\n playbackState: PLAYBACK_STATE.TRACK_CHANGE,\n currentTrackPlayTime: 0,\n currentTrack: mediaTrack\n });\n\n updateMetaData(mediaTrack);\n audioInstance.load();\n }\n\n attachEq() {\n if (this.isEqEnabled && this.eqStatus === 'IDEAL') {\n try {\n const eq = new Equalizer();\n this.eqStatus = eq.status();\n this.eqInstance = eq;\n } catch (e) {\n console.log('failed to enable equalizer');\n }\n }\n }\n\n async play() {\n const isSourceAvailable = audioInstance.src !== '';\n if (\n audioInstance?.paused &&\n audioInstance.HAVE_ENOUGH_DATA === READY_STATE.HAVE_ENOUGH_DATA &&\n isSourceAvailable\n ) {\n await audioInstance\n .play()\n .then(() => {\n console.log('PLAYING');\n })\n .catch(() => {\n console.warn('cancelling current audio playback, track changed');\n });\n }\n }\n\n /**\n *\n * @param mediaTrack MediaTrack to be added and played\n *\n * Note: Use this method when you want to add media and do playback or want continuous playback\n * You can also call addMedia and Play Separately to achieve playback.\n */\n\n async addMediaAndPlay(\n mediaTrack?: MediaTrack | null,\n fetchFn?: (mediaTrack: MediaTrack) => Promise\n // this should be passed when there something needs to be done before the audio starts playing\n ) {\n const currentTrack =\n mediaTrack || (this._queue.length > 0 ? this._queue[0] : undefined);\n if (fetchFn && isValidFunction(fetchFn) && currentTrack) {\n this._fetchFn = fetchFn;\n await fetchFn(currentTrack as MediaTrack);\n }\n\n if (this._queue && isValidArray(this._queue)) {\n this._currentQueueIndex = this._queue.findIndex(\n (track) => track.id === currentTrack?.id\n );\n }\n try {\n if (currentTrack) {\n this.addMedia(currentTrack).then(() => {\n if (audioInstance.HAVE_ENOUGH_DATA === READY_STATE.HAVE_ENOUGH_DATA) {\n setTimeout(async () => {\n this.attachEq();\n await this.play();\n }, 950);\n }\n });\n } else {\n console.error('Playback Failed, No MediaTrack Provided');\n }\n } catch (error) {\n console.error('Playback Failed');\n }\n }\n\n pause() {\n if (audioInstance && !audioInstance?.paused) {\n audioInstance?.pause();\n }\n }\n\n stop() {\n if (audioInstance && !audioInstance.paused) {\n audioInstance?.pause();\n audioInstance.currentTime = 0;\n }\n }\n\n /**\n * @method reset : This stops the playback and resets all the state of the audio\n */\n async reset() {\n if (audioInstance) {\n this.stop();\n audioInstance.src = '';\n audioInstance.srcObject = null;\n }\n }\n\n /**\n * @param volume : numeric value between 1-100 to be used.\n */\n setVolume(volume: number) {\n const actualVolume = volume / 100;\n if (audioInstance) {\n audioInstance.volume = actualVolume;\n notifier.notify('AUDIO_STATE', {\n volume: volume\n });\n }\n }\n /**\n * @param playbackRate : a number denoting speed at which the playback should happen,\n */\n setPlaybackRate(playbackRate: PlaybackRate) {\n if (audioInstance) {\n audioInstance.playbackRate = playbackRate;\n notifier.notify('AUDIO_STATE', {\n playbackRate\n });\n }\n }\n\n mute() {\n if (audioInstance && !audioInstance.muted) {\n audioInstance.muted = true;\n }\n }\n\n seek(time: number) {\n if (audioInstance) {\n audioInstance.currentTime = time;\n }\n }\n\n seekBy(time: number) {\n if (audioInstance && audioInstance.currentTime) {\n const currentProgress = audioInstance.currentTime;\n audioInstance.currentTime = currentProgress + time;\n }\n }\n\n async destroy() {\n if (audioInstance) {\n await this.reset();\n audioInstance.removeAttribute('src');\n audioInstance.load();\n }\n }\n\n subscribe(eventName: string, callback: (data: any) => void, state: any = {}) {\n const unsubscribe = notifier.listen(eventName, callback, state);\n return unsubscribe;\n }\n\n addEventListener(\n event: keyof HTMLMediaElementEventMap,\n callback: (data: any) => void\n ) {\n audioInstance.addEventListener(event, callback);\n }\n\n getPresets() {\n return Equalizer.getPresets();\n }\n\n setPreset(id: keyof Preset) {\n this.eqInstance.setPreset(id);\n }\n\n setCustomEQ(gains: number[]) {\n this.eqInstance.setCustomEQ(gains);\n }\n\n addQueue(queue: MediaTrack[], playbackType: QueuePlaybackType) {\n const playerQueue = isValidArray(queue) ? queue.slice() : [];\n switch (playbackType) {\n case 'DEFAULT':\n this._queue = playerQueue;\n break;\n case 'REVERSE':\n this._queue = playerQueue.reverse();\n break;\n case 'SHUFFLE':\n this._queue = shuffle(playerQueue);\n break;\n default:\n this._queue = playerQueue;\n break;\n }\n handleQueuePlayback();\n // Attaching MediaSession Handler again as this will make sure the next and previous button show up in notification\n if (this.showNotificationsActions) {\n attachMediaSessionHandlers();\n }\n }\n\n playNext() {\n if (this._queue.length > this._currentQueueIndex + 1) {\n this._currentQueueIndex++;\n const nextTrack = this._queue[this._currentQueueIndex];\n this.addMediaAndPlay(nextTrack, this._fetchFn);\n } else {\n console.warn('Queue ended');\n }\n }\n\n playPrevious() {\n if (this._currentQueueIndex > 0) {\n this._currentQueueIndex--;\n const previousTrack = this._queue[this._currentQueueIndex];\n this.addMediaAndPlay(previousTrack, this._fetchFn);\n } else {\n console.log('At the beginning of the queue');\n }\n }\n\n clearQueue() {\n if (this._queue && isValidArray(this._queue)) {\n this._queue = [];\n }\n }\n\n addToQueue(mediaTracks: MediaTrack | MediaTrack[]) {\n if (this._queue && isValidArray(this._queue)) {\n if (Array.isArray(mediaTracks)) {\n this._queue = [...this._queue, ...mediaTracks];\n } else {\n this._queue.push(mediaTracks);\n }\n }\n }\n\n removeFromQueue(mediaTrack: MediaTrack) {\n if (this._queue && isValidArray(this._queue)) {\n const queue = this._queue.filter(\n (track: MediaTrack) => track.id == mediaTrack.id\n );\n this._queue = queue;\n }\n }\n\n getQueue() {\n return this._queue && isValidArray(this._queue) ? this._queue : [];\n }\n\n get id() {\n return audioInstance?.getAttribute('id');\n }\n\n static getAudioInstance() {\n return audioInstance;\n }\n}\n\nexport { AudioX };\n"]} \ No newline at end of file +{"version":3,"sources":["../src/constants/equalizer.ts","../src/constants/common.ts","../src/helpers/notifier.ts","../src/helpers/common.ts","../src/adapters/equalizer.ts","../src/events/hlsEvents.ts","../src/events/audioEvents.ts","../src/events/listeners.ts","../src/adapters/hls.ts","../src/events/errorEvents.ts","../src/events/baseEvents.ts","../src/mediasession/mediasessionHandler.ts","../src/states/audioState.ts","../src/audio.ts"],"names":["bands","frequency","type","gain","q","presets","name","id","default","gains","AUDIO_X_CONSTANTS","Object","freeze","REACT","VANILLA","DEVELOPMENT","PLAYBACK_STATE","BUFFERING","PLAYING","PAUSED","READY","IDLE","ENDED","STALLED","ERROR","TRACK_CHANGE","DURATION_CHANGE","QUEUE_ENDED","ERROR_MSG_MAP","MEDIA_ERR_ABORTED","MEDIA_ERR_DECODE","MEDIA_ERR_NETWORK","MEDIA_ERR_SRC_NOT_SUPPORTED","DEFAULT","URLS","HLS","CAST","_a","ChangeNotifier","validateEventName","eventName","Error","notify","data","caller","listenerCbs","listeners","notifierState","__spreadValues","forEach","cb","listen","callback","state","add","Set","eventListeners","delete","size","multiListen","callbacks","Array","isArray","length","unsubscribeFunctions","map","unsubscribe","getLatestState","__publicField","notifier_default","isValidArray","__name","arr","isValidFunction","fn","Function","isValidWindow","loadedScripts","getReadableErrorMessage","audioInstance","message","err","error","code","MediaError","metaDataCreator","mediaTrack","title","album","artist","artwork","artworkUrl","src","artworkMap","el","sizes","previousTrackPlayTime","calculateActualPlayedLength","event","lengthSet","i","played","startX","start","width","end","currentTrackPlayTime","reduce","acc","val","includes","loadScript","url","onLoad","Promise","resolve","reject","window","Window","document","script","createElement","async","onload","head","appendChild","handleQueuePlayback","audio","AudioX","hasEnded","audioStateListener","playbackState","queue","getQueue","playNext","getBufferedDuration","buffered","bufferedDuration","shuffle","array","shuffledArray","j","Math","floor","random","diffChecker","d1","d2","every","item","index","keys1","keys","keys2","key","Equalizer","constructor","audioCtx","audioCtxStatus","eqFilterBands","bassBoostFilter","compressor","_instance","initializeAudioContext","audioContextOptions","latencyHint","AudioContext","webkitAudioContext","init","addResumeListener","resume","setTimeout","body","removeEventListener","addEventListener","getAudioInstance","audioSource","createMediaElementSource","equalizerBands","band","filter","createBiquadFilter","value","Q","createDynamicsCompressor","threshold","knee","ratio","attack","release","connect","destination","setPreset","preset","find","currentTime","targetGain","setTargetAtTime","getPresets","status","setCustomEQ","setBassBoost","enable","setCompressorSettings","options","undefined","reset","HLS_EVENTS_CALLBACK_MAP","e","detail","details","isFatal","fatal","FRAG_CHANGED","AUDIO_EVENTS","ABORT","TIME_UPDATE","CAN_PLAY","CAN_PLAY_THROUGH","EMPTIED","WAITING","SEEKING","SEEKED","LOADED_META_DATA","LOADED_DATA","PLAY","PAUSE","RATE_CHANGE","VOLUME_CHANGE","SUSPEND","PROGRESS","LOAD_START","HLS_EVENTS","MEDIA_ATTACHING","MEDIA_ATTACHED","MEDIA_DETACHING","MEDIA_DETACHED","BUFFER_RESET","BUFFER_CODECS","BUFFER_CREATED","BUFFER_APPENDING","BUFFER_APPENDED","BUFFER_EOS","BUFFER_FLUSHING","BUFFER_FLUSHED","MANIFEST_LOADING","MANIFEST_LOADED","MANIFEST_PARSED","LEVEL_SWITCHING","LEVEL_SWITCHED","LEVEL_LOADING","LEVEL_LOADED","LEVEL_UPDATED","LEVEL_PTS_UPDATED","LEVELS_UPDATED","AUDIO_TRACKS_UPDATED","AUDIO_TRACK_SWITCHING","AUDIO_TRACK_SWITCHED","AUDIO_TRACK_LOADING","AUDIO_TRACK_LOADED","SUBTITLE_TRACKS_UPDATED","SUBTITLE_TRACKS_CLEARED","SUBTITLE_TRACK_SWITCH","SUBTITLE_TRACK_LOADING","SUBTITLE_TRACK_LOADED","SUBTITLE_FRAG_PROCESSED","CUES_PARSED","NON_NATIVE_TEXT_TRACKS_FOUND","INIT_PTS_FOUND","FRAG_LOADING","FRAG_LOAD_EMERGENCY_ABORTED","FRAG_LOADED","FRAG_DECRYPTED","FRAG_PARSING_INIT_SEGMENT","FRAG_PARSING_USERDATA","FRAG_PARSING_METADATA","FRAG_PARSED","FRAG_BUFFERED","FPS_DROP","FPS_DROP_LEVEL_CAPPING","DESTROYING","KEY_LOADING","KEY_LOADED","LIVE_BACK_BUFFER_REACHED","BACK_BUFFER_REACHED","attachEventListeners","eventListenersCallbackMap","playLogEnabled","evt","listenerCallback","attachHlsEventsListeners","hlsEventlistenerCallbackMap","hlsInstance","HlsAdapter","getHlsInstance","on","HlsClass","load","__async","then","Hls","catch","msg","config","enablePlayLog","isSupported","addHlsMedia","loadSource","source","attachMedia","Events","hls_default","ERROR_EVENTS","notifier","BASE_EVENT_CALLBACK_MAP","duration","readable","audioState","isPaused","paused","progress","errorCode","updateMetaData","navigator","mediaSession","metadata","MediaMetadata","attachMediaSessionHandlers","setActionHandler","play","pause","playPrevious","READY_STATE","HAVE_NOTHING","HAVE_METADATA","HAVE_CURRENT_DATA","HAVE_FUTURE_DATA","HAVE_ENOUGH_DATA","AUDIO_STATE","volume","playbackRate","currentTrack","latestState","_audio","isPlayLogEnabled","_queue","_currentQueueIndex","_fetchFn","eqStatus","isEqEnabled","eqInstance","showNotificationsActions","process","env","NODE_ENV","Audio","initProps","preloadStrategy","autoPlay","useDefaultEventListeners","customEventListeners","showNotificationActions","enableHls","enableEQ","crossOrigin","hlsConfig","setAttribute","preload","autoplay","addMedia","mediaFetchFn","findIndex","track","mediaType","canPlayType","hls","detachMedia","attachEq","eq","isSourceAvailable","addMediaAndPlay","fetchFn","stop","srcObject","setVolume","actualVolume","setPlaybackRate","mute","muted","seek","time","seekBy","currentProgress","destroy","removeAttribute","subscribe","enabled","boost","addQueue","playbackType","clearQueue","playerQueue","slice","reverse","nextTrack","previousTrack","addToQueue","mediaTracks","push","removeFromQueue","getAttribute"],"mappings":"kpBAEA,IAAMA,CAAAA,CAAgB,CACpB,CAAEC,SAAW,CAAA,EAAA,CAAIC,IAAM,CAAA,UAAA,CAAYC,IAAM,CAAA,CAAA,CAAGC,CAAG,CAAA,GAAI,CACnD,CAAA,CAAEH,UAAW,EAAIC,CAAAA,IAAAA,CAAM,SAAWC,CAAAA,IAAAA,CAAM,CAAGC,CAAAA,CAAAA,CAAG,GAAI,CAAA,CAClD,CAAEH,SAAAA,CAAW,GAAKC,CAAAA,IAAAA,CAAM,SAAWC,CAAAA,IAAAA,CAAM,EAAGC,CAAG,CAAA,GAAI,CACnD,CAAA,CAAEH,SAAW,CAAA,GAAA,CAAKC,IAAM,CAAA,SAAA,CAAWC,IAAM,CAAA,CAAA,CAAGC,CAAG,CAAA,GAAI,CACnD,CAAA,CAAEH,SAAW,CAAA,GAAA,CAAKC,IAAM,CAAA,SAAA,CAAWC,IAAM,CAAA,CAAA,CAAGC,CAAG,CAAA,GAAI,CACnD,CAAA,CAAEH,SAAW,CAAA,GAAA,CAAMC,IAAM,CAAA,SAAA,CAAWC,IAAM,CAAA,CAAA,CAAGC,EAAG,GAAI,CAAA,CACpD,CAAEH,SAAAA,CAAW,GAAMC,CAAAA,IAAAA,CAAM,SAAWC,CAAAA,IAAAA,CAAM,CAAGC,CAAAA,CAAAA,CAAG,GAAI,CAAA,CACpD,CAAEH,SAAAA,CAAW,IAAMC,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,CAAAA,CAAe2U,CAAAA,YAAAA,CAAa,IACrC,CAAA,CAEA,OAAO3O,gBAAAA,EAAmB,CACxB,OAAOhG,CACT,CACF,CA3aMiD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,QAAAA,CAAAA,CAGJ5D,CAHF/B,CAAAA,CAAAA,CAGiB6H,WAHjB7H,CAAAA,CAAAA,CAAAA","file":"index.js","sourcesContent":["import { Band } from 'types/equalizer.types';\n\nconst bands: Band[] = [\n { frequency: 31, type: 'lowshelf', gain: 0, q: 1.2 },\n { frequency: 63, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 125, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 250, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 500, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 1000, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 2000, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 4000, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 8000, type: 'peaking', gain: 0, q: 1.2 },\n { frequency: 16000, type: 'highshelf', gain: 0, q: 1.2 }\n];\n\nconst presets = [\n {\n name: 'Default',\n id: 'default',\n default: true,\n gains: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n },\n {\n name: 'Club',\n id: 'club',\n default: true,\n gains: [0.0, 0.0, 4.8, 3.36, 3.36, 3.36, 1.92, 0.0, 0.0, 0.0]\n },\n {\n name: 'Live',\n id: 'live',\n default: true,\n gains: [-2.88, 0.0, 2.4, 3.36, 3.36, 3.36, 2.4, 1.44, 1.44, 1.44]\n },\n {\n name: 'Party',\n id: 'Party',\n default: true,\n gains: [4.32, 4.32, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.32, 4.32]\n },\n {\n name: 'Pop',\n id: 'pop',\n default: true,\n gains: [0.96, 2.88, 4.32, 4.8, 3.36, 0.0, -1.44, -1.44, 0.96, 0.96]\n },\n {\n name: 'Soft',\n id: 'soft',\n default: true,\n gains: [2.88, 0.96, 0.0, -1.44, 0.0, 2.4, 4.8, 5.76, 6.72, 7.2]\n },\n {\n name: 'Ska',\n id: 'ska',\n default: true,\n gains: [-1.44, -2.88, -2.4, 0.0, 2.4, 3.36, 5.28, 5.76, 6.72, 5.76]\n },\n {\n name: 'Reggae',\n id: 'reggae',\n default: true,\n gains: [0.0, 0.0, 0.0, -3.36, 0.0, 3.84, 3.84, 0.0, 0.0, 0.0]\n },\n\n {\n name: 'Rock',\n id: 'rock',\n default: true,\n gains: [4.8, 2.88, -3.36, -4.8, -1.92, 2.4, 5.28, 6.72, 6.72, 6.72]\n },\n {\n name: 'Dance',\n id: 'dance',\n default: true,\n gains: [5.76, 4.32, 1.44, 0.0, 0.0, -3.36, -4.32, -4.32, 0.0, 0.0]\n },\n {\n name: 'Techno',\n id: 'techno',\n default: true,\n gains: [4.8, 3.36, 0.0, -3.36, -2.88, 0.0, 4.8, 5.76, 5.76, 5.28]\n },\n {\n name: 'Headphones',\n id: 'headphones',\n default: true,\n gains: [2.88, 6.72, 3.36, -1.92, -1.44, 0.96, 2.88, 5.76, 7.68, 8.64]\n },\n {\n name: 'Soft rock',\n id: 'soft_rock',\n default: true,\n gains: [2.4, 2.4, 1.44, 0.0, -2.4, -3.36, -1.92, 0.0, 1.44, 5.28]\n },\n {\n name: 'Classical',\n id: 'classical',\n default: true,\n gains: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -4.32, -4.32, -4.32, -5.76]\n },\n {\n name: 'Large Hall',\n id: 'large_hall',\n default: true,\n gains: [6.24, 6.24, 3.36, 3.36, 0.0, -2.88, -2.88, -2.88, 0.0, 0.0]\n },\n {\n name: 'Full Bass',\n id: 'full_base',\n default: true,\n gains: [4.8, 5.76, 5.76, 3.36, 0.96, -2.4, -4.8, -6.24, -6.72, -6.72]\n },\n {\n name: 'Full Treble',\n id: 'full_treble',\n default: true,\n gains: [-5.76, -5.76, -5.76, -2.4, 1.44, 6.72, 9.6, 9.6, 9.6, 10.08]\n },\n {\n name: 'Laptop Speakers',\n id: 'laptop_speakers',\n default: true,\n gains: [2.88, 6.72, 3.36, -1.92, -1.44, 0.96, 2.88, 5.76, 7.68, 8.64]\n },\n {\n name: 'Full Bass & Treble',\n id: 'bass_treble',\n default: true,\n gains: [4.32, 3.36, 0.0, -4.32, -2.88, 0.96, 4.8, 6.72, 7.2, 7.2]\n }\n];\n\nexport { bands, presets };\n","import { InitMode } from 'types';\nimport { ErrorMessageMap } from 'types/errorEvents.types';\n\nconst AUDIO_X_CONSTANTS = Object.freeze({\n REACT: 'REACT' as InitMode,\n VANILLA: 'VANILLA' as InitMode,\n DEVELOPMENT: 'development'\n});\n\nconst PLAYBACK_STATE = Object.freeze({\n BUFFERING: 'buffering',\n PLAYING: 'playing',\n PAUSED: 'paused',\n READY: 'ready',\n IDLE: 'idle',\n ENDED: 'ended',\n STALLED: 'stalled',\n ERROR: 'error',\n TRACK_CHANGE: 'trackchanged',\n DURATION_CHANGE: 'durationchanged',\n QUEUE_ENDED: 'queueended'\n});\n\nconst ERROR_MSG_MAP: ErrorMessageMap = Object.freeze({\n MEDIA_ERR_ABORTED: 'The user canceled the audio.',\n MEDIA_ERR_DECODE: 'An error occurred while decoding the audio.',\n MEDIA_ERR_NETWORK: 'A network error occurred while fetching the audio.',\n MEDIA_ERR_SRC_NOT_SUPPORTED:\n 'The audio is missing or is in a format not supported by your browser.',\n DEFAULT: 'An unknown error occurred.'\n});\n\nconst URLS = {\n HLS: 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.11/hls.min.js',\n CAST: 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'\n};\n\nexport { AUDIO_X_CONSTANTS, ERROR_MSG_MAP, PLAYBACK_STATE, URLS };\n","type ListenerCallback = (data: T) => void;\n\nclass ChangeNotifier {\n private static listeners: Record>> = {};\n private static notifierState: Record = {};\n\n private static validateEventName(eventName: string): void {\n if (!eventName || typeof eventName !== 'string') {\n throw new Error('Invalid event name');\n }\n }\n\n static notify(\n eventName: string,\n data: T,\n caller: string = 'audiox_notifier_default'\n ): void {\n this.validateEventName(eventName);\n\n const listenerCbs = ChangeNotifier.listeners[eventName];\n\n if (!listenerCbs) return;\n\n if (data !== null) {\n console.log(`NOTIFYING TO EVENT : ${eventName} - CALLER : ${caller}`);\n\n ChangeNotifier.notifierState[eventName] = {\n ...(ChangeNotifier.notifierState[eventName] || {}),\n ...data\n };\n\n listenerCbs.forEach((cb: ListenerCallback) => {\n cb(ChangeNotifier.notifierState[eventName]);\n });\n }\n }\n\n static listen(\n eventName: string,\n callback: ListenerCallback,\n state = {}\n ): () => void {\n this.validateEventName(eventName);\n\n if (typeof callback !== 'function') {\n throw new Error('Callback must be a function');\n }\n\n if (!ChangeNotifier.listeners[eventName]) {\n ChangeNotifier.notifierState[eventName] = state;\n ChangeNotifier.listeners[eventName] = new Set([callback]);\n } else {\n ChangeNotifier.listeners[eventName].add(callback);\n }\n\n return (): void => {\n const eventListeners = ChangeNotifier.listeners[eventName];\n\n if (!eventListeners) {\n console.log(`EVENT NOT FOUND : ${eventName}`);\n return;\n }\n\n console.log(`REMOVING EVENT LISTENER FOR EVENT : ${eventName}`);\n\n eventListeners.delete(callback);\n\n if (eventListeners.size === 0) {\n delete ChangeNotifier.listeners[eventName];\n }\n };\n }\n\n static multiListen(\n eventName: string,\n callbacks: ListenerCallback[],\n state = {}\n ): () => void {\n this.validateEventName(eventName);\n\n if (!Array.isArray(callbacks) || callbacks.length === 0) {\n throw new Error('Callbacks must be a non-empty array of functions');\n }\n\n const unsubscribeFunctions = callbacks.map((callback) =>\n ChangeNotifier.listen(eventName, callback, state)\n );\n\n return (): void => {\n unsubscribeFunctions.forEach((unsubscribe) => unsubscribe());\n };\n }\n\n // Retrieve the latest state data for a specific event\n static getLatestState(eventName: string): T | undefined {\n this.validateEventName(eventName);\n\n return ChangeNotifier.notifierState[eventName];\n }\n}\n\nexport default ChangeNotifier;\n","import { AudioX } from 'audio';\nimport { ERROR_MSG_MAP } from 'constants/common';\nimport { AudioEvents, AudioState, MediaTrack } from 'types';\nimport ChangeNotifier from './notifier';\n\nconst isValidArray = (arr: any[]) => arr && Array.isArray(arr) && arr.length;\nconst isValidFunction = (fn: any) =>\n fn instanceof Function && typeof fn === 'function';\n\nconst isValidObject = (obj: any) =>\n typeof obj === 'object' &&\n obj !== null &&\n obj instanceof Object &&\n Object.keys(obj).length;\n\nconst isValidWindow = typeof window !== undefined && window instanceof Window;\nconst loadedScripts: any = {};\n\nconst getReadableErrorMessage = (audioInstance: HTMLAudioElement) => {\n let message = '';\n const err = audioInstance.error;\n\n switch (err?.code) {\n case MediaError.MEDIA_ERR_ABORTED:\n message += ERROR_MSG_MAP['MEDIA_ERR_ABORTED'];\n break;\n case MediaError.MEDIA_ERR_NETWORK:\n message += ERROR_MSG_MAP['MEDIA_ERR_NETWORK'];\n break;\n case MediaError.MEDIA_ERR_DECODE:\n message += ERROR_MSG_MAP['MEDIA_ERR_DECODE'];\n break;\n case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:\n message += ERROR_MSG_MAP['MEDIA_ERR_SRC_NOT_SUPPORTED'];\n break;\n default:\n message += ERROR_MSG_MAP['DEFAULT'];\n break;\n }\n\n return message;\n};\n\nconst metaDataCreator = (mediaTrack: MediaTrack) => {\n const { title, album, artist, artwork } = mediaTrack;\n const artworkUrl = artwork ? artwork[0]?.src : '';\n const sizes = [\n '96x96',\n '128x128',\n '192x192',\n '256x256',\n '384x384',\n '512x512'\n ];\n const artworkMap = sizes.map((el) => {\n return { src: artworkUrl, sizes: el, type: 'image/png' };\n });\n const metaData = {\n title,\n album,\n artist,\n artwork: artworkMap\n };\n return metaData;\n};\n\nlet previousTrackPlayTime = 0;\nexport const calculateActualPlayedLength = (\n audioInstance: HTMLAudioElement,\n event?: keyof AudioEvents\n) => {\n const lengthSet = new Set();\n for (let i = 0; i < audioInstance.played.length; i++) {\n const startX = audioInstance.played.start(i);\n const endX = audioInstance.played.end(i);\n const width = endX - startX;\n lengthSet.add(width);\n }\n const lengthArr = [...lengthSet] as number[];\n const currentTrackPlayTime = lengthArr.reduce((acc, val) => acc + val, 0);\n\n previousTrackPlayTime = ['ENDED', 'TRACK_CHANGE', 'PAUSE'].includes(\n event as keyof AudioEvents\n )\n ? currentTrackPlayTime\n : previousTrackPlayTime;\n ChangeNotifier.notify('AUDIO_STATE', {\n currentTrackPlayTime,\n previousTrackPlayTime\n });\n};\n\nconst loadScript = (\n url: string,\n onLoad: () => void,\n name: string\n): Promise => {\n return new Promise((resolve, reject) => {\n if (window instanceof Window && window.document) {\n if (!loadedScripts[name]) {\n loadedScripts[name] = true;\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = url;\n script.async = true;\n script.onload = () => {\n onLoad();\n resolve();\n };\n document.head.appendChild(script);\n } else {\n onLoad();\n resolve();\n }\n } else {\n reject(`Window not ready unable to initialize ${name}`);\n }\n });\n};\n\nconst handleQueuePlayback = () => {\n const audio = new AudioX();\n let hasEnded = false;\n\n const audioStateListener = (state: AudioState) => {\n if (state.playbackState === 'ended' && !hasEnded) {\n const queue = audio.getQueue();\n hasEnded = true;\n if (queue && isValidArray(queue) && hasEnded) {\n audio.playNext();\n }\n }\n if (state.playbackState !== 'ended') {\n hasEnded = false;\n }\n };\n\n ChangeNotifier.listen('AUDIO_STATE', audioStateListener);\n};\n\nconst getBufferedDuration = (audioInstance: HTMLAudioElement) => {\n const { buffered } = audioInstance;\n let bufferedDuration = 0;\n\n for (let i = 0; i < buffered.length; i++) {\n bufferedDuration += buffered.end(i) - buffered.start(i);\n }\n\n return bufferedDuration;\n};\n\nconst shuffle = (array: T[]): T[] => {\n const shuffledArray = [...array];\n\n for (let i = shuffledArray.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * i);\n\n [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];\n }\n\n return shuffledArray;\n};\n\nconst diffChecker = (d1: any, d2: any): boolean => {\n if (d1 === null && d2 === null) {\n return true;\n }\n\n if (d1 === null || d2 === null) {\n return false;\n }\n\n if (typeof d1 !== typeof d2) {\n return false;\n }\n\n if (typeof d1 !== 'object') {\n return d1 === d2;\n }\n\n if (Array.isArray(d1) && Array.isArray(d2)) {\n if (d1.length !== d2.length) {\n return false;\n }\n\n return d1.every((item, index) => diffChecker(item, d2[index]));\n }\n\n const keys1 = Object.keys(d1);\n const keys2 = Object.keys(d2);\n\n if (keys1.length !== keys2.length) {\n return false;\n }\n\n return keys1.every((key) => {\n if (!keys2.includes(key)) {\n return false;\n }\n\n return diffChecker(d1[key], d2[key]);\n });\n};\n\nexport {\n diffChecker,\n getBufferedDuration,\n getReadableErrorMessage,\n handleQueuePlayback,\n isValidArray,\n isValidFunction,\n isValidObject,\n isValidWindow,\n loadScript,\n metaDataCreator,\n shuffle\n};\n","import { AudioX } from 'audio';\nimport { bands, presets } from 'constants/equalizer';\nimport { isValidArray } from 'helpers/common';\n\nimport { EqualizerStatus, Preset } from 'types/equalizer.types';\n\nclass Equalizer {\n private static _instance: Equalizer;\n private audioCtx: AudioContext;\n private audioCtxStatus: EqualizerStatus;\n private eqFilterBands: BiquadFilterNode[];\n private bassBoostFilter: BiquadFilterNode;\n private compressor: DynamicsCompressorNode;\n\n /**\n * Creates an instance of Equalizer or returns the existing instance.\n */\n constructor() {\n if (Equalizer._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instances of Equalizer. Returning existing instance.'\n );\n return Equalizer._instance;\n }\n\n this.initializeAudioContext();\n\n Equalizer._instance = this;\n }\n\n /**\n * Initializes the AudioContext, ensuring compatibility with older browsers.\n * @private\n */\n private initializeAudioContext() {\n const audioContextOptions = { latencyHint: 'playback' };\n if (typeof AudioContext !== 'undefined') {\n this.audioCtx = new AudioContext(\n audioContextOptions as AudioContextOptions\n );\n } else if (typeof (window as any).webkitAudioContext !== 'undefined') {\n this.audioCtx = new (window as any).webkitAudioContext(\n audioContextOptions\n );\n } else {\n console.error('Web Audio API is not supported in this browser.');\n }\n\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n\n if (this.audioCtx.state === 'suspended') {\n this.addResumeListener();\n }\n }\n\n /**\n * Adds a listener to resume the AudioContext on user interaction.\n * @private\n */\n private addResumeListener() {\n const resume = () => {\n this.audioCtx.resume();\n setTimeout(() => {\n if (this.audioCtx.state === 'running') {\n document.body.removeEventListener('click', resume, false);\n }\n }, 0);\n };\n\n document.body.addEventListener('click', resume, false);\n }\n\n /**\n * Initializes the equalizer by setting up the audio source and filter bands.\n */\n init() {\n try {\n const audioInstance = AudioX.getAudioInstance();\n const audioSource = this.audioCtx.createMediaElementSource(audioInstance);\n\n const equalizerBands = bands.map((band) => {\n const filter = this.audioCtx.createBiquadFilter();\n filter.type = band.type;\n filter.frequency.value = band.frequency;\n filter.gain.value = band.gain;\n filter.Q.value = band.q || 1; // Use a default Q of 1 if not specified\n return filter;\n });\n\n // Create a compressor for overall dynamic control\n this.compressor = this.audioCtx.createDynamicsCompressor();\n this.compressor.threshold.value = -24;\n this.compressor.knee.value = 30;\n this.compressor.ratio.value = 12;\n this.compressor.attack.value = 0.003;\n this.compressor.release.value = 0.25;\n\n // Create the bass boost filter\n this.bassBoostFilter = this.audioCtx.createBiquadFilter();\n this.bassBoostFilter.type = 'lowshelf';\n this.bassBoostFilter.frequency.value = 100;\n this.bassBoostFilter.gain.value = 0;\n\n // Connect the nodes\n audioSource.connect(equalizerBands[0]);\n for (let i = 0; i < equalizerBands.length - 1; i++) {\n equalizerBands[i].connect(equalizerBands[i + 1]);\n }\n equalizerBands[equalizerBands.length - 1].connect(this.bassBoostFilter);\n this.bassBoostFilter.connect(this.compressor);\n this.compressor.connect(this.audioCtx.destination);\n\n this.audioCtxStatus = 'ACTIVE';\n this.eqFilterBands = equalizerBands;\n } catch (error) {\n console.error('Equalizer initialization failed:', error);\n this.audioCtxStatus = 'FAILED';\n }\n }\n\n /**\n * Sets the equalizer to a predefined preset.\n * @param {keyof Preset} id - The ID of the preset to apply.\n */\n setPreset(id: keyof Preset) {\n const preset = presets.find((el) => el.id === id);\n if (!preset) {\n console.error('Preset not found:', id);\n return;\n }\n\n if (\n !this.eqFilterBands ||\n this.eqFilterBands.length !== preset.gains.length\n ) {\n console.error('Invalid data provided.');\n return;\n }\n\n const currentTime = this.audioCtx.currentTime;\n this.eqFilterBands.forEach((band, index) => {\n const targetGain = preset.gains[index];\n band.gain.setTargetAtTime(targetGain, currentTime, 0.05);\n });\n }\n\n /**\n * Retrieves the list of available presets.\n * @returns {Preset[]} The list of available presets.\n */\n static getPresets() {\n return presets;\n }\n\n /**\n * Gets the current status of the AudioContext.\n * @returns {EqualizerStatus} The current status of the AudioContext.\n */\n status() {\n if (this.audioCtx.state === 'suspended') {\n this.audioCtx.resume();\n }\n return this.audioCtxStatus;\n }\n\n /**\n * Sets a custom equalizer configuration.\n * @param {number[]} gains - The gain values for each band.\n */\n setCustomEQ(gains: number[]) {\n if (isValidArray(gains) && gains.length === this.eqFilterBands.length) {\n const currentTime = this.audioCtx.currentTime;\n this.eqFilterBands.forEach((band: BiquadFilterNode, index: number) => {\n band.gain.setTargetAtTime(gains[index], currentTime, 0.05);\n });\n } else {\n console.error('Invalid array of gains provided.');\n }\n }\n\n /**\n * Enables or disables bass boost.\n * @param {boolean} enable - Whether to enable or disable bass boost.\n * @param {number} gain - The gain value for bass boost.\n */\n setBassBoost(enable: boolean, gain: number = 6) {\n const currentTime = this.audioCtx.currentTime;\n if (enable) {\n this.bassBoostFilter.gain.setTargetAtTime(gain, currentTime, 0.05);\n } else {\n this.bassBoostFilter.gain.setTargetAtTime(0, currentTime, 0.05);\n }\n }\n\n /**\n * Adjusts the compressor settings.\n * @param {Partial} options - The compressor options to adjust.\n */\n setCompressorSettings(options: Partial) {\n if (this.compressor) {\n if (options.threshold !== undefined)\n this.compressor.threshold.setTargetAtTime(\n options.threshold,\n this.audioCtx.currentTime,\n 0.01\n );\n if (options.knee !== undefined)\n this.compressor.knee.setTargetAtTime(\n options.knee,\n this.audioCtx.currentTime,\n 0.01\n );\n if (options.ratio !== undefined)\n this.compressor.ratio.setTargetAtTime(\n options.ratio,\n this.audioCtx.currentTime,\n 0.01\n );\n if (options.attack !== undefined)\n this.compressor.attack.setTargetAtTime(\n options.attack,\n this.audioCtx.currentTime,\n 0.01\n );\n if (options.release !== undefined)\n this.compressor.release.setTargetAtTime(\n options.release,\n this.audioCtx.currentTime,\n 0.01\n );\n }\n }\n\n /**\n * Resets the equalizer to flat response.\n */\n reset() {\n const currentTime = this.audioCtx.currentTime;\n this.eqFilterBands.forEach((band: BiquadFilterNode) => {\n band.gain.setTargetAtTime(0, currentTime, 0.05);\n });\n this.bassBoostFilter.gain.setTargetAtTime(0, currentTime, 0.05);\n }\n}\n\nexport { Equalizer };\n","import { PLAYBACK_STATE } from 'constants/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { HlsEventsCallbackMap } from 'types/audioEvents.types';\n\nexport const HLS_EVENTS_CALLBACK_MAP: HlsEventsCallbackMap = {\n ERROR: (e: Event, data: any) => {\n const type = data.type;\n const detail = data.details;\n const isFatal = data.fatal;\n console.log('STATUS', e.type);\n\n ChangeNotifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ERROR,\n error: {\n type,\n isFatal,\n detail\n }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n FRAG_CHANGED: () => {\n console.log('FRAG_CHANGED');\n }\n};\n","import { AudioEvents } from 'types';\n\nexport const AUDIO_EVENTS: AudioEvents = Object.freeze({\n ABORT: 'abort',\n TIME_UPDATE: 'timeupdate',\n CAN_PLAY: 'canplay',\n CAN_PLAY_THROUGH: 'canplaythrough',\n DURATION_CHANGE: 'durationchange',\n ENDED: 'ended',\n EMPTIED: 'emptied',\n PLAYING: 'playing',\n WAITING: 'waiting',\n SEEKING: 'seeking',\n SEEKED: 'seeked',\n LOADED_META_DATA: 'loadedmetadata',\n LOADED_DATA: 'loadeddata',\n PLAY: 'play',\n PAUSE: 'pause',\n RATE_CHANGE: 'ratechange',\n VOLUME_CHANGE: 'volumechange',\n SUSPEND: 'suspend',\n STALLED: 'stalled',\n PROGRESS: 'progress',\n LOAD_START: 'loadstart',\n ERROR: 'error',\n TRACK_CHANGE: 'trackchange', // this is a custom event added to support track change\n QUEUE_ENDED: 'queueended' // this is a custom event added to support end of queue\n});\n\nexport const HLS_EVENTS = {\n MEDIA_ATTACHING: 'hlsMediaAttaching',\n MEDIA_ATTACHED: 'hlsMediaAttached',\n MEDIA_DETACHING: 'hlsMediaDetaching',\n MEDIA_DETACHED: 'hlsMediaDetached',\n BUFFER_RESET: 'hlsBufferReset',\n BUFFER_CODECS: 'hlsBufferCodecs',\n BUFFER_CREATED: 'hlsBufferCreated',\n BUFFER_APPENDING: 'hlsBufferAppending',\n BUFFER_APPENDED: 'hlsBufferAppended',\n BUFFER_EOS: 'hlsBufferEos',\n BUFFER_FLUSHING: 'hlsBufferFlushing',\n BUFFER_FLUSHED: 'hlsBufferFlushed',\n MANIFEST_LOADING: 'hlsManifestLoading',\n MANIFEST_LOADED: 'hlsManifestLoaded',\n MANIFEST_PARSED: 'hlsManifestParsed',\n LEVEL_SWITCHING: 'hlsLevelSwitching',\n LEVEL_SWITCHED: 'hlsLevelSwitched',\n LEVEL_LOADING: 'hlsLevelLoading',\n LEVEL_LOADED: 'hlsLevelLoaded',\n LEVEL_UPDATED: 'hlsLevelUpdated',\n LEVEL_PTS_UPDATED: 'hlsLevelPtsUpdated',\n LEVELS_UPDATED: 'hlsLevelsUpdated',\n AUDIO_TRACKS_UPDATED: 'hlsAudioTracksUpdated',\n AUDIO_TRACK_SWITCHING: 'hlsAudioTrackSwitching',\n AUDIO_TRACK_SWITCHED: 'hlsAudioTrackSwitched',\n AUDIO_TRACK_LOADING: 'hlsAudioTrackLoading',\n AUDIO_TRACK_LOADED: 'hlsAudioTrackLoaded',\n SUBTITLE_TRACKS_UPDATED: 'hlsSubtitleTracksUpdated',\n SUBTITLE_TRACKS_CLEARED: 'hlsSubtitleTracksCleared',\n SUBTITLE_TRACK_SWITCH: 'hlsSubtitleTrackSwitch',\n SUBTITLE_TRACK_LOADING: 'hlsSubtitleTrackLoading',\n SUBTITLE_TRACK_LOADED: 'hlsSubtitleTrackLoaded',\n SUBTITLE_FRAG_PROCESSED: 'hlsSubtitleFragProcessed',\n CUES_PARSED: 'hlsCuesParsed',\n NON_NATIVE_TEXT_TRACKS_FOUND: 'hlsNonNativeTextTracksFound',\n INIT_PTS_FOUND: 'hlsInitPtsFound',\n FRAG_LOADING: 'hlsFragLoading',\n FRAG_LOAD_EMERGENCY_ABORTED: 'hlsFragLoadEmergencyAborted',\n FRAG_LOADED: 'hlsFragLoaded',\n FRAG_DECRYPTED: 'hlsFragDecrypted',\n FRAG_PARSING_INIT_SEGMENT: 'hlsFragParsingInitSegment',\n FRAG_PARSING_USERDATA: 'hlsFragParsingUserdata',\n FRAG_PARSING_METADATA: 'hlsFragParsingMetadata',\n FRAG_PARSED: 'hlsFragParsed',\n FRAG_BUFFERED: 'hlsFragBuffered',\n FRAG_CHANGED: 'hlsFragChanged',\n FPS_DROP: 'hlsFpsDrop',\n FPS_DROP_LEVEL_CAPPING: 'hlsFpsDropLevelCapping',\n ERROR: 'hlsError',\n DESTROYING: 'hlsDestroying',\n KEY_LOADING: 'hlsKeyLoading',\n KEY_LOADED: 'hlsKeyLoaded',\n LIVE_BACK_BUFFER_REACHED: 'hlsLiveBackBufferReached',\n BACK_BUFFER_REACHED: 'hlsBackBufferReached'\n};\n\nexport const CUSTOM_AUDIO_EVENTS = Object.freeze({\n AUDIO_X_STATE: 'AUDIO_X_STATE'\n});\n","import HlsAdapter from 'adapters/hls';\nimport { AudioX } from 'audio';\nimport { isValidArray } from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport {\n AudioEvents,\n EventListenerCallbackMap,\n EventListenersList,\n HlsEvents,\n HlsEventsCallbackMap\n} from 'types/audioEvents.types';\nimport { HlsListeners } from '../types/hls.js.js';\nimport { AUDIO_EVENTS, HLS_EVENTS } from './audioEvents';\n\n/**\n * this attaches event listeners, for audio also sends a flag to calculate playLog\n * loops through the event listeners map and attaches it to the audio element\n */\nconst attachEventListeners = (\n eventListenersCallbackMap: EventListenerCallbackMap,\n playLogEnabled: boolean = false\n) => {\n const audioInstance = AudioX.getAudioInstance();\n isValidArray(Object.keys(eventListenersCallbackMap)) &&\n Object.keys(eventListenersCallbackMap).forEach((evt) => {\n let event = evt as keyof AudioEvents;\n audioInstance?.addEventListener(AUDIO_EVENTS[event], (e: Event) => {\n if (evt && eventListenersCallbackMap[event]) {\n const listenerCallback = eventListenersCallbackMap[event];\n if (typeof listenerCallback === 'function') {\n listenerCallback(e, audioInstance, playLogEnabled);\n }\n }\n });\n });\n};\n\nconst attachCustomEventListeners = (\n eventListenersList: EventListenersList,\n enablePlayLog: boolean = false\n) => {\n const audioInstance = AudioX.getAudioInstance();\n if (isValidArray(eventListenersList)) {\n eventListenersList.forEach((evt) => {\n let event = evt as keyof AudioEvents;\n if (Object.keys(AUDIO_EVENTS).includes(event)) {\n audioInstance?.addEventListener(AUDIO_EVENTS[event], (e: Event) => {\n ChangeNotifier.notify(AUDIO_EVENTS[event], {\n e,\n audioInstance,\n enablePlayLog\n });\n });\n }\n });\n }\n};\n\nconst attachHlsEventsListeners = (\n hlsEventlistenerCallbackMap: HlsEventsCallbackMap,\n playLogEnabled: boolean = false\n) => {\n const hls = new HlsAdapter();\n const hlsInstance = hls.getHlsInstance();\n isValidArray(Object.keys(hlsEventlistenerCallbackMap)) &&\n Object.keys(hlsEventlistenerCallbackMap).forEach((evt) => {\n let event = evt as keyof HlsEvents;\n hlsInstance.on(\n HLS_EVENTS[event] as keyof HlsListeners,\n (e: any, data: any) => {\n if (event && hlsEventlistenerCallbackMap[event]) {\n const listenerCallback = hlsEventlistenerCallbackMap[event];\n if (typeof listenerCallback === 'function') {\n listenerCallback(e, data, hlsInstance, playLogEnabled);\n }\n }\n }\n );\n });\n};\n\nexport {\n attachCustomEventListeners,\n attachEventListeners,\n attachHlsEventsListeners\n};\n","declare global {\n interface Window {\n Hls: any;\n }\n}\n\nimport { AudioX } from 'audio';\nimport { URLS } from 'constants/common';\nimport { HLS_EVENTS_CALLBACK_MAP } from 'events/hlsEvents';\nimport { attachHlsEventsListeners } from 'events/listeners';\nimport { loadScript } from 'helpers/common';\nimport { MediaTrack } from 'types';\nimport type Hls from 'types/hls.js.js';\nimport type { HlsConfig } from 'types/hls.js.js';\n\nlet hlsInstance: Hls;\n\nclass HlsAdapter {\n private static _instance: HlsAdapter;\n private HlsClass: typeof Hls;\n\n constructor() {\n if (HlsAdapter._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of HLS returning existing instance'\n );\n return HlsAdapter._instance;\n }\n HlsAdapter._instance = this;\n }\n\n async load() {\n await loadScript(\n URLS.HLS,\n () => {\n console.log('HLS Loaded');\n },\n 'hls'\n )\n .then(() => {\n this.HlsClass = window.Hls;\n window.Hls = undefined;\n })\n .catch((msg: string) => {\n console.log(msg);\n });\n\n return this.HlsClass;\n }\n\n async init(config: HlsConfig | {} = {}, enablePlayLog: boolean) {\n const Hls = await this.load();\n if (Hls.isSupported()) {\n hlsInstance = new Hls(config);\n attachHlsEventsListeners(HLS_EVENTS_CALLBACK_MAP, enablePlayLog);\n }\n }\n\n addHlsMedia(mediaTrack: MediaTrack) {\n const Hls = this.HlsClass;\n const audioInstance = AudioX.getAudioInstance();\n hlsInstance.loadSource(mediaTrack.source);\n hlsInstance.attachMedia(audioInstance);\n hlsInstance.on(Hls.Events.MEDIA_ATTACHED, function () {\n console.log('hls media attached');\n });\n }\n\n getHlsInstance() {\n return hlsInstance;\n }\n}\n\nexport default HlsAdapter;\n","import { ErrorEvents } from 'types/errorEvents.types';\n\nexport const ERROR_EVENTS: ErrorEvents = Object.freeze({\n 1: 'MEDIA_ERR_ABORTED',\n 3: 'MEDIA_ERR_DECODE',\n 2: 'MEDIA_ERR_NETWORK',\n 4: 'MEDIA_ERR_SRC_NOT_SUPPORTED',\n});\n","import { PLAYBACK_STATE } from 'constants/common';\nimport {\n calculateActualPlayedLength,\n getBufferedDuration,\n getReadableErrorMessage\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState, EventListenerCallbackMap } from 'types';\nimport { ERROR_EVENTS } from './errorEvents';\n\nconst notifier = ChangeNotifier;\n\nconst BASE_EVENT_CALLBACK_MAP: EventListenerCallbackMap = {\n LOAD_START: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n DURATION_CHANGE: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'playing'\n ? PLAYBACK_STATE.PLAYING // fix for live streams where duration change is fired even when audio is playing\n : PLAYBACK_STATE.DURATION_CHANGE,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n LOADED_META_DATA: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n LOADED_DATA: (e, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const bufferedDuration = getBufferedDuration(audioInstance);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'paused'\n ? PLAYBACK_STATE.PAUSED\n : PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n } as AudioState,\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY_THROUGH: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const isPaused = audioInstance.paused;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n /* below we check if the audio was already in paused state then we keep\n it as paused instead going to ready this make sure ready is fired only on the first load.*/\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: isPaused\n ? PLAYBACK_STATE.PAUSED\n : audioState.playbackState === 'playing'\n ? PLAYBACK_STATE.PLAYING // fix for live streams as canplaythrough event is can be behave weirdly as there is no known end to the media\n : PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PLAY: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PLAYING: (e, audioInstance) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n PAUSE: (e: Event, audioInstance: HTMLAudioElement, playLogEnabled) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.PAUSED,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n if (playLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'PAUSE');\n }\n },\n\n ENDED: (e: Event, audioInstance: HTMLAudioElement, playLogEnabled) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ENDED,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n if (playLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'ENDED');\n }\n },\n\n ERROR: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const errorCode = audioInstance.error?.code as keyof typeof ERROR_EVENTS;\n const message = getReadableErrorMessage(audioInstance);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.ERROR,\n error: {\n code: errorCode,\n message: ERROR_EVENTS[errorCode],\n readable: message\n }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n TIME_UPDATE: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: audioInstance.paused\n ? audioState?.playbackState\n : PLAYBACK_STATE.PLAYING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n WAITING: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n VOLUME_CHANGE: (e: Event) => {\n console.log('STATUS', e.type);\n notifier.notify('AUDIO_STATE', {}, `audiox_baseEvents_state`);\n },\n\n SEEKED: (e: any, audioInstance: HTMLAudioElement) => {\n const audioState = notifier.getLatestState('AUDIO_X_STATE') as AudioState;\n const bufferedDuration = getBufferedDuration(audioInstance);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState:\n audioState.playbackState === 'paused'\n ? 'paused'\n : audioState.playbackState,\n progress: audioInstance?.currentTime,\n error: { code: null, message: '', readable: '' },\n bufferedDuration\n } as AudioState,\n `audiox_baseEvents_state_${e.type}`\n );\n }\n};\n\nexport { BASE_EVENT_CALLBACK_MAP };\n","import { AudioX } from 'audio';\nimport { metaDataCreator } from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState } from 'types';\n\nexport const updateMetaData = (data: any) => {\n if ('mediaSession' in navigator) {\n navigator.mediaSession.metadata = new MediaMetadata(metaDataCreator(data));\n }\n};\n\nexport const attachMediaSessionHandlers = () => {\n const audio = new AudioX();\n if ('mediaSession' in navigator) {\n navigator.mediaSession.setActionHandler('play', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.play();\n });\n\n navigator.mediaSession.setActionHandler('pause', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.pause();\n });\n\n // Only add next and previous handler if there is a valid queue\n if (audio.getQueue().length) {\n navigator.mediaSession.setActionHandler('previoustrack', () => {\n audio.playPrevious();\n });\n\n navigator.mediaSession.setActionHandler('nexttrack', () => {\n audio.playNext();\n });\n }\n }\n};\n\nexport const updatePositionState = () => {\n ChangeNotifier.listen('AUDIO_X_STATE', (audioState: AudioState) => {\n if (\n audioState?.duration &&\n audioState?.playbackRate &&\n audioState?.progress\n ) {\n navigator.mediaSession.setPositionState({\n duration: audioState.duration,\n playbackRate: audioState.playbackRate,\n position: audioState.progress\n });\n }\n });\n};\n","import { PLAYBACK_STATE } from 'constants/common';\nimport { diffChecker } from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { ReadyState } from 'types';\nimport { AudioState, MediaTrack } from 'types/audio.types';\n\nexport const READY_STATE: ReadyState = {\n HAVE_NOTHING: 0,\n HAVE_METADATA: 1,\n HAVE_CURRENT_DATA: 2,\n HAVE_FUTURE_DATA: 3,\n HAVE_ENOUGH_DATA: 4\n};\n\nexport const AUDIO_STATE: AudioState = {\n playbackState: PLAYBACK_STATE.IDLE,\n duration: 0,\n bufferedDuration: 0,\n progress: 0,\n volume: 50,\n playbackRate: 1,\n error: {\n code: null,\n message: '',\n readable: ''\n },\n currentTrack: {} as MediaTrack,\n currentTrackPlayTime: 0,\n previousTrackPlayTime: 0\n};\n\n/* Listen to state changes and update global audio state that is being exposed to outer world\n Do not subscribe to this event, this may cause unexpected behavior instead attach your own custom\n event listener, if you wish to have granular control on audio state. See: attachCustomEventListener \n*/\nChangeNotifier.listen(\n 'AUDIO_STATE',\n (audioState: AudioState) => {\n const latestState = ChangeNotifier.getLatestState(\n 'AUDIO_X_STATE'\n ) as AudioState;\n if (!diffChecker(latestState, audioState)) {\n ChangeNotifier.notify('AUDIO_X_STATE', { ...AUDIO_STATE, ...audioState });\n }\n },\n AUDIO_STATE\n);\n","import { Equalizer } from 'adapters/equalizer';\nimport HlsAdapter from 'adapters/hls';\nimport { AUDIO_X_CONSTANTS, PLAYBACK_STATE } from 'constants/common';\nimport { BASE_EVENT_CALLBACK_MAP } from 'events/baseEvents';\nimport { attachEventListeners } from 'events/listeners';\nimport {\n calculateActualPlayedLength,\n handleQueuePlayback,\n isValidArray,\n isValidFunction,\n shuffle\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\n\nimport {\n attachMediaSessionHandlers,\n updateMetaData\n} from 'mediasession/mediasessionHandler';\nimport { READY_STATE } from 'states/audioState';\nimport {\n AudioInit,\n MediaTrack,\n PlaybackRate,\n QueuePlaybackType\n} from 'types/audio.types';\nimport { EqualizerStatus, Preset } from 'types/equalizer.types';\n\nlet audioInstance: HTMLAudioElement;\nconst notifier = ChangeNotifier;\n\nclass AudioX {\n private _audio: HTMLAudioElement;\n private isPlayLogEnabled: Boolean;\n private static _instance: AudioX;\n private _queue: MediaTrack[];\n private _currentQueueIndex: number = 0;\n private _fetchFn: (mediaTrack: MediaTrack) => Promise;\n private eqStatus: EqualizerStatus = 'IDEAL';\n private isEqEnabled: boolean = false;\n private eqInstance: Equalizer;\n private showNotificationsActions: boolean = false;\n\n constructor() {\n if (AudioX._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of AudioX returning existing instance'\n );\n return AudioX._instance;\n }\n if (\n process.env.NODE_ENV !== AUDIO_X_CONSTANTS?.DEVELOPMENT &&\n audioInstance\n ) {\n throw new Error('Cannot create multiple audio instance');\n }\n\n AudioX._instance = this;\n this._audio = new Audio();\n audioInstance = this._audio;\n }\n\n /**\n *\n * @param initProps initial config to initialize AudioX\n * @param initProps.mediaTrack mediaTrack Object containing metadata and source of the media\n * @param initProps.mediaTrack.title title of the Audio\n * @param initProps.mediaTrack.source URI of the Audio\n * @param initProps.mediaTrack.artwork artwork of the Audio\n * @param initProps.mediaTrack.duration duration of the audio\n * @param initProps.mediaTrack.genre genre of the audio\n * @param initProps.mediaTrack.album album of the audio\n * @param initProps.mediaTrack.comment comment for the audio\n * @param initProps.mediaTrack.year release year of the audio\n * @param initProps.mediaTrack.artist artist of the audio\n * @param mode mode of operation for AudioX\n * @param autoplay flag for autoplay\n * @param preloadStrategy strategy for preloading audio\n * @param playbackRate default playbackRate of the audio\n * @param attachAudioEventListeners flag for registering audio events\n * @param attachMediaSessionHandlers flag for registering mediaSession handlers\n */\n\n async init(initProps: AudioInit) {\n const {\n preloadStrategy = 'auto',\n autoPlay = false,\n useDefaultEventListeners = true,\n customEventListeners = null,\n showNotificationActions = false,\n enablePlayLog = false,\n enableHls = false,\n enableEQ = false,\n crossOrigin = null,\n hlsConfig = {}\n } = initProps;\n\n this._audio?.setAttribute('id', 'audio_x_instance');\n this._audio.preload = preloadStrategy;\n this._audio.autoplay = autoPlay;\n this._audio.crossOrigin = crossOrigin;\n this.isPlayLogEnabled = enablePlayLog;\n this.isEqEnabled = enableEQ;\n\n if (customEventListeners !== null) {\n if (useDefaultEventListeners) {\n console.warn(\n `useDefaultEventListeners is set to true at init, are you trying to use the default event listeners?\n set customEventListeners to null to use default event listeners`\n );\n }\n attachEventListeners(customEventListeners, false);\n } else {\n attachEventListeners(BASE_EVENT_CALLBACK_MAP, enablePlayLog);\n }\n\n if (showNotificationActions) {\n this.showNotificationsActions = true;\n attachMediaSessionHandlers();\n }\n\n if (enableHls) {\n const hls = new HlsAdapter();\n hls.init(hlsConfig, enablePlayLog);\n }\n }\n\n async addMedia(\n mediaTrack: MediaTrack,\n mediaFetchFn?: (mediaTrack: MediaTrack) => Promise\n ) {\n if (!mediaTrack) {\n return;\n }\n\n if (mediaFetchFn && !mediaTrack.source.length) {\n this._fetchFn = mediaFetchFn;\n }\n\n const queue = this.getQueue();\n if (isValidArray(queue)) {\n const index = queue.findIndex((track) => mediaTrack.id === track.id);\n if (index > -1) {\n this._currentQueueIndex = index;\n }\n }\n\n const mediaType = mediaTrack.source.includes('.m3u8') ? 'HLS' : 'DEFAULT';\n\n if (this.isPlayLogEnabled) {\n calculateActualPlayedLength(audioInstance, 'TRACK_CHANGE');\n }\n\n if (\n mediaType === 'HLS' &&\n !audioInstance.canPlayType('application/vnd.apple.mpegurl')\n ) {\n const hls = new HlsAdapter();\n const hlsInstance = hls.getHlsInstance();\n if (hlsInstance) {\n hlsInstance.detachMedia();\n hls.addHlsMedia(mediaTrack);\n } else {\n console.warn(\n 'The source provided seems to be a HLS stream but, hls playback is not enabled. Please have a look at init method of AudioX'\n );\n await this.reset();\n }\n } else {\n audioInstance.src = mediaTrack.source;\n }\n\n notifier.notify('AUDIO_STATE', {\n playbackState: PLAYBACK_STATE.TRACK_CHANGE,\n currentTrackPlayTime: 0,\n currentTrack: mediaTrack\n });\n\n updateMetaData(mediaTrack);\n audioInstance.load();\n }\n\n attachEq() {\n if (this.eqStatus === 'IDEAL') {\n try {\n const eq = new Equalizer();\n this.eqStatus = eq.status();\n this.eqInstance = eq;\n } catch (e) {\n console.log('failed to enable equalizer');\n }\n }\n }\n\n async play() {\n const isSourceAvailable = audioInstance.src !== '';\n if (\n audioInstance?.paused &&\n audioInstance.HAVE_ENOUGH_DATA === READY_STATE.HAVE_ENOUGH_DATA &&\n isSourceAvailable\n ) {\n await audioInstance\n .play()\n .then(() => {\n console.log('PLAYING');\n })\n .catch(() => {\n console.warn('cancelling current audio playback, track changed');\n });\n }\n if (this.isEqEnabled) {\n this.attachEq();\n }\n }\n\n /**\n *\n * @param mediaTrack MediaTrack to be added and played\n *\n * Note: Use this method when you want to add media and do playback or want continuous playback\n * You can also call addMedia and Play Separately to achieve playback.\n */\n\n async addMediaAndPlay(\n mediaTrack?: MediaTrack | null,\n fetchFn?: (mediaTrack: MediaTrack) => Promise\n // this should be passed when there something needs to be done before the audio starts playing\n ) {\n const currentTrack =\n mediaTrack || (this._queue.length > 0 ? this._queue[0] : undefined);\n if (fetchFn && isValidFunction(fetchFn) && currentTrack?.source.length) {\n this._fetchFn = fetchFn;\n await fetchFn(currentTrack as MediaTrack);\n }\n try {\n if (currentTrack) {\n this.addMedia(currentTrack).then(() => {\n if (audioInstance.HAVE_ENOUGH_DATA === READY_STATE.HAVE_ENOUGH_DATA) {\n setTimeout(async () => {\n await this.play();\n if (this.isEqEnabled) {\n this.attachEq();\n }\n }, 950);\n }\n });\n } else {\n console.error('Playback Failed, No MediaTrack Provided');\n }\n } catch (error) {\n console.error('Playback Failed');\n }\n }\n\n pause() {\n if (audioInstance && !audioInstance?.paused) {\n audioInstance?.pause();\n }\n }\n\n stop() {\n if (audioInstance && !audioInstance.paused) {\n audioInstance?.pause();\n audioInstance.currentTime = 0;\n }\n }\n\n /**\n * @method reset : This stops the playback and resets all the state of the audio\n */\n async reset() {\n if (audioInstance) {\n this.stop();\n audioInstance.src = '';\n audioInstance.srcObject = null;\n }\n }\n\n /**\n * @param volume : numeric value between 1-100 to be used.\n */\n setVolume(volume: number) {\n const actualVolume = volume / 100;\n if (audioInstance) {\n audioInstance.volume = actualVolume;\n notifier.notify('AUDIO_STATE', {\n volume: volume\n });\n }\n }\n /**\n * @param playbackRate : a number denoting speed at which the playback should happen,\n */\n setPlaybackRate(playbackRate: PlaybackRate) {\n if (audioInstance) {\n audioInstance.playbackRate = playbackRate;\n notifier.notify('AUDIO_STATE', {\n playbackRate\n });\n }\n }\n\n mute() {\n if (audioInstance && !audioInstance.muted) {\n audioInstance.muted = true;\n }\n }\n\n seek(time: number) {\n if (audioInstance) {\n audioInstance.currentTime = time;\n }\n }\n\n seekBy(time: number) {\n if (audioInstance && audioInstance.currentTime) {\n const currentProgress = audioInstance.currentTime;\n audioInstance.currentTime = currentProgress + time;\n }\n }\n\n async destroy() {\n if (audioInstance) {\n await this.reset();\n audioInstance.removeAttribute('src');\n audioInstance.load();\n }\n }\n\n subscribe(eventName: string, callback: (data: any) => void, state: any = {}) {\n const unsubscribe = notifier.listen(eventName, callback, state);\n return unsubscribe;\n }\n\n addEventListener(\n event: keyof HTMLMediaElementEventMap,\n callback: (data: any) => void\n ) {\n audioInstance.addEventListener(event, callback);\n }\n\n getPresets() {\n return Equalizer.getPresets();\n }\n\n setPreset(id: keyof Preset) {\n if (this.isEqEnabled) {\n this.eqInstance.setPreset(id);\n } else {\n console.error('Equalizer not initialized, please set enableEq at init');\n }\n }\n\n setCustomEQ(gains: number[]) {\n if (this.isEqEnabled) {\n this.eqInstance.setCustomEQ(gains);\n } else {\n console.error('Equalizer not initialized, please set enableEq at init');\n }\n }\n\n setBassBoost(enabled: boolean, boost: number) {\n if (this.isEqEnabled) {\n this.eqInstance.setBassBoost(enabled, boost);\n } else {\n console.error('Equalizer not initialized, please set enableEq at init');\n }\n }\n\n addQueue(queue: MediaTrack[], playbackType: QueuePlaybackType) {\n this.clearQueue();\n const playerQueue = isValidArray(queue) ? queue.slice() : [];\n switch (playbackType) {\n case 'DEFAULT':\n this._queue = playerQueue;\n break;\n case 'REVERSE':\n this._queue = playerQueue.reverse();\n break;\n case 'SHUFFLE':\n this._queue = shuffle(playerQueue);\n break;\n default:\n this._queue = playerQueue;\n break;\n }\n handleQueuePlayback();\n /* Attaching MediaSession Handler again as this will make sure that\n the next and previous button show up in notification */\n if (this.showNotificationsActions) {\n attachMediaSessionHandlers();\n }\n }\n\n playNext() {\n const index = this._currentQueueIndex + 1;\n if (this?._queue?.length > index) {\n const nextTrack = this._queue[index];\n this.addMediaAndPlay(nextTrack, this._fetchFn);\n this._currentQueueIndex = index;\n } else {\n // stop the audio and end trigger queue ended\n this.stop();\n notifier.notify('AUDIO_STATE', {\n playbackState: PLAYBACK_STATE.QUEUE_ENDED\n });\n }\n }\n\n playPrevious() {\n const index = this?._currentQueueIndex - 1;\n\n if (index >= 0) {\n const previousTrack = this?._queue[index];\n this.addMediaAndPlay(previousTrack, this._fetchFn);\n this._currentQueueIndex = index;\n } else {\n console.log('At the beginning of the queue');\n }\n }\n\n clearQueue() {\n if (this._queue && isValidArray(this._queue)) {\n this._queue = [];\n this._currentQueueIndex = 0;\n }\n }\n\n addToQueue(mediaTracks: MediaTrack | MediaTrack[]) {\n if (this._queue && isValidArray(this._queue)) {\n if (Array.isArray(mediaTracks)) {\n this._queue = [...this._queue, ...mediaTracks];\n } else {\n this._queue.push(mediaTracks);\n }\n }\n }\n\n removeFromQueue(mediaTrack: MediaTrack) {\n if (this._queue && isValidArray(this._queue)) {\n const queue = this._queue.filter(\n (track: MediaTrack) => track.id == mediaTrack.id\n );\n this._queue = queue;\n }\n }\n\n getQueue() {\n return this._queue && isValidArray(this._queue) ? this._queue : [];\n }\n\n get id() {\n return audioInstance?.getAttribute('id');\n }\n\n static getAudioInstance() {\n return audioInstance;\n }\n}\n\nexport { AudioX };\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 794a1cf..37fd728 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "audio_x", - "version": "1.0.10-beta.13", + "version": "1.0.10", "description": "The audio player for the gen-x", "main": "./dist/index.js", "types": "./dist/index.d.ts",