Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ export class WaveformPlayer {
this.setLoading(true);
this.progress = 0;
this.hasError = false;
this.container.classList.remove('waveform-is-placeholder');

// In external mode we don't own an <audio> element — skip
// src assignment + metadata-wait, but still generate the
Expand Down Expand Up @@ -1202,6 +1203,7 @@ export class WaveformPlayer {
} catch (error) {
console.warn('[WaveformPlayer] Using placeholder waveform:', error);
this.waveformData = generatePlaceholderWaveform(this.options.samples);
this.container.classList.add('waveform-is-placeholder');
}
}

Expand Down
22 changes: 22 additions & 0 deletions test/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,3 +1003,25 @@ describe('speed menu a11y (#11)', () => {
expect(btn.getAttribute('aria-expanded')).toBe('true');
});
});

describe('waveform analysis fallback', () => {
it('adds the waveform-is-placeholder class on analysis failure', async () => {
const { el, player } = track(mount());
await player.loadTrack('does-not-exist.mp3', null, null, { autoplay: false });
expect(el.classList.contains('waveform-is-placeholder')).toBe(true);
});

it('removes the waveform-is-placeholder class when a new load starts', async () => {
const { el, player } = track(mount());
await player.loadTrack('does-not-exist.mp3', null, null, { autoplay: false });
expect(el.classList.contains('waveform-is-placeholder')).toBe(true);

const loadPromise = player.loadTrack('next.mp3', 'Next', 'Artist', {
waveform: [0.1, 0.5, 0.9],
autoplay: false
});
expect(el.classList.contains('waveform-is-placeholder')).toBe(false);
await loadPromise;
});
});