fix(cctv): preserve looping for finite video feeds

This commit is contained in:
Bilawal Sidhu committed 2026-09-15 11:24:10 -05:00
1 parent 052e1bfc1b
commit 0f04547691
2 files changed
+25

No files matched your search

+2
View File
@@ -9,6 +9,8 @@ export function attachCctvVideo(
fetchImpl = globalThis.fetch, fetchImpl = globalThis.fetch,
} = {}, } = {},
) { ) {
// Preserve replay for existing finite video feeds; live HLS must not loop.
video.loop = feedType !== 'hls';
let disposed = false; let disposed = false;
let hls = null; let hls = null;
const leaseId = feedType === 'hls' ? globalThis.crypto.randomUUID() : null; const leaseId = feedType === 'hls' ? globalThis.crypto.randomUUID() : null;
+23
View File
@@ -68,3 +68,26 @@ test('native HLS releases its client lease without response-header access', asyn
assert.equal(releases[0].url, requested); assert.equal(releases[0].url, requested);
assert.equal(releases[0].init.method, 'DELETE'); assert.equal(releases[0].init.method, 'DELETE');
}); });
test('finite video feeds retain looping while live HLS does not loop', async () => {
for (const feedType of ['mp4', 'webm', 'hls']) {
const source = video();
source.loop = true;
source.canPlayType = () => 'probably';
let imports = 0;
const playback = attachCctvVideo(source, '/api/cctv/media/a', feedType, {
loadHls: async () => {
imports++;
return { default: { isSupported: () => false } };
},
fetchImpl: async () => {},
});
try {
await playback.ready;
assert.equal(source.loop, feedType !== 'hls');
assert.equal(imports, feedType === 'hls' ? 1 : 0);
} finally {
playback.dispose();
}
}
});