HTML5 Video autoplay not working

廉价感情. 提交于 2020-03-21 11:21:33

问题


I have been looking into how to implement HTML5 videos as a background video on web and mobile, below is the following code- it displays but not autostarts, this is the problem

<video width="100%" controls autoplay>
  <source src="video/342125205.mp4" type="video/mp4">
  <source src="video/342125205.ogg" type="video/ogg">
</video>

回答1:


Depending on your Chrome version you might get the new implementation of video autoplay rules:

  • Muted autoplay is always allowed.
  • Autoplay with sound is allowed if:
    • User has interacted with the domain (click, tap, etc.).
    • On desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously play video with sound.
    • On mobile, the user has added the site to his or her home screen. Top frames can delegate autoplay permission to their iframes to allow autoplay with sound.

Taken from: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

So you can try it muted:

<video width="100%" controls autoplay muted>
  <source src="video/342125205.mp4" type="video/mp4">
  <source src="video/342125205.ogg" type="video/ogg">
</video>



回答2:


I had similar issues with autoplay not having any effect regardless of usage of muted. Unexpectedly I had success when specifying autoplay as camel case autoPlay



来源:https://stackoverflow.com/questions/49822790/html5-video-autoplay-not-working

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