原因分析:
1、http協議的網站的安全原因,不能訪問本地的麥克風
2、允許打開麥克風的請求有http://localhost/以及https請求。
解決方法:
方法一:
訪問攝像頭,麥克風等必須使用https,將網站部署成https請求
方法二:
官方解釋:
You can run chrome with the --unsafely-treat-insecure-origin-as-secure="http:example.com" flag (replacing "example.com" with the origin you actually want to test), which will treat that origin as secure for this session. Note that on Android and ChromeOS this requires having a device with root access/dev mode. (This flag is broken in Chrome 63 but fixed in Chrome 64 and later. Prior to Chrome 62, you must also include the --user-data-dir=/test/only/profile/dir to create a fresh testing profile for the flag to work.)
右鍵點擊Chrome桌面快捷方式,打開屬性
在 “快捷方式頁-目標”最後輸入以下內容
--unsafely-treat-insecure-origin-as-secure="http://example.com" --user-data-dir=/test/only/profile/dir
注意:
1、"--"前要保留一個空格;
2、" --user-data-dir=/test/only/profile/dir",不可缺少,很多文章都是因爲缺少該配置,無法實現http網頁打開麥克風、攝像頭。