Skip to content

🎥 Make videos programmatically with React

Skip scheduling audio node when remaining duration is non-positive

Jonny Burgerb8b72d598d47
diff --git a/packages/media/src/media-player.ts b/packages/media/src/media-player.ts
index 4bb05c98a4..66327e162b 100644
--- a/packages/media/src/media-player.ts
+++ b/packages/media/src/media-player.ts
@@ -661,6 +661,10 @@ export class MediaPlayer {
);
} else {
const offset = -delayWithoutPlaybackRate;
+ if (maxDuration !== null && maxDuration - offset <= 0) {
+ return;
+ }
+
node.start(
this.sharedAudioContext.currentTime,
offset,
@@ -702,10 +706,11 @@ export class MediaPlayer {
this.globalPlaybackRate;
// Skip small shifts to avoid audio glitches from frame-quantized re-anchoring
- if (shift < 0.05) {
+ if (shift < 0.1) {
return;
}
+ console.log('setting new anchor', newAnchor, globalTime, shift);
this.sharedAudioSyncAnchor.value = newAnchor;
}