File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 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
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 ;
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
You can’t perform that action at this time.
0 commit comments