@@ -67,29 +67,35 @@ export const AudioPlayer = (props: AudioPlayerProps) => {
6767 } ;
6868
6969 useEffect ( ( ) => {
70- if ( firstSongBlobUrl )
70+ if ( firstSongBlobUrl ) {
7171 setSongSource ( ( prevState ) => ( {
7272 ...prevState , // keep all other key-value pairs
7373 [ 1 ] : firstSongBlobUrl , // update the value of the first index
7474 } ) ) ;
75+ }
76+
7577 audio . addEventListener ( "ended" , function ( ) {
7678 setCurrentTrackIndex ( ( prevCurrentTrackIndex ) => ( prevCurrentTrackIndex < songs . length - 1 ? prevCurrentTrackIndex + 1 : 0 ) ) ;
7779 } ) ;
80+
7881 audio . addEventListener ( "timeupdate" , updateProgress ) ;
82+
7983 audio . addEventListener ( "canplaythrough" , function ( ) {
8084 // Audio is ready to be played
8185 setIsLoaded ( true ) ;
8286 updateProgress ( ) ;
8387 // play the song
8488 if ( audio . currentTime == 0 ) togglePlay ( ) ;
8589 } ) ;
90+
8691 if ( songs ) {
8792 songs ?. forEach ( ( song : any ) => {
8893 if ( song . idx === 1 ) return ;
8994 fetchMarshalForSong ( song . idx ) ;
9095 } ) ;
9196 updateProgress ( ) ;
9297 }
98+
9399 return ( ) => {
94100 audio . pause ( ) ;
95101 audio . removeEventListener ( "timeupdate" , updateProgress ) ;
@@ -129,7 +135,7 @@ export const AudioPlayer = (props: AudioPlayerProps) => {
129135 }
130136 } , [ previewUrl ] ) ;
131137
132- /// format time as minutes:seconds
138+ // format time as minutes:seconds
133139 const formatTime = ( _seconds : number ) => {
134140 const minutes = Math . floor ( _seconds / 60 ) ;
135141 const remainingSeconds = Math . floor ( _seconds % 60 ) ;
@@ -140,7 +146,7 @@ export const AudioPlayer = (props: AudioPlayerProps) => {
140146 return `${ formattedMinutes } :${ formattedSeconds } ` ;
141147 } ;
142148
143- /// fetch song from Marshal
149+ // fetch song from Marshal
144150 const fetchMarshalForSong = async ( index : number ) => {
145151 if ( songSource [ index ] === undefined ) {
146152 try {
@@ -291,7 +297,7 @@ export const AudioPlayer = (props: AudioPlayerProps) => {
291297 } ;
292298
293299 return (
294- < div className = "bg-white dark: bg-black " >
300+ < div className = "bg-gradient-to-br from-[#00C79740] to-[#3D00EA20] bg-blend-multiply " >
295301 < div className = "bg-[#1b1b1b10] backdrop-contrast-[1.10]" >
296302 < div className = "p-2 md:p-12 relative overflow-hidden" >
297303 { displayPlaylist ? (
@@ -356,7 +362,6 @@ export const AudioPlayer = (props: AudioPlayerProps) => {
356362 < div className = "flex flex-col select-text" >
357363 < div >
358364 < span className = "font-sans text-lg font-medium leading-7 text-foreground" > { songs [ currentTrackIndex ] ?. title } </ span > { " " }
359- < span className = "ml-2 font-sans text-base font-medium text-muted-foreground" > { songs [ currentTrackIndex ] ?. date . split ( "T" ) [ 0 ] } </ span >
360365 </ div >
361366
362367 < span className = "font-sans text-base font-medium text-foreground/60" > { songs [ currentTrackIndex ] ?. category } </ span >
0 commit comments