Quale video sia fermo dipende dall'ora: i passi lo cercano in tutta la libreria e dicono se manca. La dimostrazione chiude la ricerca prima dell'archivio. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.7 KiB
JavaScript
28 lines
1.7 KiB
JavaScript
// The viewer of the still video of @marta.demo (spec §4.6, §4.10, tappa E4; composed from mockup 02): the chip «Video
|
|
// fermo», the row «Un'immagine sola per tutto il video: basta un fotogramma · fotogramma a …» and «Salva il fotogramma»
|
|
// among the actions. The player is stopped past the fade from black.
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
const until = async (test, tries = 100) => { for (let i = 0; i < tries && !test(); i++) await sleep(100); return test(); };
|
|
const json = (path) => fetch(path, { headers: { Accept: 'application/json' } }).then((r) => r.json());
|
|
|
|
const marta = (await json('/api/accounts')).accounts.find((a) => a.username === 'marta.demo');
|
|
const still = (await json(`/api/library?kind=stillvideos&accounts=${marta.id}&limit=1`)).tiles[0];
|
|
if (!still) throw new Error('La dimostrazione non ha un video fermo di @marta.demo.');
|
|
const tile = () => document.querySelector(`.mosaico .tess[data-entry="${still.id}"]`);
|
|
await until(tile);
|
|
tile().click();
|
|
const entry = await json(`/api/entries/${still.id}`);
|
|
await until(() => document.querySelector('.vis video, .vis img'));
|
|
for (let i = entry.media.findIndex((m) => m.still?.outcome === 'still'); i > 0; i--) {
|
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }));
|
|
await sleep(300);
|
|
}
|
|
await until(() => document.querySelector('.vis .azione-salva-fotogramma') && document.querySelector('.vis video')?.readyState >= 2);
|
|
const video = document.querySelector('.vis video');
|
|
video.pause();
|
|
video.currentTime = 1;
|
|
await until(() => !video.seeking, 50);
|
|
await sleep(600);
|
|
document.activeElement?.blur();
|
|
return [document.querySelector('.vis .etichette')?.textContent, document.querySelector('.vis .riga-fermo')?.textContent];
|