When using oembed to get embed codes for Youtube, I get this HTML:
<iframe allowfullscreen="" frameborder="0" gesture="media" height="270" src="https://www.youtube.com/embed/4B36Lr0Unp4?feature=oembed" width="480"></iframe>
Do you notice the gesture="media"
HTML attribute? What is it? What does the "media"
value do?
It’s a non-standard (or not-yet-standard) thing that’s so far only used for media autoplay in Chrome.
See https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#iframe:
Iframe delegation
Once an origin has received autoplay permission, it can delegate that permission to iframes via a new HTML attribute. Check out the Gesture Delegation API proposal to learn more.
<iframe src="myvideo.html" gesture="media">
Without iframe delegation, videos will not be able to autoplay with sound.
And see also https://www.chromium.org/audio-video/autoplay:
By default embedded IFrames will only be able to play muted or silent videos. However, if site owners wish for IFrames on their site to be able to play unmuted content, they may pass the autoplay permissions to the IFrame via the gesture=media attribute. This attribute allows any video contained in the IFrame to play as if it were hosted on the site.
Those things both cite https://github.com/WICG/gesture-delegation/blob/master/explainer.md, but that document’s author says the gesture
name was only ever intended as a “placeholder” and that a Chrome Intent to Ship will go out soon with the real name of the HTML markup attribute being delegatestickyuseractivation
. So you’ll instead need to do:
<iframe src="myvideo.html" delegatestickyuseractivation="media">