Skip to content

Commit cf31315

Browse files
committed
Merge branch 'docs/demo'
2 parents a64b8a0 + 7fa644c commit cf31315

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

demo/assets/poster.png

131 KB
Loading

demo/assets/video.min.mp4

2.18 MB
Binary file not shown.

demo/index.html

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
h1, h2,
3636
p,
3737
pre,
38-
.c-snippet {
38+
.c-snippet,
39+
.c-video > video,
40+
.c-video >img {
3941
margin-bottom: 1.5rem;
4042
}
4143

@@ -120,6 +122,12 @@
120122
text-decoration: underline;
121123
}
122124

125+
img, video {
126+
max-width: 100%;
127+
height: auto;
128+
display: block;
129+
}
130+
123131
.c-snippet {
124132
display: block;
125133
background-color: #002a35;
@@ -131,6 +139,10 @@
131139
padding-right: 2.5em;
132140
}
133141

142+
.c-video > video {
143+
aspect-ratio: 312 / 202;
144+
}
145+
134146
.c-pill {
135147
display: inline-block;
136148
border: 1px solid #ccc;
@@ -265,6 +277,36 @@ <h2><code>window.obs</code></h2>
265277

266278
<pre id=obs aria-live=polite></pre>
267279

280+
<link rel=preload as=image href=./assets/poster.png>
281+
282+
<div class=c-video id=jsVideo></div>
283+
284+
<script class=c-snippet>
285+
(() => {
286+
// Inject a video if we’re on a good enough connection, otherwise just
287+
// inject a screenshot image.
288+
const videoWrapper = document.getElementById('jsVideo');
289+
290+
if (window.obs?.shouldAvoidRichMedia === true) {
291+
const img = new Image();
292+
img.src = './assets/poster.png';
293+
img.alt = '';
294+
img.width = '1500';
295+
img.height = '966';
296+
videoWrapper.appendChild(img);
297+
} else {
298+
const video = document.createElement('video');
299+
video.src = './assets/video.min.mp4';
300+
video.poster = './assets/poster.png';
301+
video.autoplay = true;
302+
video.muted = true;
303+
video.setAttribute('controls', '');
304+
videoWrapper.appendChild(video);
305+
}
306+
307+
})();
308+
</script>
309+
268310
<p><small><strong>Note:</strong> API support varies by browser; Chromium has
269311
the broadest coverage.</small></p>
270312

0 commit comments

Comments
 (0)