Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome 播放声音时会提示未捕获异常 #17

Open
icaca opened this issue Oct 24, 2018 · 2 comments
Open

chrome 播放声音时会提示未捕获异常 #17

icaca opened this issue Oct 24, 2018 · 2 comments

Comments

@icaca
Copy link

icaca commented Oct 24, 2018

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
mac chrome v70

@jaywcjlove
Copy link
Owner

我搜到的结果

Chrome的autoplay政策在2018年4月做了更改。

新的行为:浏览器为了提高用户体验,减少数据消耗,现在都在遵循autoplay政策,Chrome的autoplay 政策非常简单

  1. muted autoplay始终被允许
  2. 音乐的autoplay 只有在下面集中情况下起作用:
        1. 有用户行为发生像(click,tap,etc).
        2. 对于桌面程序,用户已经提前播放了音频
        3. 对于移动端用户将音频网址home screen.

  解决方案:

  • Open chrome://flags/#autoplay-policy
  • Setting No user gesture is required
  • Relaunch Chrome

回头我尝试一下,页面加载完成之后,再播放声音,这样应该没有这个错误。

@jaywcjlove
Copy link
Owner

@icaca 我测试了一下,果真是要设置允许自动播放然后,就不报错了。

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants