1313 100% { transform : scale (0.95 ); box-shadow : 0 0 0 0 rgba (59 , 130 , 246 , 0 ); }
1414 }
1515 .playing-indicator { animation : pulse-ring 2s ease-in-out infinite; }
16-
16+
1717 @keyframes soundwave {
1818 0% , 100% { height : 5px ; }
1919 50% { height : 20px ; }
2929 .soundwave-bar : nth-child (3 ) { animation : soundwave 0.5s ease-in-out 0.2s infinite; }
3030 .soundwave-bar : nth-child (4 ) { animation : soundwave 0.5s ease-in-out 0.3s infinite; }
3131 .soundwave-bar : nth-child (5 ) { animation : soundwave 0.5s ease-in-out 0.4s infinite; }
32-
32+
3333 .track-item { transition : all 0.3s ease; }
3434 .track-item : hover { transform : translateX (5px ); }
35-
35+
3636 .progress-bar { transition : width 0.1s linear; }
3737 </ style >
3838</ head >
@@ -118,42 +118,41 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
118118 </ h3 >
119119 < div class ="grid grid-cols-2 gap-3 text-sm ">
120120 < div >
121- < span class ="text-gray-400 "> WebAudio Status :</ span >
122- < span id ="webAudioStatus " class ="ml-2 font-mono "> Checking...</ span >
121+ < span class ="text-gray-400 "> Current Track WebAudio :</ span >
122+ < span id ="currentWebAudioStatus " class ="ml-2 font-mono text-xs "> Checking...</ span >
123123 </ div >
124124 < div >
125- < span class ="text-gray-400 "> Buffer Status :</ span >
126- < span id ="bufferStatus " class ="ml-2 font-mono "> N/A</ span >
125+ < span class ="text-gray-400 "> Next Track WebAudio :</ span >
126+ < span id ="nextWebAudioStatus " class ="ml-2 font-mono text-xs "> N/A</ span >
127127 </ div >
128128 < div >
129129 < span class ="text-gray-400 "> Current Track:</ span >
130130 < span id ="currentTrackIdx " class ="ml-2 font-mono "> N/A</ span >
131131 </ div >
132132 < div >
133- < span class ="text-gray-400 "> Next Track Loaded :</ span >
134- < span id ="nextTrackLoaded " class ="ml-2 font-mono "> N/A</ span >
133+ < span class ="text-gray-400 "> Playback Mode :</ span >
134+ < span id ="playbackMode " class ="ml-2 font-mono "> N/A</ span >
135135 </ div >
136136 </ div >
137137 </ div >
138138 </ div >
139139
140140 < script type ="module ">
141141 import Gapless from './dist/index.mjs' ;
142+
142143 // Track metadata
143144 const trackMetadata = [
144- { title : "Electric Dreams" , artist : "JRAD" , album : "Live 2017-03-17" } ,
145- { title : "Cosmic Highway" , artist : "JRAD" , album : "Live 2017-03-17" } ,
146- { title : "Starlight Serenade" , artist : "JRAD" , album : "Live 2017-03-17" } ,
147- { title : "Neon Nights" , artist : "JRAD" , album : "Live 2017-03-17" }
145+ { title : "Scarlet Begonias" , artist : "Grateful Dead" , album : "Cornell 5/8/77" } ,
146+ { title : "Fire on the Mountain" , artist : "Grateful Dead" , album : "Cornell 5/8/77" } ,
147+ { title : "Estimated Prophet" , artist : "Grateful Dead" , album : "Cornell 5/8/77" }
148148 ] ;
149149
150150 // Initialize player
151151 window . player = new Gapless ( {
152152 tracks : [
153- "https://archive.org/download/jrad2017-03-17.cmc621.cmc64.sbd.matrix.flac16/jrad2017-03-17.cmc621.cmc64.sbd.matrix-s2t03.mp3" ,
154- "https://archive.org/download/jrad2017-03-17.cmc621.cmc64.sbd.matrix.flac16/jrad2017-03-17.cmc621.cmc64.sbd.matrix-s2t04.mp3" ,
155- "https://archive.org/download/jrad2017-03-17.cmc621.cmc64.sbd.matrix.flac16/jrad2017-03-17.cmc621.cmc64.sbd.matrix-s2t05.mp3" ,
156- "https://archive.org/download/jrad2017-03-17.cmc621.cmc64.sbd.matrix.flac16/jrad2017-03-17.cmc621.cmc64.sbd.matrix-s2t06.mp3"
153+ "https://archive.org/download/gd1977-05-08.148737.SBD.Betty.Anon.Noel.t-flac2448/gd77-05-08.s2t02.mp3" ,
154+ "https://archive.org/download/gd1977-05-08.148737.SBD.Betty.Anon.Noel.t-flac2448/gd77-05-08.s2t03.mp3" ,
155+ "https://archive.org/download/gd1977-05-08.148737.SBD.Betty.Anon.Noel.t-flac2448/gd77-05-08.s2t04.mp3"
157156 ] ,
158157 onProgress : updateProgress ,
159158 onPlayNextTrack : updateTrackDisplay ,
@@ -222,9 +221,10 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
222221 if ( player . currentTrack && player . currentTrack . duration ) {
223222 const rect = progressContainer . getBoundingClientRect ( ) ;
224223 const x = e . clientX - rect . left ;
225- const percentage = x / rect . width ;
224+ const percentage = Math . max ( 0 , Math . min ( 1 , x / rect . width ) ) ;
226225 const newTime = percentage * player . currentTrack . duration ;
227226 player . currentTrack . seek ( newTime ) ;
227+ updateProgress ( player . currentTrack ) ; // Force immediate update
228228 }
229229 } ) ;
230230
@@ -260,24 +260,38 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
260260 progressBar . style . width = `${ percentage } %` ;
261261 }
262262
263- // Update technical status
264- const webAudioEnabled = track . isUsingWebAudio || ( track . webAudioLoadingState === 'LOADED' ) ;
265- document . getElementById ( 'webAudioStatus' ) . textContent = webAudioEnabled ? 'Enabled' : 'Disabled' ;
266- document . getElementById ( 'webAudioStatus' ) . className = webAudioEnabled ? 'ml-2 font-mono text-green-400' : 'ml-2 font-mono text-yellow-400' ;
263+ // Update technical status for current track
264+ const currentLoadingState = track . webAudioLoadingState || 'NONE' ;
265+ const currentStatusText = `${ currentLoadingState } ${ track . isUsingWebAudio ? ' (Active)' : '' } ` ;
266+ document . getElementById ( 'currentWebAudioStatus' ) . textContent = currentStatusText ;
267+ document . getElementById ( 'currentWebAudioStatus' ) . className =
268+ track . isUsingWebAudio ? 'ml-2 font-mono text-xs text-green-400' :
269+ currentLoadingState === 'LOADED' ? 'ml-2 font-mono text-xs text-blue-400' :
270+ currentLoadingState === 'LOADING' ? 'ml-2 font-mono text-xs text-yellow-400' :
271+ 'ml-2 font-mono text-xs text-gray-400' ;
267272
268- // Log WebAudio state for debugging
269- if ( track . webAudioLoadingState ) {
270- console . log ( 'WebAudio Loading State:' , track . webAudioLoadingState ) ;
273+ // Update next track WebAudio status
274+ if ( player . nextTrack ) {
275+ const nextLoadingState = player . nextTrack . webAudioLoadingState || 'NONE' ;
276+ document . getElementById ( 'nextWebAudioStatus' ) . textContent = nextLoadingState ;
277+ document . getElementById ( 'nextWebAudioStatus' ) . className =
278+ nextLoadingState === 'LOADED' ? 'ml-2 font-mono text-xs text-green-400' :
279+ nextLoadingState === 'LOADING' ? 'ml-2 font-mono text-xs text-yellow-400' :
280+ 'ml-2 font-mono text-xs text-gray-400' ;
281+ } else {
282+ document . getElementById ( 'nextWebAudioStatus' ) . textContent = 'N/A' ;
283+ document . getElementById ( 'nextWebAudioStatus' ) . className = 'ml-2 font-mono text-xs text-gray-400' ;
271284 }
272-
273- document . getElementById ( 'bufferStatus' ) . textContent = track . isLoaded ? 'Ready' : 'Loading...' ;
274- document . getElementById ( 'bufferStatus' ) . className = track . isLoaded ? 'ml-2 font-mono text-green-400' : 'ml-2 font-mono text-yellow-400' ;
275-
285+
276286 document . getElementById ( 'currentTrackIdx' ) . textContent = `${ track . idx + 1 } / ${ player . tracks . length } ` ;
277-
278- const nextTrackStatus = player . nextTrack ?. isLoaded ? 'Yes' : 'No' ;
279- document . getElementById ( 'nextTrackLoaded' ) . textContent = nextTrackStatus ;
280- document . getElementById ( 'nextTrackLoaded' ) . className = player . nextTrack ?. isLoaded ? 'ml-2 font-mono text-green-400' : 'ml-2 font-mono text-yellow-400' ;
287+ document . getElementById ( 'playbackMode' ) . textContent = track . isUsingWebAudio ? 'WebAudio' : 'HTML5' ;
288+ document . getElementById ( 'playbackMode' ) . className = track . isUsingWebAudio ? 'ml-2 font-mono text-green-400' : 'ml-2 font-mono text-yellow-400' ;
289+
290+ // Debug logging
291+ console . log ( `Track ${ track . idx + 1 } - WebAudio: ${ currentLoadingState } , Using: ${ track . isUsingWebAudio } ` ) ;
292+ if ( player . nextTrack ) {
293+ console . log ( `Next Track ${ player . nextTrack . idx + 1 } - WebAudio: ${ player . nextTrack . webAudioLoadingState || 'NONE' } ` ) ;
294+ }
281295 }
282296
283297 function updateTrackDisplay ( track ) {
@@ -289,7 +303,7 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
289303
290304 // Update playlist highlighting
291305 renderPlaylist ( ) ;
292-
306+
293307 // Update play/pause button
294308 updatePlayPauseButton ( ! track . isPaused ) ;
295309 }
@@ -299,12 +313,12 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
299313 player . tracks . forEach ( ( track , idx ) => {
300314 const metadata = track . metadata || { } ;
301315 const isActive = player . currentTrack ?. idx === idx ;
302-
316+
303317 const trackEl = document . createElement ( 'div' ) ;
304318 trackEl . className = `track-item p-2 rounded-lg cursor-pointer flex items-center space-x-3 ${
305319 isActive ? 'bg-blue-600 bg-opacity-20 border border-blue-500' : 'bg-gray-700 hover:bg-gray-600'
306320 } `;
307-
321+
308322 trackEl . innerHTML = `
309323 <div class="text-2xl w-8 text-center">
310324 ${ isActive && ! player . currentTrack . isPaused ? '<i class="fas fa-volume-up text-blue-400"></i>' : `<span class="text-gray-500">${ idx + 1 } </span>` }
@@ -317,11 +331,11 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
317331 ${ track . duration ? formatTime ( track . duration ) : '--:--' }
318332 </div>
319333 ` ;
320-
334+
321335 trackEl . addEventListener ( 'click' , ( ) => {
322336 player . gotoTrack ( idx , true ) ;
323337 } ) ;
324-
338+
325339 playlist . appendChild ( trackEl ) ;
326340 } ) ;
327341 }
@@ -335,6 +349,7 @@ <h3 class="text-lg font-semibold mb-3 flex items-center">
335349
336350 // Debug WebAudio status
337351 console . log ( 'Player initialized. WebAudio disabled?' , player . webAudioIsDisabled ) ;
352+ console . log ( 'AudioContext available?' , window . AudioContext || window . webkitAudioContext ) ;
338353
339354 // Also update display for initial track
340355 if ( player . currentTrack ) {
0 commit comments