Can't autoplay youtube video in android chrome

倖福魔咒の 提交于 2019-12-02 02:18:19
etf213

This link seems to answer most of your questions:

YouTube iframe embeds cannot autoplay on Android

But in short, it seems like autoplay has been disabled on Chrome for Android so you need to treat it in the same way as iOS and use a user interaction to trigger the play.

Update: There's a more affirmative information that it has been disabled here: https://developers.google.com/web/updates/2016/07/autoplay#why_the_change

It will play however if you set it to autoplay in a muted state.

A solution I've just been working on for autoplaying would be to instantiate the player with an empty video on page load:

var player = new YT.Player('yt-media-player', {
  height: height,
  width: width,
  videoId: ''
});

Then on the click event of opening the lightbox you can load the particular video and call it to play:

player.loadVideoById(youtubeId);

player.playVideo();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!