https://www.duolingo.com/ace2233ace

Certificate causes microphone function to fail

Certificate causes microphone function to fail

网站默认使用 http://www.duolingo.cn/

但是 chrome 不允许使用 http 调用摄像头。

The website uses http://www.duolingo.cn/ by default.

But chrome doesn't allow calling the camera with http.

http err

手动切换到 https 后, chrome 提示证书失效, 也是无法正常使用麦克风。

After manually switching to https, chrome indicates that the certificate is invalid, and the microphone is not working properly.

https err

以下提供三种解决方案:

The following three solutions are available:

关闭 chrome 的安全检查

使用 --unsafely-treat-insecure-origin-as-secure="http://example.com" 关闭 chrome 的安全检查功能, 让 http 可以调用麦克风。

Use --unsafely-treat-insecure-origin-as-secure="http://example.com" to turn off chrome's security check feature so that http can call the microphone.

由多邻国安装有效的 https 证书

为了减少成本, 可以申请免费的 ssl 证书。

In order to reduce costs, you can apply for a free ssl certificate.

通过以下代码为证书失效的 https 调用麦克风。

``` js

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

if (navigator.getUserMedia) { // yes } else { // no }

navigator.getUserMedia({video: true,audio:true}, function onSuccess(stream) { console.log('yes'); }, function onError(error) { console.log("no", error); });

```

感谢多邻国。

Thanks duolingo.

3 天前

0 条评论

每天 5 分钟就能学一种语言了!且完全免费!