Muted Autoplay video shows error: play() failed because the user didn't interact with the document first.

落爺英雄遲暮 提交于 2019-11-27 04:53:21

问题


I am trying to make an HTML5 video autoplay (in muted condition) in the popup in the page. The popup is hidden when page is loaded. When user tries to go out of page (from top), it shows video popup with AutoPlay & muted ON. Then I tried to play video with JavaScript but it gives this error: play() failed because the user didn't interact with the document first.

It works fine if I click somewhere on page or if developer panel is open before the video popup is displayed. I am using Flow Player, and issue only in Google Chrome (works fine on FF).

Can you please give any ideas on how to overcome this?

Thanks, J


回答1:


Google Chrome has updated the autoplay policies. URL for reference

According to new behaviours:

  1. Muted autoplay is always allowed.
  2. 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.
  3. Top frames can delegate autoplay permission to their iframes to allow autoplay with sound.


来源:https://stackoverflow.com/questions/51041580/muted-autoplay-video-shows-error-play-failed-because-the-user-didnt-interact

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