// A video entry in Play (playVideo.mjs): the stage's fade into it, its source second, the ducked sound. // Run with: pnpm test:scripts import assert from "node:assert/strict"; import test from "node:test"; import { videoStageAt } from "./playVideo.mjs"; const ve = { src: "media/v.mp4", from: 2, to: 6, fit: "contain", enter: { out: 0.5, in: 0.5 }, lead: 0.4, hold: 0, seconds: 4.4, bass: 6, gain: 0, noChrome: true }; // A 3 s card, then the video (4.4 s, its first 0.4 s the dissolve's black); Play cuts at the overlap's midpoint. const plan = { items: [ { id: "k01", start: 0, end: 3, from: 0, to: 2.8 }, { id: "fin", start: 2.6, end: 7, from: 2.8, to: 7 }, ], }; const entries = new Map([["k01", {}], ["fin", { videoEntry: ve }]]); test("the item before a video darkens over its last enter.out seconds, its sound with it; untouched before", () => { assert.equal(videoStageAt(plan, entries, 1), null); assert.equal(videoStageAt(plan, entries, 2.3), null); const mid = videoStageAt(plan, entries, 2.55); assert.equal(mid?.dark, 0.5); assert.equal(mid?.duck, 0.5); assert.equal(mid?.video, null); }); test("on the video: black through its lead, then up over enter.in, on its own source clock; the clips' sound off", () => { const black = videoStageAt(plan, entries, 2.9); assert.equal(black?.opacity, 0); assert.equal(black?.src, 2); assert.equal(black?.duck, 0); assert.equal(black?.playing, false); const up = videoStageAt(plan, entries, 3.25); assert.equal(up?.opacity, 0.5); assert.equal(up?.src, 2.25); assert.equal(up?.playing, true); const on = videoStageAt(plan, entries, 5); assert.equal(on?.opacity, 1); assert.equal(on?.src, 4); // Its end: the last frame, held (no fade out). const end = videoStageAt(plan, entries, 7); assert.equal(end?.opacity, 1); assert.equal(end?.src, 6); assert.equal(end?.playing, false); }); test('enter "cut": no darkening before it, no fade up', () => { const cut = new Map([["k01", {}], ["fin", { videoEntry: { ...ve, enter: null, lead: 0 } }]]); assert.equal(videoStageAt(plan, cut, 2.75), null); assert.equal(videoStageAt(plan, cut, 2.9)?.opacity, 1); }); test("a cut without a video entry: nothing, anywhere", () => { const none = new Map([["k01", {}], ["fin", {}]]); for (const t of [0, 2.6, 2.9, 7]) assert.equal(videoStageAt(plan, none, t), null); });