@@ -256,6 +256,9 @@ export const MEDIA_HARD_SYNC_SECONDS = 0.5;
256256/** Drift a playing audio element may carry before sync pulls it back onto the playhead. */
257257export const MEDIA_SYNC_TOLERANCE_SECONDS = 0.04 ;
258258
259+ // Chromium refuses a slower playbackRate (NotSupportedError).
260+ const MIN_NATIVE_PLAYBACK_RATE = 1 / 16 ;
261+
259262// A playing video is steered back by rate, not seeked (a seek resets its decoder).
260263// Its rate is written only when steering starts or stops: every write costs a frame.
261264const VIDEO_STEER = 0.03 ;
@@ -473,6 +476,8 @@ export function syncRuntimeMedia(params: {
473476 if ( el . preload !== "auto" ) el . preload = "auto" ;
474477 // Per-element rate × global transport rate
475478 const baseRate = rateAt ( clipRate , params . timeSeconds - clip . start ) * params . playbackRate ;
479+ // Too slow for the browser to play: kept paused and stepped onto the playhead by seeks.
480+ const playing = params . playing && baseRate >= MIN_NATIVE_PLAYBACK_RATE ;
476481 // Drift correction — three tiers:
477482 //
478483 // 1. Hard sync (0.5s): first tick, timeline jumps (scrub), catastrophic
@@ -518,12 +523,14 @@ export function syncRuntimeMedia(params: {
518523 // seek→freeze→drift→seek stutter. So a playing video skips strict and force sync; only hard
519524 // sync (>0.5s) warrants the decoder-reset cost. A paused transport pauses this video below,
520525 // so a seek that pauses mid-playback still lands it.
521- const isPlayingVideo = el . tagName === "VIDEO" && ! el . paused && params . playing ;
526+ const isPlayingVideo = el . tagName === "VIDEO" && ! el . paused && playing ;
522527 // Only apply strict sync when offset has stabilized (not growing).
523528 // During initial buffering, offset grows ~16ms/tick as the timeline
524529 // advances while media stays at 0. Accumulated drift from pause/play
525530 // toggling shows up as a stable, non-zero offset (delta near 0).
526- const offsetStabilized = prevOffset !== undefined && Math . abs ( offset - prevOffset ) < 0.004 ;
531+ const heldBelowFloor = params . playing && ! playing ;
532+ const offsetStabilized =
533+ heldBelowFloor || ( prevOffset !== undefined && Math . abs ( offset - prevOffset ) < 0.004 ) ;
527534 let strictSync = false ;
528535 if (
529536 ! isPlayingVideo &&
@@ -545,8 +552,10 @@ export function syncRuntimeMedia(params: {
545552 try {
546553 // A hard sync lands the video on the playhead, so its pre-seek offset says nothing.
547554 if ( ! isPlayingVideo || hardSync ) videoSteering . delete ( el ) ;
548- const rate =
549- isPlayingVideo && ! hardSync ? steeredVideoRate ( el , offset , baseRate ) : baseRate ;
555+ const rate = Math . max (
556+ MIN_NATIVE_PLAYBACK_RATE ,
557+ isPlayingVideo && ! hardSync ? steeredVideoRate ( el , offset , baseRate ) : baseRate ,
558+ ) ;
550559 // Some engines read a rate back at lower precision; an equal-enough rate is not rewritten.
551560 if ( Math . abs ( el . playbackRate - rate ) > 1e-6 ) el . playbackRate = rate ;
552561 } catch ( err ) {
@@ -584,12 +593,12 @@ export function syncRuntimeMedia(params: {
584593 holdSeekBarrierUntilVideoLands ( el ) ;
585594 }
586595 playRequested . delete ( el ) ;
587- } else if ( ! params . playing ) {
596+ } else if ( ! playing ) {
588597 holdSeekBarrierUntilVideoLands ( el ) ;
589598 }
590599 if ( isHeldVideoTail ) {
591600 if ( ! el . paused ) el . pause ( ) ;
592- } else if ( params . playing && el . paused && ! playRequested . has ( el ) && ! isUnplayable ( el ) ) {
601+ } else if ( playing && el . paused && ! playRequested . has ( el ) && ! isUnplayable ( el ) ) {
593602 // `HTMLMediaElement.play()` is spec'd to queue playback and resolve
594603 // once enough data is buffered, so we can unconditionally call it —
595604 // no need to gate on `readyState` or defer to a `canplay` listener.
@@ -617,7 +626,7 @@ export function syncRuntimeMedia(params: {
617626 : "" ;
618627 if ( name === "NotAllowedError" ) params . onAutoplayBlocked ?.( ) ;
619628 } ) ;
620- } else if ( ! params . playing && ! el . paused ) {
629+ } else if ( ! playing && ! el . paused ) {
621630 el . pause ( ) ;
622631 }
623632 continue ;
0 commit comments