mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(runtime): schedule future WebAudio clips with delay instead of playing immediately
Clips whose compositionStart is ahead of the current timeline position were starting immediately because sourceNode.start() always received when=0. Use the AudioContext scheduling API to defer future clips: sourceNode.start(ctx.currentTime + delay, mediaStart). Closes #674 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
8de7ad7f61
commit
38522f996e
@@ -91,10 +91,16 @@ export class WebAudioTransport {
|
||||
sourceNode.connect(gainNode);
|
||||
gainNode.connect(this._masterGain);
|
||||
|
||||
const offset = Math.max(0, compositionTime - compositionStart + mediaStart);
|
||||
const elapsed = compositionTime - compositionStart;
|
||||
const scheduledAt = this._ctx.currentTime;
|
||||
this._scheduleOffset = scheduledAt - compositionTime;
|
||||
sourceNode.start(0, offset);
|
||||
|
||||
if (elapsed >= 0) {
|
||||
sourceNode.start(0, elapsed + mediaStart);
|
||||
} else {
|
||||
const delay = -elapsed;
|
||||
sourceNode.start(scheduledAt + delay, mediaStart);
|
||||
}
|
||||
|
||||
const priorMuted = el.muted;
|
||||
el.muted = true;
|
||||
|
||||
Reference in New Issue
Block a user