Skip to content

Commit 68bcfbe

Browse files
committed
Fix clocks rendering at 00:00 when playback had not begun.
1 parent 42fe796 commit 68bcfbe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/audio/PlaybackQueue.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ export class PlaybackQueue {
8989
private onPlaybackStateChange(playback: Playback, mxEvent: MatrixEvent, newState: PlaybackState): void {
9090
// Remember where the user got to in playback
9191
const wasLastPlaying = this.currentPlaybackId === mxEvent.getId();
92-
if (newState === PlaybackState.Stopped && this.clockStates.has(mxEvent.getId()!) && !wasLastPlaying) {
93-
// noinspection JSIgnoredPromiseFromCall
94-
playback.skipTo(this.clockStates.get(mxEvent.getId()!)!);
92+
const currentClockState = this.clockStates.get(mxEvent.getId()!);
93+
if (newState === PlaybackState.Stopped && currentClockState !== undefined && !wasLastPlaying) {
94+
if (currentClockState > 0) {
95+
// skipTo will pause playback, which causes the clock to render the current
96+
// playback seconds. If the clock state is 0, then we can just ignore
97+
// skipping entirely.
98+
// noinspection JSIgnoredPromiseFromCall
99+
playback.skipTo(currentClockState);
100+
}
95101
} else if (newState === PlaybackState.Stopped) {
96102
// Remove the now-useless clock for some space savings
97103
this.clockStates.delete(mxEvent.getId()!);

0 commit comments

Comments
 (0)