People have asked for extended capabilities of HTML videos, this Gist is used to showcase a somewhat niched use case that incorporates theoretical capabilities as suggested in the issues raised by others, as mentioned below.
Use case:
Autoplay a background-video only on screens larger than 1000px (where the user hasn't set a preference to reduce motion),
if the user prefers reduced motion and/or is on a smaller device then show the poster
image instead.
<!-- 1) -->
<video autoplay muted playsinline>
<!-- 2) -->
<source src="video.webm" type="video/webm" media="screen and (min-width: 1000px) and (prefers-reduced-motion: no-preference)">
<!-- 3) -->
<poster src="poster.webp" type="image/webp" media="not all and (min-width: 1000px), not all and (prefers-reduced-motion: no-preference)" alt="{alt text for poster image}">
</<video>
- (FWIW) These attributes are used to satisfy browser policies for autoplaying videos.
- Allow
media
attribute for<video>
in whatwg/html#4544. - New
<poster>
element enables:
• Poster image delivery based onmedia
query conditions.
•alt
text (resolves w3c/html#1431).
• Responsive poster images usingsrcset
&sizes
(resolves ResponsiveImagesCG/picture-element#258).
@zcorpan If you don't mind, what is your initial thought of this?