refactor(audio): Phase 2 — simplify AudioService to thin WaveSurfer wrapper
audioService.ts rewritten from ~850 lines to ~130: - Remove custom logging system with throttle that suppressed ERROR logs - Remove AudioContext management entirely (initializeAudioContext, handleAudioContextResume, setupAudioContext, shareAudioContextWithWaveSurfer, ensureAudioContext). WaveSurfer v7 owns its AudioContext; fighting it caused prod/dev divergence and silent failures. - Replace 5-state InitializationState machine + split promise with a single isReady boolean set in the 'ready' event handler - Remove retry/debounce logic from play() — these are UI concerns - Remove dead methods: canPlayAudio (always returned true), getWaveSurferVersion, updatePlayerState, getAudioContextState, setLogLevel - Extract destroyWaveSurfer() helper so cleanup is one place - MiniPlayer now passes songId/bandId to play() (was calling with no args) - SongPage spacebar handler simplified: just checks isReady from hook - SongPage no longer imports audioService directly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -94,7 +94,9 @@ export function MiniPlayer() {
|
||||
if (isPlaying) {
|
||||
audioService.pause();
|
||||
} else {
|
||||
audioService.play();
|
||||
audioService.play(currentSongId, currentBandId).catch(err => {
|
||||
console.warn('MiniPlayer playback failed:', err);
|
||||
});
|
||||
}
|
||||
}}
|
||||
style={
|
||||
|
||||
Reference in New Issue
Block a user