Search code examples
androidyoutubeandroid-webview

Are there any new tricks for auto playing embedded YouTube videos inside an Android WebView?


I've read lots of posts but none of the old tricks, like autoplay or playsinline or allow='autoplay' work.

I have full control over the WebView so I've even tried mediaPlaybackRequiresUserGesture set to false but it didn't help.

Any other tricks?

This is how I load the iframe:

<iframe width="100%" height="100%" allow="autoplay" src="http://www.youtube.com/embed/${YOUTUBE_VIDE)_ID}?autoplay=1&playsinline=1" frameborder="0" ></iframe>

Solution

  • Looks like a combination of the steps from this page https://developers.google.com/youtube/iframe_api_reference and mediaPlaybackRequiresUserGesture will allow me to auto play the video. Even tested it on the newest Android System WebView on Android 12.