From 5d11f3f2c6fd6936a41a362869d5192cf78d2cc3 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Date: Sun, 31 Dec 2023 21:55:39 +0530 Subject: [PATCH] add track id for media track --- dist/index.d.ts | 1 + dist/index.js | 2 +- dist/index.js.map | 2 +- src/types/audio.types.ts | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 0c0f6c1..f0aefbd 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -3290,6 +3290,7 @@ interface MediaTrack { title: string; source: string; artwork: MediaArtwork[] | null; + id?: string; duration?: number; genre?: string; album?: string; diff --git a/dist/index.js b/dist/index.js index 8e2766a..f3f57ec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,4 +1,4 @@ -var w=Object.defineProperty;var Q=(s,e,t)=>e in s?w(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e)=>w(s,"name",{value:e,configurable:!0});var c=(s,e,t)=>(Q(s,typeof e!="symbol"?e+"":e,t),t);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}],C=[{id:"preset_default",name:"Default",gains:[0,0,0,0,0,0,0,0,0,0]},{id:"preset_live",name:"Live",gains:[-1,1,3,4,4,4,3,2,2,2]},{id:"preset_acoustic",name:"Acoustic",gains:[6,6,4,1,3,3,4,5,4,1.5]},{id:"preset_classical",name:"Classical",gains:[6,5,4,3,-1,-1,0,2,4,5]},{id:"preset_piano",name:"Piano",gains:[4,2,0,3.5,4,1.5,5,6,4,4.5]},{id:"preset_lounge",name:"Lounge",gains:[-3,-1.5,0,1,5.5,1,0,-1.5,2,.5]},{id:"preset_spoken_word",name:"Spoken Word",gains:[-2,0,0,1,5,6.5,7,6,3,0]},{id:"preset_jazz",name:"Jazz",gains:[5.5,4,1,2,-1.5,-1.5,0,1,4,5.5]},{id:"preset_pop",name:"Pop",gains:[.5,2.4,3.8,4.3,3,0,-.5,-.5,.5,.5]},{id:"preset_dance",name:"Dance",gains:[5,10,6.5,0,2,4.5,7.5,7,5.5,0]},{id:"preset_latin",name:"Latin",gains:[3.5,1.5,0,0,-1.5,-1.5,-1.5,0,4,6.5]},{id:"preset_rnb",name:"RnB",gains:[3.5,10.5,8.5,1,-3,-1.5,3,3.5,4,5]},{id:"preset_hiphop",name:"HipHop",gains:[7,6,1,4,-1,-.5,1,-.5,2,4]},{id:"preset_electronic",name:"Electronic",gains:[6,5.5,1,0,-2,2,1,1.5,5.5,6.5]},{id:"preset_techno",name:"Techno",gains:[3.8,2.4,0,-2.4,-1.9,0,3.8,4.8,4.8,4.3]},{id:"preset_deep",name:"Deep",gains:[6,5,1.5,.5,4,3,1.5,-2,-5,-6.5]},{id:"preset_club",name:"Club",gains:[0,0,3.8,2.4,2.4,2.4,1,0,0,0]},{id:"preset_rock",name:"Rock",gains:[7,5.5,4,1,-.5,0,.5,3,4.5,6.5]},{id:"preset_rock_soft",name:"Rock Soft",gains:[1.5,0,0,-.5,0,1,3.8,4.8,5.7,6.2]},{id:"preset_ska",name:"Ska",gains:[-.5,-1.5,-1,0,1,2,3.8,4.3,5.2,4.3]},{id:"preset_reggae",name:"Reggae",gains:[0,0,0,-2.4,0,2.5,2.5,0,0,0]},{id:"preset_country",name:"Country",gains:[3,2,1,0,-1,0,2,3,4,4]},{id:"preset_funk",name:"Funk",gains:[4,5,3,0,-1,0,2,4,5,5]},{id:"preset_blues",name:"Blues",gains:[2,1,0,-1,0,1,2,3,4,3]},{id:"preset_metal",name:"Metal",gains:[8,7,6,4,2,1,0,2,4,6]},{id:"preset_indie",name:"Indie",gains:[2,3,2,1,0,-1,-2,0,3,4]},{id:"preset_chill",name:"Chill",gains:[1,1,0,-1,-2,-1,1,2,3,2]},{id:"preset_world",name:"World",gains:[3,2,0,-2,-1,1,3,4,5,3]},{id:"preset_alternative",name:"Alternative",gains:[3,2,1,0,-1,-2,1,3,4,3]},{id:"preset_ambient",name:"Ambient",gains:[0,-1,-2,-3,-2,0,1,2,3,2]},{id:"preset_mellow",name:"Mellow",gains:[1,1,0,-1,-2,-1,1,2,3,1]},{id:"preset_grunge",name:"Grunge",gains:[5,4,3,2,1,0,0,2,4,5]},{id:"preset_soul",name:"Soul",gains:[3,3,2,1,0,-1,0,2,3,3]},{id:"preset_folk",name:"Folk",gains:[2,1,0,-1,-2,-1,1,2,3,2]},{id:"preset_trap",name:"Trap",gains:[7,6,3,1,-2,-1,1,3,6,7]},{id:"preset_dubstep",name:"Dubstep",gains:[6,5,4,3,2,1,1,3,5,6]}];var O=Object.freeze({REACT:"REACT",VANILLA:"VANILLA",DEVELOPMENT:"development"}),E=Object.freeze({BUFFERING:"buffering",PLAYING:"playing",PAUSED:"paused",READY:"ready",IDLE:"idle",ENDED:"ended",STALLED:"stalled",ERROR:"error",TRACK_CHANGE:"trackchanged"}),S=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."}),M={HLS:"https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"};var l,J=(l=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 o=l.listeners[e];o&&t!==null&&(l.notifierState[e]={...l.notifierState[e]||{},...t},o.forEach(i=>{i(l.notifierState[e]);}));}static listen(e,t,a={}){if(this.validateEventName(e),typeof t!="function")throw new Error("Callback must be a function");return l.listeners[e]?l.listeners[e].add(t):(l.notifierState[e]=a,l.listeners[e]=new Set([t])),()=>{let o=l.listeners[e];o&&(o.delete(t),o.size===0&&delete l.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 o=t.map(i=>l.listen(e,i,a));return ()=>{o.forEach(i=>i());}}static getLatestState(e){return this.validateEventName(e),l.notifierState[e]}},r(l,"ChangeNotifier"),c(l,"listeners",{}),c(l,"notifierState",{}),l),A=J;var D=r(s=>s&&Array.isArray(s)&&s.length,"isValidArray");var x={},G=r(s=>{let e="";switch(s.error?.code){case MediaError.MEDIA_ERR_ABORTED:e+=S.MEDIA_ERR_ABORTED;break;case MediaError.MEDIA_ERR_NETWORK:e+=S.MEDIA_ERR_NETWORK;break;case MediaError.MEDIA_ERR_DECODE:e+=S.MEDIA_ERR_DECODE;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:e+=S.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:e+=S.DEFAULT;break}return e},"getReadableErrorMessage"),v=r(s=>{let{title:e,album:t,artist:a,artwork:o}=s,i=o?o[0]?.src:"",g=["96x96","128x128","192x192","256x256","384x384","512x512"].map(I=>({src:i,sizes:I,type:"image/png"}));return {title:e,album:t,artist:a,artwork:g}},"metaDataCreator"),N=0,m=r((s,e)=>{let t=new Set;for(let i=0;ii+d,0);N=["ENDED","TRACK_CHANGE","PAUSE"].includes(e)?o:N,A.notify("AUDIO_STATE",{currentTrackPlayTime:o,previousTrackPlayTime:N});},"calculateActualPlayedLength"),B=r((s,e,t)=>new Promise((a,o)=>{if(window instanceof Window&&window.document)if(x[t])e(),a();else {x[t]=!0;let i=document.createElement("script");i.type="text/javascript",i.src=s,i.async=!0,i.onload=()=>{e(),a();},document.head.appendChild(i);}else o(`Window not ready unable to initialize ${t}`);}),"loadScript");var p,U=(p=class{constructor(){c(this,"audioCtx");c(this,"audioCtxStatus");c(this,"eqFilterBands");if(p._instance)return p._instance;if(this.audioCtx===void 0&&typeof AudioContext<"u")if(typeof AudioContext<"u")this.audioCtx=new AudioContext,this.audioCtxStatus="ACTIVE",this.init();else if(typeof window.webkitAudioContext<"u")this.audioCtx=new window.webkitAudioContext,this.audioCtxStatus="ACTIVE",this.init();else throw new Error("Web Audio API is not supported in this browser.");else this.audioCtxStatus="FAILED";if(this.audioCtxStatus==="ACTIVE"&&this.audioCtx.state==="suspended"){var e=r(()=>{this.audioCtx.resume(),setTimeout(()=>{this.audioCtx.state==="running"&&document.body.removeEventListener("click",e,!1);},0);},"resume");document.body.addEventListener("click",e,!1);}p._instance=this;}init(){try{let e=u.getAudioInstance(),t=this.audioCtx.createMediaElementSource(e),a=k.map(i=>{let d=this.audioCtx.createBiquadFilter();return d.type=i.type,d.frequency.value=i.frequency,d.gain.value=i.gain,d.Q.value=1,d}),o=this.audioCtx.createGain();o.gain.value=1,t.connect(a[0]);for(let i=0;ia.id===e);if(!(!this.eqFilterBands||this.eqFilterBands.length!==t?.gains.length))for(let a=0;a{t.gain.value=e[a];});}},r(p,"Equalizer"),c(p,"_instance"),p);var V={ERROR:(s,e)=>{let t=e.type,a=e.details,o=e.fatal;A.notify("AUDIO_STATE",{playbackState:E.ERROR,error:{type:t,isFatal:o,detail:a}},`audiox_baseEvents_state_${s.type}`);},FRAG_CHANGED:()=>{}};var b=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"}),q={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 P=r((s,e=!1)=>{let t=u.getAudioInstance();D(Object.keys(s))&&Object.keys(s).forEach(a=>{let o=a;t?.addEventListener(b[o],i=>{if(a&&s[o]){let d=s[o];typeof d=="function"&&d(i,t,e);}});});},"attachEventListeners");var K=r((s,e=!1)=>{let a=new R().getHlsInstance();D(Object.keys(s))&&Object.keys(s).forEach(o=>{let i=o;a.on(q[i],(d,g)=>{if(i&&s[i]){let h=s[i];typeof h=="function"&&h(d,g,a,e);}});});},"attachHlsEventsListeners");var y,T,Z=(T=class{constructor(){c(this,"HlsClass");if(T._instance)return T._instance;T._instance=this;}async load(){return await B(M.HLS,()=>{},"hls").then(()=>{this.HlsClass=window.Hls,window.Hls=void 0;}).catch(e=>{}),this.HlsClass}async init(e={},t){let a=await this.load();a.isSupported()&&(y=new a(e),K(V,t));}addHlsMedia(e){let t=this.HlsClass,a=u.getAudioInstance();y.loadSource(e.source),y.attachMedia(a),y.on(t.Events.MEDIA_ATTACHED,function(){});}getHlsInstance(){return y}},r(T,"HlsAdapter"),c(T,"_instance"),T),R=Z;var Y=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var _=A,z={LOADED_META_DATA:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,duration:e?.duration,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_state_${s.type}`);},CAN_PLAY:s=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},CAN_PLAY_THROUGH:s=>{_.notify("AUDIO_STATE",{playbackState:E.READY,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PLAY:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.PLAYING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PAUSE:(s,e,t)=>{_.notify("AUDIO_STATE",{playbackState:E.PAUSED,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&m(e,"PAUSE");},ENDED:(s,e,t)=>{_.notify("AUDIO_STATE",{playbackState:E.ENDED,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&m(e,"ENDED");},ERROR:(s,e)=>{let t=e.error?.code,a=G(e);_.notify("AUDIO_STATE",{playbackState:E.ERROR,error:{code:t,message:Y[t],readable:a}},`audiox_baseEvents_state_${s.type}`);},TIME_UPDATE:(s,e)=>{let t=A.getLatestState("AUDIO_X_STATE");_.notify("AUDIO_STATE",{playbackState:e.paused?t?.playbackState:E.PLAYING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},WAITING:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},VOLUME_CHANGE:s=>{_.notify("AUDIO_STATE",{},"audiox_baseEvents_state");}};var X=r(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata(v(s)));},"updateMetaData"),j=r(()=>{"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",()=>{u.getAudioInstance().play();}),navigator.mediaSession.setActionHandler("pause",()=>{u.getAudioInstance().pause();}));},"attachMediaSessionHandlers");var H={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},F={playbackState:E.IDLE,duration:0,bufferedDuration:0,progress:0,volume:50,playbackRate:1,error:{code:null,message:"",readable:""},currentTrack:{},currentTrackPlayTime:0,previousTrackPlayTime:0};A.listen("AUDIO_STATE",s=>{A.notify("AUDIO_X_STATE",{...F,...s});},F);var n,L=A,f,u=(f=class{constructor(){c(this,"_audio");c(this,"isPlayLogEnabled");c(this,"eqStatus","IDEAL");c(this,"isEqEnabled",!1);c(this,"eqInstance");if(f._instance)return f._instance;if(process.env.NODE_ENV!==O?.DEVELOPMENT&&n)throw new Error("Cannot create multiple audio instance");f._instance=this,this._audio=new Audio,n=this._audio;}async init(e){let{preloadStrategy:t="auto",autoPlay:a=!1,useDefaultEventListeners:o=!0,customEventListeners:i=null,showNotificationActions:d=!1,enablePlayLog:g=!1,enableHls:h=!1,enableEQ:I=!1,crossOrigin:W="anonymous",hlsConfig:$={}}=e;this._audio?.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=a,this._audio.crossOrigin=W,this.isPlayLogEnabled=g,i!==null?P(i,!1):P(z,g),d&&j(),I&&(this.isEqEnabled=I),h&&new R().init($,g);}async addMedia(e){if(!e)return;let t=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&m(n,"TRACK_CHANGE"),t==="HLS"){let a=new R,o=a.getHlsInstance();o?(o.detachMedia(),a.addHlsMedia(e)):await this.reset();}else n.src=e.source;L.notify("AUDIO_STATE",{playbackState:E.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),X(e),n.load();}attachEq(){if(this.isEqEnabled&&this.eqStatus==="IDEAL")try{let e=new U;this.eqStatus=e.status(),this.eqInstance=e;}catch{}}async play(){let e=n.src!=="";n?.paused&&n.HAVE_ENOUGH_DATA===H.HAVE_ENOUGH_DATA&&e&&await n.play().then(()=>{}).catch(()=>{});}async addMediaAndPlay(e){try{e&&this.addMedia(e).then(()=>{n.HAVE_ENOUGH_DATA===H.HAVE_ENOUGH_DATA&&setTimeout(async()=>{this.attachEq(),await this.play();},950);});}catch{}}pause(){n&&!n?.paused&&n?.pause();}stop(){n&&!n.paused&&(n?.pause(),n.currentTime=0);}async reset(){n&&(this.stop(),n.src="",n.srcObject=null);}setVolume(e){let t=e/100;n&&(n.volume=t,L.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){n&&(n.playbackRate=e,L.notify("AUDIO_STATE",{playbackRate:e}));}mute(){n&&!n.muted&&(n.muted=!0);}seek(e){n&&(n.currentTime=e);}async destroy(){n&&(await this.reset(),n.removeAttribute("src"),n.load());}subscribe(e,t,a={}){return L.listen(e,t,a)}addEventListener(e,t){n.addEventListener(e,t);}getPresets(){return U.getPresets()}setPreset(e){this.eqInstance.setPreset(e);}setCustomEQ(e){this.eqInstance.setCustomEQ(e);}get id(){return n?.getAttribute("id")}static getAudioInstance(){return n}},r(f,"AudioX"),c(f,"_instance"),f); +var w=Object.defineProperty;var Q=(s,e,t)=>e in s?w(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e)=>w(s,"name",{value:e,configurable:!0});var c=(s,e,t)=>(Q(s,typeof e!="symbol"?e+"":e,t),t);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}],C=[{id:"preset_default",name:"Default",gains:[0,0,0,0,0,0,0,0,0,0]},{id:"preset_live",name:"Live",gains:[-1,1,3,4,4,4,3,2,2,2]},{id:"preset_acoustic",name:"Acoustic",gains:[6,6,4,1,3,3,4,5,4,1.5]},{id:"preset_classical",name:"Classical",gains:[6,5,4,3,-1,-1,0,2,4,5]},{id:"preset_piano",name:"Piano",gains:[4,2,0,3.5,4,1.5,5,6,4,4.5]},{id:"preset_lounge",name:"Lounge",gains:[-3,-1.5,0,1,5.5,1,0,-1.5,2,.5]},{id:"preset_spoken_word",name:"Spoken Word",gains:[-2,0,0,1,5,6.5,7,6,3,0]},{id:"preset_jazz",name:"Jazz",gains:[5.5,4,1,2,-1.5,-1.5,0,1,4,5.5]},{id:"preset_pop",name:"Pop",gains:[.5,2.4,3.8,4.3,3,0,-.5,-.5,.5,.5]},{id:"preset_dance",name:"Dance",gains:[5,10,6.5,0,2,4.5,7.5,7,5.5,0]},{id:"preset_latin",name:"Latin",gains:[3.5,1.5,0,0,-1.5,-1.5,-1.5,0,4,6.5]},{id:"preset_rnb",name:"RnB",gains:[3.5,10.5,8.5,1,-3,-1.5,3,3.5,4,5]},{id:"preset_hiphop",name:"HipHop",gains:[7,6,1,4,-1,-.5,1,-.5,2,4]},{id:"preset_electronic",name:"Electronic",gains:[6,5.5,1,0,-2,2,1,1.5,5.5,6.5]},{id:"preset_techno",name:"Techno",gains:[3.8,2.4,0,-2.4,-1.9,0,3.8,4.8,4.8,4.3]},{id:"preset_deep",name:"Deep",gains:[6,5,1.5,.5,4,3,1.5,-2,-5,-6.5]},{id:"preset_club",name:"Club",gains:[0,0,3.8,2.4,2.4,2.4,1,0,0,0]},{id:"preset_rock",name:"Rock",gains:[7,5.5,4,1,-.5,0,.5,3,4.5,6.5]},{id:"preset_rock_soft",name:"Rock Soft",gains:[1.5,0,0,-.5,0,1,3.8,4.8,5.7,6.2]},{id:"preset_ska",name:"Ska",gains:[-.5,-1.5,-1,0,1,2,3.8,4.3,5.2,4.3]},{id:"preset_reggae",name:"Reggae",gains:[0,0,0,-2.4,0,2.5,2.5,0,0,0]},{id:"preset_country",name:"Country",gains:[3,2,1,0,-1,0,2,3,4,4]},{id:"preset_funk",name:"Funk",gains:[4,5,3,0,-1,0,2,4,5,5]},{id:"preset_blues",name:"Blues",gains:[2,1,0,-1,0,1,2,3,4,3]},{id:"preset_metal",name:"Metal",gains:[8,7,6,4,2,1,0,2,4,6]},{id:"preset_indie",name:"Indie",gains:[2,3,2,1,0,-1,-2,0,3,4]},{id:"preset_chill",name:"Chill",gains:[1,1,0,-1,-2,-1,1,2,3,2]},{id:"preset_world",name:"World",gains:[3,2,0,-2,-1,1,3,4,5,3]},{id:"preset_alternative",name:"Alternative",gains:[3,2,1,0,-1,-2,1,3,4,3]},{id:"preset_ambient",name:"Ambient",gains:[0,-1,-2,-3,-2,0,1,2,3,2]},{id:"preset_mellow",name:"Mellow",gains:[1,1,0,-1,-2,-1,1,2,3,1]},{id:"preset_grunge",name:"Grunge",gains:[5,4,3,2,1,0,0,2,4,5]},{id:"preset_soul",name:"Soul",gains:[3,3,2,1,0,-1,0,2,3,3]},{id:"preset_folk",name:"Folk",gains:[2,1,0,-1,-2,-1,1,2,3,2]},{id:"preset_trap",name:"Trap",gains:[7,6,3,1,-2,-1,1,3,6,7]},{id:"preset_dubstep",name:"Dubstep",gains:[6,5,4,3,2,1,1,3,5,6]}];var O=Object.freeze({REACT:"REACT",VANILLA:"VANILLA",DEVELOPMENT:"development"}),E=Object.freeze({BUFFERING:"buffering",PLAYING:"playing",PAUSED:"paused",READY:"ready",IDLE:"idle",ENDED:"ended",STALLED:"stalled",ERROR:"error",TRACK_CHANGE:"trackchanged"}),S=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."}),x={HLS:"https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"};var l,J=(l=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 o=l.listeners[e];o&&t!==null&&(l.notifierState[e]={...l.notifierState[e]||{},...t},o.forEach(i=>{i(l.notifierState[e]);}));}static listen(e,t,a={}){if(this.validateEventName(e),typeof t!="function")throw new Error("Callback must be a function");return l.listeners[e]?l.listeners[e].add(t):(l.notifierState[e]=a,l.listeners[e]=new Set([t])),()=>{let o=l.listeners[e];o&&(o.delete(t),o.size===0&&delete l.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 o=t.map(i=>l.listen(e,i,a));return ()=>{o.forEach(i=>i());}}static getLatestState(e){return this.validateEventName(e),l.notifierState[e]}},r(l,"ChangeNotifier"),c(l,"listeners",{}),c(l,"notifierState",{}),l),A=J;var D=r(s=>s&&Array.isArray(s)&&s.length,"isValidArray");var M={},G=r(s=>{let e="";switch(s.error?.code){case MediaError.MEDIA_ERR_ABORTED:e+=S.MEDIA_ERR_ABORTED;break;case MediaError.MEDIA_ERR_NETWORK:e+=S.MEDIA_ERR_NETWORK;break;case MediaError.MEDIA_ERR_DECODE:e+=S.MEDIA_ERR_DECODE;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:e+=S.MEDIA_ERR_SRC_NOT_SUPPORTED;break;default:e+=S.DEFAULT;break}return e},"getReadableErrorMessage"),v=r(s=>{let{title:e,album:t,artist:a,artwork:o}=s,i=o?o[0]?.src:"",g=["96x96","128x128","192x192","256x256","384x384","512x512"].map(I=>({src:i,sizes:I,type:"image/png"}));return {title:e,album:t,artist:a,artwork:g}},"metaDataCreator"),N=0,m=r((s,e)=>{let t=new Set;for(let i=0;ii+d,0);N=["ENDED","TRACK_CHANGE","PAUSE"].includes(e)?o:N,A.notify("AUDIO_STATE",{currentTrackPlayTime:o,previousTrackPlayTime:N});},"calculateActualPlayedLength"),B=r((s,e,t)=>new Promise((a,o)=>{if(window instanceof Window&&window.document)if(M[t])e(),a();else {M[t]=!0;let i=document.createElement("script");i.type="text/javascript",i.src=s,i.async=!0,i.onload=()=>{e(),a();},document.head.appendChild(i);}else o(`Window not ready unable to initialize ${t}`);}),"loadScript");var p,U=(p=class{constructor(){c(this,"audioCtx");c(this,"audioCtxStatus");c(this,"eqFilterBands");if(p._instance)return p._instance;if(this.audioCtx===void 0&&typeof AudioContext<"u")if(typeof AudioContext<"u")this.audioCtx=new AudioContext,this.audioCtxStatus="ACTIVE",this.init();else if(typeof window.webkitAudioContext<"u")this.audioCtx=new window.webkitAudioContext,this.audioCtxStatus="ACTIVE",this.init();else throw new Error("Web Audio API is not supported in this browser.");else this.audioCtxStatus="FAILED";if(this.audioCtxStatus==="ACTIVE"&&this.audioCtx.state==="suspended"){var e=r(()=>{this.audioCtx.resume(),setTimeout(()=>{this.audioCtx.state==="running"&&document.body.removeEventListener("click",e,!1);},0);},"resume");document.body.addEventListener("click",e,!1);}p._instance=this;}init(){try{let e=u.getAudioInstance(),t=this.audioCtx.createMediaElementSource(e),a=k.map(i=>{let d=this.audioCtx.createBiquadFilter();return d.type=i.type,d.frequency.value=i.frequency,d.gain.value=i.gain,d.Q.value=1,d}),o=this.audioCtx.createGain();o.gain.value=1,t.connect(a[0]);for(let i=0;ia.id===e);if(!(!this.eqFilterBands||this.eqFilterBands.length!==t?.gains.length))for(let a=0;a{t.gain.value=e[a];});}},r(p,"Equalizer"),c(p,"_instance"),p);var V={ERROR:(s,e)=>{let t=e.type,a=e.details,o=e.fatal;A.notify("AUDIO_STATE",{playbackState:E.ERROR,error:{type:t,isFatal:o,detail:a}},`audiox_baseEvents_state_${s.type}`);},FRAG_CHANGED:()=>{}};var b=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"}),q={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 P=r((s,e=!1)=>{let t=u.getAudioInstance();D(Object.keys(s))&&Object.keys(s).forEach(a=>{let o=a;t?.addEventListener(b[o],i=>{if(a&&s[o]){let d=s[o];typeof d=="function"&&d(i,t,e);}});});},"attachEventListeners");var K=r((s,e=!1)=>{let a=new R().getHlsInstance();D(Object.keys(s))&&Object.keys(s).forEach(o=>{let i=o;a.on(q[i],(d,g)=>{if(i&&s[i]){let h=s[i];typeof h=="function"&&h(d,g,a,e);}});});},"attachHlsEventsListeners");var y,T,Z=(T=class{constructor(){c(this,"HlsClass");if(T._instance)return T._instance;T._instance=this;}async load(){return await B(x.HLS,()=>{},"hls").then(()=>{this.HlsClass=window.Hls,window.Hls=void 0;}).catch(e=>{}),this.HlsClass}async init(e={},t){let a=await this.load();a.isSupported()&&(y=new a(e),K(V,t));}addHlsMedia(e){let t=this.HlsClass,a=u.getAudioInstance();y.loadSource(e.source),y.attachMedia(a),y.on(t.Events.MEDIA_ATTACHED,function(){});}getHlsInstance(){return y}},r(T,"HlsAdapter"),c(T,"_instance"),T),R=Z;var Y=Object.freeze({1:"MEDIA_ERR_ABORTED",3:"MEDIA_ERR_DECODE",2:"MEDIA_ERR_NETWORK",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"});var _=A,z={LOADED_META_DATA:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,duration:e?.duration,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_state_${s.type}`);},CAN_PLAY:s=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},CAN_PLAY_THROUGH:s=>{_.notify("AUDIO_STATE",{playbackState:E.READY,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PLAY:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.PLAYING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},PAUSE:(s,e,t)=>{_.notify("AUDIO_STATE",{playbackState:E.PAUSED,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&m(e,"PAUSE");},ENDED:(s,e,t)=>{_.notify("AUDIO_STATE",{playbackState:E.ENDED,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`),t&&m(e,"ENDED");},ERROR:(s,e)=>{let t=e.error?.code,a=G(e);_.notify("AUDIO_STATE",{playbackState:E.ERROR,error:{code:t,message:Y[t],readable:a}},`audiox_baseEvents_state_${s.type}`);},TIME_UPDATE:(s,e)=>{let t=A.getLatestState("AUDIO_X_STATE");_.notify("AUDIO_STATE",{playbackState:e.paused?t?.playbackState:E.PLAYING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},WAITING:(s,e)=>{_.notify("AUDIO_STATE",{playbackState:E.BUFFERING,progress:e?.currentTime,error:{code:null,message:"",readable:""}},`audiox_baseEvents_state_${s.type}`);},VOLUME_CHANGE:s=>{_.notify("AUDIO_STATE",{},"audiox_baseEvents_state");}};var X=r(s=>{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new MediaMetadata(v(s)));},"updateMetaData"),j=r(()=>{"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",()=>{u.getAudioInstance().play();}),navigator.mediaSession.setActionHandler("pause",()=>{u.getAudioInstance().pause();}));},"attachMediaSessionHandlers");var H={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},F={playbackState:E.IDLE,duration:0,bufferedDuration:0,progress:0,volume:50,playbackRate:1,error:{code:null,message:"",readable:""},currentTrack:{},currentTrackPlayTime:0,previousTrackPlayTime:0};A.listen("AUDIO_STATE",s=>{A.notify("AUDIO_X_STATE",{...F,...s});},F);var n,L=A,f,u=(f=class{constructor(){c(this,"_audio");c(this,"isPlayLogEnabled");c(this,"eqStatus","IDEAL");c(this,"isEqEnabled",!1);c(this,"eqInstance");if(f._instance)return f._instance;if(process.env.NODE_ENV!==O?.DEVELOPMENT&&n)throw new Error("Cannot create multiple audio instance");f._instance=this,this._audio=new Audio,n=this._audio;}async init(e){let{preloadStrategy:t="auto",autoPlay:a=!1,useDefaultEventListeners:o=!0,customEventListeners:i=null,showNotificationActions:d=!1,enablePlayLog:g=!1,enableHls:h=!1,enableEQ:I=!1,crossOrigin:W="anonymous",hlsConfig:$={}}=e;this._audio?.setAttribute("id","audio_x_instance"),this._audio.preload=t,this._audio.autoplay=a,this._audio.crossOrigin=W,this.isPlayLogEnabled=g,i!==null?P(i,!1):P(z,g),d&&j(),I&&(this.isEqEnabled=I),h&&new R().init($,g);}async addMedia(e){if(!e)return;let t=e.source.includes(".m3u8")?"HLS":"DEFAULT";if(this.isPlayLogEnabled&&m(n,"TRACK_CHANGE"),t==="HLS"){let a=new R,o=a.getHlsInstance();o?(o.detachMedia(),a.addHlsMedia(e)):await this.reset();}else n.src=e.source;L.notify("AUDIO_STATE",{playbackState:E.TRACK_CHANGE,currentTrackPlayTime:0,currentTrack:e}),X(e),n.load();}attachEq(){if(this.isEqEnabled&&this.eqStatus==="IDEAL")try{let e=new U;this.eqStatus=e.status(),this.eqInstance=e;}catch{}}async play(){let e=n.src!=="";n?.paused&&n.HAVE_ENOUGH_DATA===H.HAVE_ENOUGH_DATA&&e&&await n.play().then(()=>{}).catch(()=>{});}async addMediaAndPlay(e){try{e&&this.addMedia(e).then(()=>{n.HAVE_ENOUGH_DATA===H.HAVE_ENOUGH_DATA&&setTimeout(async()=>{this.attachEq(),await this.play();},950);});}catch{}}pause(){n&&!n?.paused&&n?.pause();}stop(){n&&!n.paused&&(n?.pause(),n.currentTime=0);}async reset(){n&&(this.stop(),n.src="",n.srcObject=null);}setVolume(e){let t=e/100;n&&(n.volume=t,L.notify("AUDIO_STATE",{volume:e}));}setPlaybackRate(e){n&&(n.playbackRate=e,L.notify("AUDIO_STATE",{playbackRate:e}));}mute(){n&&!n.muted&&(n.muted=!0);}seek(e){n&&(n.currentTime=e);}async destroy(){n&&(await this.reset(),n.removeAttribute("src"),n.load());}subscribe(e,t,a={}){return L.listen(e,t,a)}addEventListener(e,t){n.addEventListener(e,t);}getPresets(){return U.getPresets()}setPreset(e){this.eqInstance.setPreset(e);}setCustomEQ(e){this.eqInstance.setCustomEQ(e);}get id(){return n?.getAttribute("id")}static getAudioInstance(){return n}},r(f,"AudioX"),c(f,"_instance"),f); export { b as AUDIO_EVENTS, F as AUDIO_STATE, O as AUDIO_X_CONSTANTS, u as AudioX }; //# sourceMappingURL=out.js.map diff --git a/dist/index.js.map b/dist/index.js.map index 596aa2f..4297cc3 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","id","name","gains","AUDIO_X_CONSTANTS","Object","freeze","REACT","VANILLA","DEVELOPMENT","PLAYBACK_STATE","BUFFERING","PLAYING","PAUSED","READY","IDLE","ENDED","STALLED","ERROR","TRACK_CHANGE","ERROR_MSG_MAP","MEDIA_ERR_ABORTED","MEDIA_ERR_DECODE","MEDIA_ERR_NETWORK","MEDIA_ERR_SRC_NOT_SUPPORTED","DEFAULT","URLS","HLS","_a","ChangeNotifier","validateEventName","eventName","Error","notify","data","caller","listenerCbs","listeners","notifierState","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","isValidWindow","window","undefined","Window","loadedScripts","getReadableErrorMessage","audioInstance","message","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","Equalizer","constructor","audioCtx","audioCtxStatus","eqFilterBands","_instance","AudioContext","init","webkitAudioContext","resume","setTimeout","body","removeEventListener","addEventListener","AudioX","getAudioInstance","audioSource","createMediaElementSource","equalizerBands","band","filter","createBiquadFilter","value","Q","gainNode","createGain","connect","destination","setPreset","preset","find","getPresets","status","setCustomEQ","index","HLS_EVENTS_CALLBACK_MAP","e","detail","details","isFatal","fatal","playbackState","FRAG_CHANGED","AUDIO_EVENTS","ABORT","TIME_UPDATE","CAN_PLAY","CAN_PLAY_THROUGH","DURATION_CHANGE","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","then","Hls","catch","msg","config","enablePlayLog","isSupported","addHlsMedia","loadSource","source","attachMedia","Events","hls_default","ERROR_EVENTS","notifier","BASE_EVENT_CALLBACK_MAP","duration","readable","progress","currentTime","errorCode","audioState","paused","updateMetaData","navigator","mediaSession","metadata","MediaMetadata","attachMediaSessionHandlers","setActionHandler","play","pause","READY_STATE","HAVE_NOTHING","HAVE_METADATA","HAVE_CURRENT_DATA","HAVE_FUTURE_DATA","HAVE_ENOUGH_DATA","AUDIO_STATE","bufferedDuration","volume","playbackRate","currentTrack","_audio","isPlayLogEnabled","eqStatus","isEqEnabled","eqInstance","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","stop","srcObject","setVolume","actualVolume","setPlaybackRate","mute","muted","seek","time","destroy","removeAttribute","subscribe","getAttribute"],"mappings":"2NAEA,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,UAAWC,KAAM,CAAE,EAC3C,CAAEF,UAAW,IAAKC,KAAM,UAAWC,KAAM,CAAE,EAC3C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,KAAOC,KAAM,YAAaC,KAAM,CAAE,GAG3CC,EAAoB,CACxB,CACEC,GAAI,iBACJC,KAAM,UACNC,MAA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AAOV,EAAWW,EAAUC,CAAAA,CAE3D,CAEAmF,iBACEvC,EACA7C,EACA,CACA2B,EAAcyD,iBAAiBvC,EAAO7C,CAAAA,CACxC,CAEAsG,YAAa,CACX,OAAO/B,EAAU+B,WAAU,CAC7B,CAEAH,UAAU5I,EAAkB,CAC1B,KAAKkS,WAAWtJ,UAAU5I,CAAAA,CAC5B,CAEAiJ,YAAY/I,EAAiB,CAC3B,KAAKgS,WAAWjJ,YAAY/I,CAAAA,CAC9B,CAEA,IAAIF,IAAK,CACP,OAAOoE,GAAeqQ,aAAa,IAAA,CACrC,CAEA,OAAO1M,kBAAmB,CACxB,OAAO3D,CACT,CACF,EA7RM0D,EAAAA,EAAAA,UAGJrE,EAHF9B,EAGiB0F,aAHjB1F","sourcesContent":["import { Band, Preset } from 'types/equalizer.types';\n\nconst bands: Band[] = [\n { frequency: 31, type: 'lowshelf', gain: 0 }, // Band 0: 31 Hz - Low Shelf Filter\n { frequency: 63, type: 'peaking', gain: 0 }, // Band 1: 63 Hz - Peaking Filter\n { frequency: 125, type: 'peaking', gain: 0 }, // Band 2: 125 Hz - Peaking Filter\n { frequency: 250, type: 'peaking', gain: 0 }, // Band 3: 250 Hz - Peaking Filter\n { frequency: 500, type: 'peaking', gain: 0 }, // Band 4: 500 Hz - Peaking Filter\n { frequency: 1000, type: 'peaking', gain: 0 }, // Band 5: 1 kHz - Peaking Filter\n { frequency: 2000, type: 'peaking', gain: 0 }, // Band 6: 2 kHz - Peaking Filter\n { frequency: 4000, type: 'peaking', gain: 0 }, // Band 7: 4 kHz - Peaking Filter\n { frequency: 8000, type: 'peaking', gain: 0 }, // Band 8: 8 kHz - Peaking Filter\n { frequency: 16000, type: 'highshelf', gain: 0 } // Band 9: 16 kHz - High Shelf Filter\n];\n\nconst presets: Preset[] = [\n {\n id: 'preset_default',\n name: 'Default',\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 id: 'preset_live',\n name: 'Live',\n gains: [-1.0, 1.0, 3.0, 4.0, 4.0, 4.0, 3.0, 2.0, 2.0, 2.0]\n },\n {\n id: 'preset_acoustic',\n name: 'Acoustic',\n gains: [6.0, 6.0, 4.0, 1.0, 3.0, 3.0, 4.0, 5.0, 4.0, 1.5]\n },\n {\n id: 'preset_classical',\n name: 'Classical',\n gains: [6.0, 5.0, 4.0, 3.0, -1.0, -1.0, 0.0, 2.0, 4.0, 5.0]\n },\n {\n id: 'preset_piano',\n name: 'Piano',\n gains: [4.0, 2.0, 0.0, 3.5, 4.0, 1.5, 5.0, 6.0, 4.0, 4.5]\n },\n {\n id: 'preset_lounge',\n name: 'Lounge',\n gains: [-3.0, -1.5, 0.0, 1.0, 5.5, 1.0, 0.0, -1.5, 2.0, 0.5]\n },\n {\n id: 'preset_spoken_word',\n name: 'Spoken Word',\n gains: [-2.0, 0.0, 0.0, 1.0, 5.0, 6.5, 7.0, 6.0, 3.0, 0.0]\n },\n {\n id: 'preset_jazz',\n name: 'Jazz',\n gains: [5.5, 4.0, 1.0, 2.0, -1.5, -1.5, 0.0, 1.0, 4.0, 5.5]\n },\n {\n id: 'preset_pop',\n name: 'Pop',\n gains: [0.5, 2.4, 3.8, 4.3, 3.0, 0.0, -0.5, -0.5, 0.5, 0.5]\n },\n {\n id: 'preset_dance',\n name: 'Dance',\n gains: [5.0, 10.0, 6.5, 0.0, 2.0, 4.5, 7.5, 7.0, 5.5, 0.0]\n },\n {\n id: 'preset_latin',\n name: 'Latin',\n gains: [3.5, 1.5, 0.0, 0.0, -1.5, -1.5, -1.5, 0.0, 4.0, 6.5]\n },\n {\n id: 'preset_rnb',\n name: 'RnB',\n gains: [3.5, 10.5, 8.5, 1.0, -3.0, -1.5, 3.0, 3.5, 4.0, 5.0]\n },\n {\n id: 'preset_hiphop',\n name: 'HipHop',\n gains: [7.0, 6.0, 1.0, 4.0, -1.0, -0.5, 1.0, -0.5, 2.0, 4.0]\n },\n {\n id: 'preset_electronic',\n name: 'Electronic',\n gains: [6.0, 5.5, 1.0, 0.0, -2.0, 2.0, 1.0, 1.5, 5.5, 6.5]\n },\n {\n id: 'preset_techno',\n name: 'Techno',\n gains: [3.8, 2.4, 0.0, -2.4, -1.9, 0.0, 3.8, 4.8, 4.8, 4.3]\n },\n {\n id: 'preset_deep',\n name: 'Deep',\n gains: [6.0, 5.0, 1.5, 0.5, 4.0, 3.0, 1.5, -2.0, -5.0, -6.5]\n },\n {\n id: 'preset_club',\n name: 'Club',\n gains: [0.0, 0.0, 3.8, 2.4, 2.4, 2.4, 1.0, 0.0, 0.0, 0.0]\n },\n {\n id: 'preset_rock',\n name: 'Rock',\n gains: [7.0, 5.5, 4.0, 1.0, -0.5, 0.0, 0.5, 3.0, 4.5, 6.5]\n },\n {\n id: 'preset_rock_soft',\n name: 'Rock Soft',\n gains: [1.5, 0.0, 0.0, -0.5, 0.0, 1.0, 3.8, 4.8, 5.7, 6.2]\n },\n {\n id: 'preset_ska',\n name: 'Ska',\n gains: [-0.5, -1.5, -1.0, 0.0, 1.0, 2.0, 3.8, 4.3, 5.2, 4.3]\n },\n {\n id: 'preset_reggae',\n name: 'Reggae',\n gains: [0.0, 0.0, 0.0, -2.4, 0.0, 2.5, 2.5, 0.0, 0.0, 0.0]\n },\n {\n id: 'preset_country',\n name: 'Country',\n gains: [3.0, 2.0, 1.0, 0.0, -1.0, 0.0, 2.0, 3.0, 4.0, 4.0]\n },\n {\n id: 'preset_funk',\n name: 'Funk',\n gains: [4.0, 5.0, 3.0, 0.0, -1.0, 0.0, 2.0, 4.0, 5.0, 5.0]\n },\n {\n id: 'preset_blues',\n name: 'Blues',\n gains: [2.0, 1.0, 0.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 3.0]\n },\n {\n id: 'preset_metal',\n name: 'Metal',\n gains: [8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0, 2.0, 4.0, 6.0]\n },\n {\n id: 'preset_indie',\n name: 'Indie',\n gains: [2.0, 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, 0.0, 3.0, 4.0]\n },\n {\n id: 'preset_chill',\n name: 'Chill',\n gains: [1.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_world',\n name: 'World',\n gains: [3.0, 2.0, 0.0, -2.0, -1.0, 1.0, 3.0, 4.0, 5.0, 3.0]\n },\n {\n id: 'preset_alternative',\n name: 'Alternative',\n gains: [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, 1.0, 3.0, 4.0, 3.0]\n },\n {\n id: 'preset_ambient',\n name: 'Ambient',\n gains: [0.0, -1.0, -2.0, -3.0, -2.0, 0.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_mellow',\n name: 'Mellow',\n gains: [1.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 1.0]\n },\n {\n id: 'preset_grunge',\n name: 'Grunge',\n gains: [5.0, 4.0, 3.0, 2.0, 1.0, 0.0, 0.0, 2.0, 4.0, 5.0]\n },\n {\n id: 'preset_soul',\n name: 'Soul',\n gains: [3.0, 3.0, 2.0, 1.0, 0.0, -1.0, 0.0, 2.0, 3.0, 3.0]\n },\n {\n id: 'preset_folk',\n name: 'Folk',\n gains: [2.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_trap',\n name: 'Trap',\n gains: [7.0, 6.0, 3.0, 1.0, -2.0, -1.0, 1.0, 3.0, 6.0, 7.0]\n },\n {\n id: 'preset_dubstep',\n name: 'Dubstep',\n gains: [6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 1.0, 3.0, 5.0, 6.0]\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});\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://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js'\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 { ERROR_MSG_MAP } from 'constants/common';\nimport { AudioEvents, 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\nexport {\n getReadableErrorMessage,\n isValidArray,\n isValidFunction,\n isValidObject,\n isValidWindow,\n loadScript,\n metaDataCreator\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 constructor() {\n if (Equalizer._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of Equalizer returning existing instance'\n );\n return Equalizer._instance;\n }\n\n if (this.audioCtx === undefined && typeof AudioContext !== 'undefined') {\n if (typeof AudioContext !== 'undefined') {\n this.audioCtx = new AudioContext();\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n } else if (typeof (window as any).webkitAudioContext !== 'undefined') {\n this.audioCtx = new (window as any).webkitAudioContext();\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n } else {\n throw new Error('Web Audio API is not supported in this browser.');\n }\n } else {\n console.log('Equalizer not initialized, AudioContext failed');\n this.audioCtxStatus = 'FAILED';\n }\n\n // context state at this time is `undefined` in iOS8 Safari\n if (\n this.audioCtxStatus === 'ACTIVE' &&\n this.audioCtx.state === 'suspended'\n ) {\n var 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 Equalizer._instance = this;\n }\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; //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 this.audioCtxStatus = 'FAILED';\n }\n }\n\n setPreset(id: keyof Preset) {\n const preset = presets.find((el) => el.id === id);\n console.log({ preset });\n if (\n !this.eqFilterBands ||\n this.eqFilterBands.length !== preset?.gains.length\n ) {\n console.error('Invalid data provided.');\n return;\n }\n for (let i = 0; i < this.eqFilterBands.length; i++) {\n this.eqFilterBands[i].gain.value = preset?.gains[i];\n }\n }\n\n static getPresets() {\n return presets;\n }\n\n status() {\n if (this.audioCtx.state === 'suspended') {\n this.audioCtx.resume();\n }\n return this.audioCtxStatus;\n }\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 }\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 getReadableErrorMessage\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState, EventListenerCallbackMap } from 'types';\nimport { ERROR_EVENTS } from './errorEvents';\nconst notifier = ChangeNotifier;\n\nconst BASE_EVENT_CALLBACK_MAP: EventListenerCallbackMap = {\n LOADED_META_DATA: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_state_${e.type}`\n );\n },\n\n CAN_PLAY: (e: Event) => {\n console.log('STATUS', e.type);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY_THROUGH: (e: Event) => {\n console.log('STATUS', e.type);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' }\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 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 = ChangeNotifier.getLatestState(\n 'AUDIO_X_STATE'\n ) as AudioState;\n\n console.log('------------>audioState', audioState);\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 },\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\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 if ('mediaSession' in navigator) {\n navigator.mediaSession.setActionHandler('play', () => {\n const audioInstance = AudioX.getAudioInstance();\n\n audioInstance.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.pause();\n });\n }\n};\n\nexport const updatePositionState = () => {\n ChangeNotifier.listen('AUDIO_X_STATE', (data: AudioState) => {\n if (data?.duration && data?.playbackRate && data?.progress) {\n navigator.mediaSession.setPositionState({\n duration: data.duration,\n playbackRate: data.playbackRate,\n position: data.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 (data: AudioState) => {\n ChangeNotifier.notify('AUDIO_X_STATE', { ...AUDIO_STATE, ...data });\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 { calculateActualPlayedLength } 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 { AudioInit, MediaTrack, PlaybackRate } 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 eqStatus: EqualizerStatus = 'IDEAL';\n private isEqEnabled: boolean = false;\n private eqInstance: Equalizer;\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 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 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 console.log('calling addMedia');\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(mediaTrack: MediaTrack) {\n try {\n if (mediaTrack) {\n this.addMedia(mediaTrack).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 }\n } catch (error) {\n console.log('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 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 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","presets","id","name","gains","AUDIO_X_CONSTANTS","Object","freeze","REACT","VANILLA","DEVELOPMENT","PLAYBACK_STATE","BUFFERING","PLAYING","PAUSED","READY","IDLE","ENDED","STALLED","ERROR","TRACK_CHANGE","ERROR_MSG_MAP","MEDIA_ERR_ABORTED","MEDIA_ERR_DECODE","MEDIA_ERR_NETWORK","MEDIA_ERR_SRC_NOT_SUPPORTED","DEFAULT","URLS","HLS","_a","ChangeNotifier","validateEventName","eventName","Error","notify","data","caller","listenerCbs","listeners","notifierState","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","isValidWindow","window","undefined","Window","loadedScripts","getReadableErrorMessage","audioInstance","message","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","Equalizer","constructor","audioCtx","audioCtxStatus","eqFilterBands","_instance","AudioContext","init","webkitAudioContext","resume","setTimeout","body","removeEventListener","addEventListener","AudioX","getAudioInstance","audioSource","createMediaElementSource","equalizerBands","band","filter","createBiquadFilter","value","Q","gainNode","createGain","connect","destination","setPreset","preset","find","getPresets","status","setCustomEQ","index","HLS_EVENTS_CALLBACK_MAP","e","detail","details","isFatal","fatal","playbackState","FRAG_CHANGED","AUDIO_EVENTS","ABORT","TIME_UPDATE","CAN_PLAY","CAN_PLAY_THROUGH","DURATION_CHANGE","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","then","Hls","catch","msg","config","enablePlayLog","isSupported","addHlsMedia","loadSource","source","attachMedia","Events","hls_default","ERROR_EVENTS","notifier","BASE_EVENT_CALLBACK_MAP","duration","readable","progress","currentTime","errorCode","audioState","paused","updateMetaData","navigator","mediaSession","metadata","MediaMetadata","attachMediaSessionHandlers","setActionHandler","play","pause","READY_STATE","HAVE_NOTHING","HAVE_METADATA","HAVE_CURRENT_DATA","HAVE_FUTURE_DATA","HAVE_ENOUGH_DATA","AUDIO_STATE","bufferedDuration","volume","playbackRate","currentTrack","_audio","isPlayLogEnabled","eqStatus","isEqEnabled","eqInstance","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","stop","srcObject","setVolume","actualVolume","setPlaybackRate","mute","muted","seek","time","destroy","removeAttribute","subscribe","getAttribute"],"mappings":"2NAEA,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,UAAWC,KAAM,CAAE,EAC3C,CAAEF,UAAW,IAAKC,KAAM,UAAWC,KAAM,CAAE,EAC3C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,IAAMC,KAAM,UAAWC,KAAM,CAAE,EAC5C,CAAEF,UAAW,KAAOC,KAAM,YAAaC,KAAM,CAAE,GAG3CC,EAAoB,CACxB,CACEC,GAAI,iBACJC,KAAM,UACNC,MAAO,CAAC,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EACvD,EACA,CACEF,GAAI,cACJC,KAAM,OACNC,MAAO,CAAC,GAAM,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EACxD,EACA,CACEF,GAAI,kBACJC,KAAM,WACNC,MAAO,CAAC,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,EAAK,IACvD,EACA,CACEF,GAAI,mBACJC,KAAM,YACNC,MAAO,CAAC,EAAK,EAAK,EA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AAa,IAAA,CACrC,CAEA,OAAO1M,kBAAmB,CACxB,OAAO3D,CACT,CACF,EA7RM0D,EAAAA,EAAAA,UAGJrE,EAHF9B,EAGiB0F,aAHjB1F","sourcesContent":["import { Band, Preset } from 'types/equalizer.types';\n\nconst bands: Band[] = [\n { frequency: 31, type: 'lowshelf', gain: 0 }, // Band 0: 31 Hz - Low Shelf Filter\n { frequency: 63, type: 'peaking', gain: 0 }, // Band 1: 63 Hz - Peaking Filter\n { frequency: 125, type: 'peaking', gain: 0 }, // Band 2: 125 Hz - Peaking Filter\n { frequency: 250, type: 'peaking', gain: 0 }, // Band 3: 250 Hz - Peaking Filter\n { frequency: 500, type: 'peaking', gain: 0 }, // Band 4: 500 Hz - Peaking Filter\n { frequency: 1000, type: 'peaking', gain: 0 }, // Band 5: 1 kHz - Peaking Filter\n { frequency: 2000, type: 'peaking', gain: 0 }, // Band 6: 2 kHz - Peaking Filter\n { frequency: 4000, type: 'peaking', gain: 0 }, // Band 7: 4 kHz - Peaking Filter\n { frequency: 8000, type: 'peaking', gain: 0 }, // Band 8: 8 kHz - Peaking Filter\n { frequency: 16000, type: 'highshelf', gain: 0 } // Band 9: 16 kHz - High Shelf Filter\n];\n\nconst presets: Preset[] = [\n {\n id: 'preset_default',\n name: 'Default',\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 id: 'preset_live',\n name: 'Live',\n gains: [-1.0, 1.0, 3.0, 4.0, 4.0, 4.0, 3.0, 2.0, 2.0, 2.0]\n },\n {\n id: 'preset_acoustic',\n name: 'Acoustic',\n gains: [6.0, 6.0, 4.0, 1.0, 3.0, 3.0, 4.0, 5.0, 4.0, 1.5]\n },\n {\n id: 'preset_classical',\n name: 'Classical',\n gains: [6.0, 5.0, 4.0, 3.0, -1.0, -1.0, 0.0, 2.0, 4.0, 5.0]\n },\n {\n id: 'preset_piano',\n name: 'Piano',\n gains: [4.0, 2.0, 0.0, 3.5, 4.0, 1.5, 5.0, 6.0, 4.0, 4.5]\n },\n {\n id: 'preset_lounge',\n name: 'Lounge',\n gains: [-3.0, -1.5, 0.0, 1.0, 5.5, 1.0, 0.0, -1.5, 2.0, 0.5]\n },\n {\n id: 'preset_spoken_word',\n name: 'Spoken Word',\n gains: [-2.0, 0.0, 0.0, 1.0, 5.0, 6.5, 7.0, 6.0, 3.0, 0.0]\n },\n {\n id: 'preset_jazz',\n name: 'Jazz',\n gains: [5.5, 4.0, 1.0, 2.0, -1.5, -1.5, 0.0, 1.0, 4.0, 5.5]\n },\n {\n id: 'preset_pop',\n name: 'Pop',\n gains: [0.5, 2.4, 3.8, 4.3, 3.0, 0.0, -0.5, -0.5, 0.5, 0.5]\n },\n {\n id: 'preset_dance',\n name: 'Dance',\n gains: [5.0, 10.0, 6.5, 0.0, 2.0, 4.5, 7.5, 7.0, 5.5, 0.0]\n },\n {\n id: 'preset_latin',\n name: 'Latin',\n gains: [3.5, 1.5, 0.0, 0.0, -1.5, -1.5, -1.5, 0.0, 4.0, 6.5]\n },\n {\n id: 'preset_rnb',\n name: 'RnB',\n gains: [3.5, 10.5, 8.5, 1.0, -3.0, -1.5, 3.0, 3.5, 4.0, 5.0]\n },\n {\n id: 'preset_hiphop',\n name: 'HipHop',\n gains: [7.0, 6.0, 1.0, 4.0, -1.0, -0.5, 1.0, -0.5, 2.0, 4.0]\n },\n {\n id: 'preset_electronic',\n name: 'Electronic',\n gains: [6.0, 5.5, 1.0, 0.0, -2.0, 2.0, 1.0, 1.5, 5.5, 6.5]\n },\n {\n id: 'preset_techno',\n name: 'Techno',\n gains: [3.8, 2.4, 0.0, -2.4, -1.9, 0.0, 3.8, 4.8, 4.8, 4.3]\n },\n {\n id: 'preset_deep',\n name: 'Deep',\n gains: [6.0, 5.0, 1.5, 0.5, 4.0, 3.0, 1.5, -2.0, -5.0, -6.5]\n },\n {\n id: 'preset_club',\n name: 'Club',\n gains: [0.0, 0.0, 3.8, 2.4, 2.4, 2.4, 1.0, 0.0, 0.0, 0.0]\n },\n {\n id: 'preset_rock',\n name: 'Rock',\n gains: [7.0, 5.5, 4.0, 1.0, -0.5, 0.0, 0.5, 3.0, 4.5, 6.5]\n },\n {\n id: 'preset_rock_soft',\n name: 'Rock Soft',\n gains: [1.5, 0.0, 0.0, -0.5, 0.0, 1.0, 3.8, 4.8, 5.7, 6.2]\n },\n {\n id: 'preset_ska',\n name: 'Ska',\n gains: [-0.5, -1.5, -1.0, 0.0, 1.0, 2.0, 3.8, 4.3, 5.2, 4.3]\n },\n {\n id: 'preset_reggae',\n name: 'Reggae',\n gains: [0.0, 0.0, 0.0, -2.4, 0.0, 2.5, 2.5, 0.0, 0.0, 0.0]\n },\n {\n id: 'preset_country',\n name: 'Country',\n gains: [3.0, 2.0, 1.0, 0.0, -1.0, 0.0, 2.0, 3.0, 4.0, 4.0]\n },\n {\n id: 'preset_funk',\n name: 'Funk',\n gains: [4.0, 5.0, 3.0, 0.0, -1.0, 0.0, 2.0, 4.0, 5.0, 5.0]\n },\n {\n id: 'preset_blues',\n name: 'Blues',\n gains: [2.0, 1.0, 0.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 3.0]\n },\n {\n id: 'preset_metal',\n name: 'Metal',\n gains: [8.0, 7.0, 6.0, 4.0, 2.0, 1.0, 0.0, 2.0, 4.0, 6.0]\n },\n {\n id: 'preset_indie',\n name: 'Indie',\n gains: [2.0, 3.0, 2.0, 1.0, 0.0, -1.0, -2.0, 0.0, 3.0, 4.0]\n },\n {\n id: 'preset_chill',\n name: 'Chill',\n gains: [1.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_world',\n name: 'World',\n gains: [3.0, 2.0, 0.0, -2.0, -1.0, 1.0, 3.0, 4.0, 5.0, 3.0]\n },\n {\n id: 'preset_alternative',\n name: 'Alternative',\n gains: [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, 1.0, 3.0, 4.0, 3.0]\n },\n {\n id: 'preset_ambient',\n name: 'Ambient',\n gains: [0.0, -1.0, -2.0, -3.0, -2.0, 0.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_mellow',\n name: 'Mellow',\n gains: [1.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 1.0]\n },\n {\n id: 'preset_grunge',\n name: 'Grunge',\n gains: [5.0, 4.0, 3.0, 2.0, 1.0, 0.0, 0.0, 2.0, 4.0, 5.0]\n },\n {\n id: 'preset_soul',\n name: 'Soul',\n gains: [3.0, 3.0, 2.0, 1.0, 0.0, -1.0, 0.0, 2.0, 3.0, 3.0]\n },\n {\n id: 'preset_folk',\n name: 'Folk',\n gains: [2.0, 1.0, 0.0, -1.0, -2.0, -1.0, 1.0, 2.0, 3.0, 2.0]\n },\n {\n id: 'preset_trap',\n name: 'Trap',\n gains: [7.0, 6.0, 3.0, 1.0, -2.0, -1.0, 1.0, 3.0, 6.0, 7.0]\n },\n {\n id: 'preset_dubstep',\n name: 'Dubstep',\n gains: [6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 1.0, 3.0, 5.0, 6.0]\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});\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://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js'\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 { ERROR_MSG_MAP } from 'constants/common';\nimport { AudioEvents, 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\nexport {\n getReadableErrorMessage,\n isValidArray,\n isValidFunction,\n isValidObject,\n isValidWindow,\n loadScript,\n metaDataCreator\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 constructor() {\n if (Equalizer._instance) {\n console.warn(\n 'Instantiation failed: cannot create multiple instance of Equalizer returning existing instance'\n );\n return Equalizer._instance;\n }\n\n if (this.audioCtx === undefined && typeof AudioContext !== 'undefined') {\n if (typeof AudioContext !== 'undefined') {\n this.audioCtx = new AudioContext();\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n } else if (typeof (window as any).webkitAudioContext !== 'undefined') {\n this.audioCtx = new (window as any).webkitAudioContext();\n this.audioCtxStatus = 'ACTIVE';\n this.init();\n } else {\n throw new Error('Web Audio API is not supported in this browser.');\n }\n } else {\n console.log('Equalizer not initialized, AudioContext failed');\n this.audioCtxStatus = 'FAILED';\n }\n\n // context state at this time is `undefined` in iOS8 Safari\n if (\n this.audioCtxStatus === 'ACTIVE' &&\n this.audioCtx.state === 'suspended'\n ) {\n var 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 Equalizer._instance = this;\n }\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; //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 this.audioCtxStatus = 'FAILED';\n }\n }\n\n setPreset(id: keyof Preset) {\n const preset = presets.find((el) => el.id === id);\n console.log({ preset });\n if (\n !this.eqFilterBands ||\n this.eqFilterBands.length !== preset?.gains.length\n ) {\n console.error('Invalid data provided.');\n return;\n }\n for (let i = 0; i < this.eqFilterBands.length; i++) {\n this.eqFilterBands[i].gain.value = preset?.gains[i];\n }\n }\n\n static getPresets() {\n return presets;\n }\n\n status() {\n if (this.audioCtx.state === 'suspended') {\n this.audioCtx.resume();\n }\n return this.audioCtxStatus;\n }\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 }\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 getReadableErrorMessage\n} from 'helpers/common';\nimport ChangeNotifier from 'helpers/notifier';\nimport { AudioState, EventListenerCallbackMap } from 'types';\nimport { ERROR_EVENTS } from './errorEvents';\nconst notifier = ChangeNotifier;\n\nconst BASE_EVENT_CALLBACK_MAP: EventListenerCallbackMap = {\n LOADED_META_DATA: (e: Event, audioInstance: HTMLAudioElement) => {\n console.log('STATUS', e.type);\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n duration: audioInstance?.duration,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_state_${e.type}`\n );\n },\n\n CAN_PLAY: (e: Event) => {\n console.log('STATUS', e.type);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.BUFFERING,\n error: { code: null, message: '', readable: '' }\n },\n `audiox_baseEvents_state_${e.type}`\n );\n },\n\n CAN_PLAY_THROUGH: (e: Event) => {\n console.log('STATUS', e.type);\n\n notifier.notify(\n 'AUDIO_STATE',\n {\n playbackState: PLAYBACK_STATE.READY,\n error: { code: null, message: '', readable: '' }\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 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 = ChangeNotifier.getLatestState(\n 'AUDIO_X_STATE'\n ) as AudioState;\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 },\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\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 if ('mediaSession' in navigator) {\n navigator.mediaSession.setActionHandler('play', () => {\n const audioInstance = AudioX.getAudioInstance();\n\n audioInstance.play();\n });\n navigator.mediaSession.setActionHandler('pause', () => {\n const audioInstance = AudioX.getAudioInstance();\n audioInstance.pause();\n });\n }\n};\n\nexport const updatePositionState = () => {\n ChangeNotifier.listen('AUDIO_X_STATE', (data: AudioState) => {\n if (data?.duration && data?.playbackRate && data?.progress) {\n navigator.mediaSession.setPositionState({\n duration: data.duration,\n playbackRate: data.playbackRate,\n position: data.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 (data: AudioState) => {\n ChangeNotifier.notify('AUDIO_X_STATE', { ...AUDIO_STATE, ...data });\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 { calculateActualPlayedLength } 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 { AudioInit, MediaTrack, PlaybackRate } 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 eqStatus: EqualizerStatus = 'IDEAL';\n private isEqEnabled: boolean = false;\n private eqInstance: Equalizer;\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 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(mediaTrack: MediaTrack) {\n try {\n if (mediaTrack) {\n this.addMedia(mediaTrack).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 }\n } catch (error) {\n console.log('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 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 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/src/types/audio.types.ts b/src/types/audio.types.ts index 3069e7c..69cdf67 100644 --- a/src/types/audio.types.ts +++ b/src/types/audio.types.ts @@ -19,6 +19,7 @@ export interface MediaTrack { title: string; source: string; artwork: MediaArtwork[] | null; + id?: string; duration?: number; genre?: string; album?: string;