Skip to content
Merged
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
10 changes: 10 additions & 0 deletions src/components/player/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ function updateProgressBar(): void {
updateTimeDisplay(audioElement.currentTime, audioElement.duration);
}

function resetProgressBar(): void {
setStyle('.bes-progbar-fill', style => (style.width = '0%'));
setStyle('.bes-slider-container .bes-progbar-thumb', style => (style.left = '0%'));
setText('.bes-time-elapsed', formatTime(0));
}

export function isPlaybackClick(target: HTMLElement | null): boolean {
if (!target) return false;
return !target.closest('.bes-track-link, .bes-track-buy-col');
Expand Down Expand Up @@ -557,6 +563,10 @@ function bindAudioEvents(audio: HTMLAudioElement, playButton: HTMLElement): void
void reportPlay();
};
audio.onpause = reflectPlaying(false);
audio.onemptied = () => {
reflectPlaying(false)();
resetProgressBar();
};
audio.onended = () => step(forward, true);
audio.ontimeupdate = updateProgressBar;
}
Expand Down
7 changes: 7 additions & 0 deletions test/playerLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,13 @@ describe('PlayerLoader - Player Interactions', () => {

expect(document.querySelector('.bes-transport-play')?.classList.contains('playing')).toBe(false);
});

it('should unmark the play button when a new source replaces the playing one', () => {
audio.dispatchEvent(new Event('play'));
audio.dispatchEvent(new Event('emptied'));

expect(document.querySelector('.bes-transport-play')?.classList.contains('playing')).toBe(false);
});
});

describe('seeking by clicking the progress bar', () => {
Expand Down
Loading