fix(venue-crowd): bail loop-fade completion when a stinger preempted the layer

Codex preflight round 6: the loop crossfade's completion callback could
still run between a stinger's start and its canplaythrough, promoting the
stinger's layer to active and pausing the real loop — it now bails when
the fading loop was preempted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
byrongamatos
2026-07-12 01:35:17 +02:00
co-authored by Claude Fable 5
parent 9178959dbd
commit 286a24214f
+6 -1
View File
@@ -240,7 +240,12 @@
if (!ok || !_venueActive) return;
_fadingLoop = state;
fadeMixTo(layer === 1 ? 1 : 0, fadeMs, () => {
if (_fadingLoop === state) _fadingLoop = null;
// Preempted mid-fade (stinger claimed this layer while we
// were still ramping): the layer no longer holds this loop —
// promoting it would pause the real loop and hand fade-back
// the wrong target.
if (_fadingLoop !== state) return;
_fadingLoop = null;
const old = _videos[_activeLayer];
_activeLayer = layer;
if (old && !old.paused) old.pause();