如何在Chrome中自动播放带有视频的iframe



我在谷歌上搜索了答案,但没有找到任何答案。如何在chrome中自动播放视频。这就是我尝试过的:

<iframe allow="fullscreen; autoplay" allowfullscreen="true" src="https://example.com"></iframe>

我在互联网上找到了答案,但在stackoverflow中没有,所以我会把它留在这里,这样有人可以找到它:

<iframe allow="autoplay *; fullscreen *" allowfullscreen="true" 
src="https://example.com">
</iframe>

令人惊讶的是,关于这方面的信息很少。经过多次搜索,我发现这是可行的。

要修改代码以包含自动播放函数,只需插入字母数字代码后:

?rel=0;&autoplay=1

示例:

<iframe width="560" height="315" 
src="https://www.youtube.com/embed/iG9CE55wbtY?rel=0;&autoplay=1" frameborder="0" 
allowfullscreen>
</iframe>

参考:https://support.gospacecraft.com/hc/en-us/articles/202694610-Set-Video-to-Autoplay

只需在代码中添加autoplay函数:在链接后(双引号内(添加"?autoplay=1"。

<iframe src="https://example.com?autoplay=1"></iframe>

转介这个会更好地解释你。

为了自动播放视频,iframe需要在src属性中包含autoplay=1,还需要包含allow=autoplay属性。

<iframe src="https://example.com?autoplay=1" allow="autoplay"></iframe>

最新更新