Silence a composition video as soon as its item ends
A video in a composition plays on a driven player that the item tells where to stand every frame. When the item ended, its object was gone and stopped asking, but the player ran on with its sound until it was let go for being unused. That took 2 to 4 seconds, and in a pause it never happened at all. The same held for the composition preview. - A driven player nobody asked for in 100 ms is now paused and muted. When its wearer comes back it carries on where it should be, as before. It is still let go after 2 to 4 seconds. - A player still without its first picture keeps playing, without sound, because it only gets that picture by playing. - Leaving the animation or composition tab now silences their video preview at once instead of after 2 to 4 seconds. - Free videos (Video clock free) keep the old behaviour. A sprite destroyed by a behavior is still heard for 2 to 4 seconds. Tests: - Unit video-library: 10 green (1 new). Without the new timer the new test is red. - e2e 68: ALL PASSED, 11 checks (68g new). An item of 0.5 s with a 2 s video plays audibly while it is there, and the player is paused and muted in every frame from about 200 ms after it ends. - Gate on melektaus-atx: green, 305 files, 4737 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
126a5a3a62
commit
65d7bf6a1f
4 files changed
+111
-2
No files matched your search
@@ -9,7 +9,8 @@ import { MAKE_OBJECT } from './lib/scaffold.mjs';
|
||||
* clip moves the item it overlaps, and `On composition finished` hears the end, by which time no
|
||||
* item is left. Nothing of the run stays in the scene. An item's video is waited for: the clock
|
||||
* stands until the Game tab has its first picture, for a clip that starts later the picture there,
|
||||
* and then the video plays at once. A recording that runs meanwhile takes no frame.
|
||||
* and then the video plays at once. A recording that runs meanwhile takes no frame. When the item
|
||||
* ends, its video stops and goes quiet with it.
|
||||
*
|
||||
* Everything it adds carries a `cp68` id and goes again at the end.
|
||||
*/
|
||||
@@ -327,6 +328,46 @@ export async function composition(t) {
|
||||
);
|
||||
const madeId = (await json('__gm.recording()')).uploads.at(-1).assetId ?? '';
|
||||
|
||||
// 68g. The item ends after half a second, its video of two seconds with sound in the middle: the
|
||||
// item's player stops and goes quiet at once – it played on, heard, until it was let go 2-4 s
|
||||
// later.
|
||||
await mutate(`
|
||||
const p = __gm.state.project;
|
||||
p.assets.find((a) => a.id === 'cp68-director').graph = ${JSON.stringify(graph)};
|
||||
p.assets.find((a) => a.id === 'cp68-screen').props.texture = 'cp68-video';
|
||||
p.assets.find((a) => a.id === 'cp68-cut').items[0].length = 30;`);
|
||||
await play();
|
||||
const cut = JSON.parse(
|
||||
await evaluate(`new Promise((done) => {
|
||||
const rows = [];
|
||||
let gone = -1;
|
||||
const step = () => {
|
||||
const exists = (__gm.world()?.entities ?? []).some((e) => e.objectId === '${id('v')}');
|
||||
const player = __gm.gameVideo('${id('v')}');
|
||||
rows.push({ exists, paused: player?.paused ?? null, muted: player?.muted ?? null });
|
||||
if (gone < 0 && rows.some((row) => row.exists) && !exists) gone = rows.length - 1;
|
||||
if ((gone >= 0 && rows.length > gone + 30) || rows.length >= 600 || !__gm.world())
|
||||
return done(JSON.stringify({ gone, heard: rows.filter((row) => row.exists && row.paused === false && row.muted === false).length, after: rows.slice(gone + 12) }));
|
||||
requestAnimationFrame(step);
|
||||
};
|
||||
step();
|
||||
})`),
|
||||
);
|
||||
await stop();
|
||||
check(
|
||||
'the video of an item that ends stops and goes quiet with it',
|
||||
cut.gone > 0 &&
|
||||
cut.heard > 0 &&
|
||||
cut.after.length > 0 &&
|
||||
cut.after.every((row) => row.paused === true && row.muted === true),
|
||||
JSON.stringify({
|
||||
gone: cut.gone,
|
||||
heard: cut.heard,
|
||||
after: cut.after.slice(0, 3),
|
||||
last: cut.after.at(-1),
|
||||
}),
|
||||
);
|
||||
|
||||
await mutate(`
|
||||
const p = __gm.state.project;
|
||||
p.assets = p.assets.filter((a) => !a.id.startsWith('cp68-') && a.id !== ${JSON.stringify(madeId)});
|
||||
|
||||
Reference in new issue
Block a user