mirror of
https://github.com/zoriya/v10.git
synced 2026-08-09 15:46:42 +00:00
Make a complete VOD reach native `ended` (and loop) reliably even when audio and video tracks end a few ms apart, via two narrow changes in the behaviors that already own end-of-playback: 1. `end-of-stream` reactor — add `LAST_SEGMENT_REACHED_SLACK` (0.5s) to the "playhead reached the last segment" gate. A tiny final segment (e.g. Apple's ~44ms last segment) starts at the buffered end and Chrome freezes the playhead ~50-70ms short of it, so a strict `currentTime >= lastSegStart` never opens -> `endOfStream()` never fires -> MediaSource stays `'open'` -> frozen. The slack fires EOS just before the freeze. 2. `recover-end-stall` (new DOM behavior) — on `waiting`, if the MediaSource is `'ended'`, duration is finite, and the playhead is within `endStallNudgeWindow` (0.2s, config) of the reachable buffered end, nudge `currentTime = duration` to force native `ended`. Event-driven, no poll (`waiting` fires at ~0ms). Inert for live and clean-ending streams. Composed in both engines. ADR: internal/decisions/end-of-stream-av-skew-recovery.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>