Merge branch 'seek-state-fix' into dev

This commit is contained in:
daniel-c-harvey
2026-06-07 17:15:45 -04:00
2 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -227,8 +227,10 @@ export class AudioPlayer {
this.isPlaying = true; this.isPlaying = true;
this.isPaused = false; this.isPaused = false;
// Resume from pause position // Resume from pause position. pausePosition is absolute track time;
this.scheduler.playFromPosition(this.pausePosition); // playFromPosition expects a buffer-relative position (excludes playbackOffset).
const bufferRelativePosition = this.pausePosition - this.scheduler.getPlaybackOffset();
this.scheduler.playFromPosition(Math.max(0, bufferRelativePosition));
this.startProgressTracking(); this.startProgressTracking();
return { success: true }; return { success: true };
@@ -235,7 +235,9 @@ export class PlaybackScheduler {
const position = this.getCurrentPosition(); const position = this.getCurrentPosition();
this.isActive_ = false; // Prevent handleSourceEnded from scheduling more this.isActive_ = false; // Prevent handleSourceEnded from scheduling more
this.stopAllSources(); this.stopAllSources();
this.playbackAnchorPosition = position; // getCurrentPosition() returns absolute time (anchor + playbackOffset); the anchor
// is buffer-relative, so strip the offset back out before storing it.
this.playbackAnchorPosition = position - this.playbackOffset;
this.playbackAnchorTime = 0; this.playbackAnchorTime = 0;
this.nextScheduleTime = 0; this.nextScheduleTime = 0;
return position; return position;