Restore seamless native looping for zero emit loop delay

This commit is contained in:
Jage9
2026-02-28 21:24:08 -05:00
parent a57e48a265
commit b8375e82f7
2 changed files with 13 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.03.01 R331";
window.CHGRID_WEB_VERSION = "2026.03.01 R332";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -227,6 +227,7 @@ export class ItemEmitRuntime {
element.playbackRate = initialRates.playbackRate;
const initialDelaySeconds = resolveEmitInitialDelaySeconds(item);
const loopDelaySeconds = resolveEmitLoopDelaySeconds(item);
element.loop = loopDelaySeconds <= 0;
const resumeState = this.resumeStateByItemId.get(item.id);
const matchingResumeState = resumeState && resumeState.soundUrl === soundUrl ? resumeState : null;
const onEnded = () => {
@@ -387,7 +388,17 @@ export class ItemEmitRuntime {
}
const nextRates = resolveEmitRates(item);
output.initialDelaySeconds = resolveEmitInitialDelaySeconds(item);
output.loopDelaySeconds = resolveEmitLoopDelaySeconds(item);
const nextLoopDelaySeconds = resolveEmitLoopDelaySeconds(item);
output.loopDelaySeconds = nextLoopDelaySeconds;
const shouldLoop = nextLoopDelaySeconds <= 0;
if (output.element.loop !== shouldLoop) {
output.element.loop = shouldLoop;
if (shouldLoop) {
// Returning to native loop mode should clear delayed restart scheduling.
this.nextEmitStartAtMs.delete(itemId);
this.tryStartEmitPlayback(itemId, output.element);
}
}
setElementPreservesPitch(output.element, nextRates.preservePitch);
const nextPlaybackRate = nextRates.playbackRate;
if (Math.abs(output.element.playbackRate - nextPlaybackRate) > 0.001) {