openvibers/openvibe.live Commits

Recent streams carry their recording's preview, so the home's cards play it (#831)

OP OpenVibers committed 2 days ago · 5abe93f170 · 2 files, +9 −2

attachPublicVods adds vod_preview_url and vod_preview_webm_url (Media's six-second preview, public VODs only, never a
private or unlisted one's) beside the thumbnail; the home's recent-stream cards already ask previewAttrs for them
(#826). Checked in production: a channel's 12 recordings preview on hover; the home's 12 recent cards had none.

Changes

ddiff --git a/server/media-proxy/lookups.js b/server/media-proxy/lookups.js
iindex 5e3b4db9..66c29259 100644
---- a/server/media-proxy/lookups.js
++++ b/server/media-proxy/lookups.js
@@@ -106,7 +106,8 @@ async function publicVodsForStreams(streamIds, { budgetMs = 4000 } = {}) {
}
/**
-- * The recently-ended list's VOD fields (vod_id, vod_is_public, vod_thumbnail_url, vod_duration),
++ * The recently-ended list's VOD fields (vod_id, vod_is_public, vod_thumbnail_url, vod_duration, vod_preview_url,
++ * vod_preview_webm_url),
* which getRecentStreams used to join from the local table. A public VOD or nothing: never the id
* or thumbnail of a private or unlisted one.
*/
@@@ -119,6 +120,9 @@ async function attachPublicVods(streams) {
s.vod_is_public = v ? 1 : null;
s.vod_thumbnail_url = v ? media.publicUrl(v.thumbnail_url) : null;
s.vod_duration = v ? (Number(v.duration_seconds ?? v.duration) || 0) : null;
++ // The recording's six-second preview (Media's preview.make, ask 355), for the card's moving preview.
++ s.vod_preview_url = v && v.preview_url ? media.publicUrl(v.preview_url) : null;
++ s.vod_preview_webm_url = v && v.preview_webm_url ? media.publicUrl(v.preview_webm_url) : null;
}
return list;
}
ddiff --git a/test/media-privacy.test.js b/test/media-privacy.test.js
iindex ccff6abb..be50b4ac 100644
---- a/test/media-privacy.test.js
++++ b/test/media-privacy.test.js
@@@ -322,14 +322,17 @@ async function check(name, fn) {
assert.ok(row, 'the stream is listed');
assert.strictEqual(row.vod_id, null, 'no private or unlisted VOD id');
assert.strictEqual(row.vod_thumbnail_url, null, 'no private or unlisted VOD thumbnail');
++ assert.strictEqual(row.vod_preview_url, null, 'no private or unlisted VOD preview');
assert.ok(asked.length && asked.every((q) => !q.include_private), 'never asks Media for hidden VODs');
lookups._resetCaches();
-- answer = [{ id: 100, stream_id: streamA, user_id: 3, visibility: 'public', is_public: 1, thumbnail_url: 'https://media.test/t/pub.jpg', duration_seconds: 42 }];
++ answer = [{ id: 100, stream_id: streamA, user_id: 3, visibility: 'public', is_public: 1, thumbnail_url: 'https://media.test/t/pub.jpg', duration_seconds: 42, preview_url: 'https://media.test/t/pub.mp4', preview_webm_url: 'https://media.test/t/pub.webm' }];
row = (await lookups.attachPublicVods(await db.getRecentStreams(10))).find((s) => s.id === streamA);
assert.strictEqual(row.vod_id, 100, 'a public VOD is attached');
assert.strictEqual(row.vod_is_public, 1);
assert.strictEqual(row.vod_thumbnail_url, 'https://media.test/t/pub.jpg');
assert.strictEqual(row.vod_duration, 42);
++ assert.strictEqual(row.vod_preview_url, 'https://media.test/t/pub.mp4', 'its preview, for the card');
++ assert.strictEqual(row.vod_preview_webm_url, 'https://media.test/t/pub.webm');
} finally { media.listVods = saved; lookups._resetCaches(); }
});