如何检测自动播放何时被阻止? [英] How to detect when autoplay is blocked?
问题描述
目前 WebRTC 在 Brave 浏览器上失败,并显示自动播放在此页面上被阻止"错误.
Currently WebRTC fails on Brave browser with "Autoplay was blocked on this page" error.
这个错误不是特别明显:
This error is not particularly visible:
您可以使用启用了任何 WebRTC 的 Brave 浏览器进行测试,例如https://test.webrtc.org/.
You can test it with Brave browser where any WebRTC is enabled, e.g. https://test.webrtc.org/.
我的应用用户将此报告为错误 - 因为他们的经验是视频无法加载.
My app users are reporting this as a bug – since their experience is that the video is just not loading.
处理这个问题的正确方法是什么?
What is the proper way to handle this?
推荐答案
https://webrtchhacks.com/autoplay-restrictions-and-webrtc/ 有很多(仍然有效的)建议.按照此处(从评论链接)的建议检查音频上下文状态是可能是要走的路.
https://webrtchacks.com/autoplay-restrictions-and-webrtc/ has quite some (still valid) suggestions. Checking the audiocontexts state as suggested here (linked from a comment) is probably the way to go.
勇敢地这样做是相当令人惊讶的,当 getUserMedia 处于活动状态时,chrome 确实允许自动播放.
It is rather surprising that brave does this, chrome does allow autoplay when getUserMedia is active.
这篇关于如何检测自动播放何时被阻止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!