Youtube iframe api allow="autoplay" Chrome 65
Asked Answered
B

2

10

Chrome 65, the current canary version, is blocking iframed youtube videos from auto playing with sound.

The latest changes to Chrome require the iframe to have allow="autoplay"

How do I go about adding allow="autoplay" to the youtube iframe api? I can't find it in any of the documentation.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#iframe

A feature policy allows developers to selectively enable and disable use of various browser features and APIs. Once an origin has received autoplay permission, it can delegate that permission to cross-origin iframes with a new feature policy for autoplay. Note that autoplay is allowed by default on same-origin iframes.

<iframe src="myvideo.html" allow="autoplay">
Barnstorm answered 3/1, 2018 at 23:47 Comment(0)
M
10

The YouTube IFrame API has been recently updated to use allow=autoplay instead of gesture=media. It should now work as expected.

Sorry for the confusion.

Milissa answered 12/2, 2018 at 13:19 Comment(3)
Thank you the fix is working! Are there plans to support Safari 11 as well?Barnstorm
It doesn't seems to work anymore, somehow it's not working for me, with both allow=autoplay and gesture=media, on Chome Mac Version 66.0.3359.181Passably
@SaeeshTendulkar I can't remember since this is pretty old to me. Sorry!Passably
V
1

You just add it in the src URL like:

autoplay

This parameter specifies whether the initial video will automatically start to play when the player loads. Supported values are 0 or 1. The default value is 0.

Vespine answered 4/1, 2018 at 9:32 Comment(1)
@nougui I am creating the player using Javascript and when I add autoplay:1 it does not add allow="autoplay" to the iframe that gets embedded on my site. function onYouTubePlayerAPIReady() { player = new YT.Player('ytplayer', { height: '360', width: '640', videoId: 'M7lc1UVf-VE' autoplay: '1', }); }Barnstorm

© 2022 - 2024 — McMap. All rights reserved.