Fix duplicate movie audio during scene transitions
CI / frontend (push) Failing after 21s
CI / backend (push) Failing after 42s

This commit is contained in:
mrleo1nid committed 2026-10-27 16:25:27 +03:00
1 parent 4dc660f786
commit b522d257c5
5 files changed
+119 -11

No files matched your search

+7 -4
View File
@@ -8,7 +8,7 @@ import type { AudioSystem } from "./audio";
import { isNativeAction } from "./musicroom";
import { galleryClass } from "./gallery";
import { parseExpression } from "./pyparse";
import { movieDisplayable } from "./movie";
import { disposeMovies, movieDisplayable } from "./movie";
import { RenderHost, isDisplayableInstance } from "./render";
import { Matrix4, blendMode } from "./rendertransform";
import { strftime } from "./pymodules";
@@ -358,7 +358,10 @@ export class ScreenManager {
inst.runners.forEach((r) => r.stop());
inst.runners = [];
inst.el.remove();
for (const id of [...this.movies.keys()]) if (id.startsWith(`${inst.name}|`)) this.movies.delete(id);
for (const [id, element] of [...this.movies]) if (id.startsWith(`${inst.name}|`)) {
disposeMovies(element);
this.movies.delete(id);
}
if (forget) this.shown.delete(inst.name);
}
@@ -462,13 +465,13 @@ export class ScreenManager {
this.nodes(inst.def.body, ctx, children);
inst.el.replaceChildren(...children);
});
// a video taken out of the page pauses by itself; carry on, and forget the ones no screen shows now
// Preserve cached players on redraw; explicitly stop those no screen shows.
for (const [id, element] of [...this.movies]) {
if (this.moviesSeen.has(id)) {
const video = element instanceof HTMLVideoElement ? element : element.querySelector("video");
if (video && video.paused && !video.ended) void video.play().catch(() => {});
} else if (id.startsWith(`${inst.name}|`)) {
if (element instanceof HTMLVideoElement) element.pause();
disposeMovies(element);
this.movies.delete(id);
}
}