iNotify icon indicating copy to clipboard operation
iNotify copied to clipboard

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

Open icaca opened this issue 6 years ago • 2 comments

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

icaca avatar Oct 24 '18 12:10 icaca

我搜到的结果

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 avatar Oct 24 '18 12:10 jaywcjlove

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

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

jaywcjlove avatar Oct 24 '18 13:10 jaywcjlove