diff --git a/lib/audio/player.ts b/lib/audio/player.ts index 45787b9..65f4e98 100644 --- a/lib/audio/player.ts +++ b/lib/audio/player.ts @@ -40,6 +40,9 @@ export class AudioPlayer { // Resume audio context if needed await resumeAudioContext(); + // Calculate start offset BEFORE stopping (since stop() resets pauseTime) + const offset = this.isPaused ? this.pauseTime : startOffset; + // Stop any existing playback this.stop(); @@ -48,8 +51,7 @@ export class AudioPlayer { this.sourceNode.buffer = this.audioBuffer; this.sourceNode.connect(this.gainNode); - // Calculate start offset - const offset = this.isPaused ? this.pauseTime : startOffset; + // Set start time this.startTime = this.audioContext.currentTime - offset; // Start playback