Skip to content

Commit 3ab77bd

Browse files
committed
Tighten up video demo
Check for middling connections and only preload video metadata in such cases.
1 parent b552a18 commit 3ab77bd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

demo/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,31 @@ <h2><code>window.obs</code></h2>
288288
const videoWrapper = document.getElementById('jsVideo');
289289

290290
if (window.obs?.shouldAvoidRichMedia === true) {
291+
291292
const img = new Image();
292293
img.src = './assets/poster.png';
293294
img.alt = '';
294295
img.width = '1500';
295296
img.height = '966';
296297
videoWrapper.appendChild(img);
298+
297299
} else {
300+
298301
const video = document.createElement('video');
299302
video.src = './assets/video.min.mp4';
300303
video.poster = './assets/poster.png';
301304
video.autoplay = true;
305+
video.loop = true;
302306
video.muted = true;
303307
video.controls = true;
308+
video.preload = 'auto';
309+
310+
if (window.obs?.deliveryMode === 'cautious') {
311+
video.preload = 'metadata';
312+
}
313+
304314
videoWrapper.appendChild(video);
315+
305316
}
306317

307318
})();

0 commit comments

Comments
 (0)