I have two videos for a webpage I created recently but the inline media queries aren't working.
The player is just pulling the first video in the list of sources.
Here is my code:
<video class="intro-video" controls poster="lineandgrid-video-intro-cover.gif">
<source media="(max-width: 750px)" src="lineandgrid-introduction-video-mobile.mp4" type="video/mp4">
<source media="(min-width: 751px)" src="lineandgrid-introduction-video.mp4" type="video/mp4">
</video>
Can someone tell me what I'm doing wrong? You can view the live webpage here: https://lineandgrid.ca/video/
Media queries are generally only supported for <picture> elements.
Attributes: Media: Media query of the resource's intended media; this should be used only in a <picture> element.
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source:
Chrome does not support inline media queries on the source tag within videotag. [...] Worse, plain media queries will not stop multiple videos from loading, which effectively doubles your data, so it requires a JS solution.
The proposed JS solution, if the original blog post becomes unavailable: https://gist.githubusercontent.com/fuzzywalrus/8abdd088e3fb6a73fd5d980f7bab0118/raw/9922cce9c4c040164f383671070e588c2adff944/responsivevideo.js
Original answer:
Apparently, support for inline media queries has been removed: