WebRTC – Video Tag Not Working In Chrome

Google Chrome 浏览器中,WebRTC 的 getUserMedia 在本地工作正常,但上传到服务器访问时,发现 video 标签没有视频输入。按 F12 查看前端报错:

getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.

新版 Chrome 浏览器需要通过 HTTPS 访问,才能调用 getUserMedia

解决办法是购买 HTTPS 证书,或者自制证书让服务器支持 HTTPS 访问。

可以免费申请证书的网站:

  • <https://startssl.com/>
  • <https://letsencrypt.org>

Leave a Reply