我想在Windows上的Chrome上以不安全的来源测试getUserMedia
。我按照goo.gl/rStTGz上的指示启动Chrome,如果你使用getUserMedia
使用不安全的来源,这个链接会显示在控制台中:
start chrome "http://my-ip:8000/index.html" --unsafely-treat-insecure-origin-as-secure="http://my-ip" --user-data-dir=/tmp
在index.html
有这样的:
navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } }, stream => console.debug(stream), e => console.error(e))
即使我做了第一个链接说的话,它仍然给我错误。此错误包括另一个链接goo.gl/Y0ZkNV,它没有提到如何解决此问题进行测试。
这仍然受支持吗?它似乎是这样,因为Chrome确实以一个新的配置文件开始,并显示有关使用上述标志的警告。该标志显然是由Chrome阅读,但没有采取行动。为什么?
您还需要在标志中指定端口。尝试
start chrome "http://my-ip:8000/index.html" --unsafely-treat-insecure-origin-as-secure="http://my-ip:8000" --user-data-dir=/tmp
请注意,不再需要--user-data-dir
。请参阅第3点here中的注释。