fix: seek lower-bound guard and pointer-down callback ordering
AudioPlayer.ts: route seeks below bufferStart to seekBeyondBuffer; previous missing lower-bound caused clamped playback after first seek. WaveformSeeker: fire OnSeekStart/OnSeekChange before capturePointer await to prevent fast-click race that locked _isSeeking true. Latent: WavOffsetService encodes remaining-only DataSize, overwriting JS this.duration after seek — not fixed here, scope separately.
This commit is contained in:
@@ -274,14 +274,18 @@ export class AudioPlayer {
|
||||
return { success: false, error: 'Invalid seek position' };
|
||||
}
|
||||
|
||||
// Get buffered duration (accounting for playback offset)
|
||||
const bufferedDuration = this.scheduler.getTotalDuration() + this.scheduler.getPlaybackOffset();
|
||||
const bufferStart = this.scheduler.getPlaybackOffset();
|
||||
const bufferEnd = this.scheduler.getTotalDuration() + bufferStart;
|
||||
|
||||
// Check if seeking within buffered content
|
||||
if (position <= bufferedDuration) {
|
||||
// Position must be within [bufferStart, bufferEnd] to use buffered content.
|
||||
// A lower-bound check is required: after a seek-beyond-buffer, bufferStart is
|
||||
// set to the prior seek position. Seeking to a position below bufferStart would
|
||||
// produce a negative bufferRelativePosition in seekWithinBuffer, silently
|
||||
// clamping to position 0 of the offset buffer instead of the requested time.
|
||||
if (position >= bufferStart && position <= bufferEnd) {
|
||||
return this.seekWithinBuffer(position);
|
||||
} else {
|
||||
// Seeking beyond buffer - signal C# to fetch new stream
|
||||
// Seeking outside buffered window - signal C# to fetch new stream
|
||||
return this.seekBeyondBuffer(position);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user