Chrome getUserMedia Not Requesting Permission Locally

前端 未结 5 628
轻奢々
轻奢々 2020-11-29 10:11

I\'m attempting to play around with navigator.getUserMedia in Chrome; however, it is not requesting permission when served locally (file:///whatever/index.html), but does on

相关标签:
5条回答
  • 2020-11-29 10:39

    It's a little non-trivial how to do the command line arg in OS X. It will usually look like this

    "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --allow-file-access-from-files
    

    If you are a freak like me, and put your apps in ~/Applications, then it will be

    "/Users/yougohere/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --allow-file-access-from-files
    

    If neither of those are working, then type chrome://version in your Chrome address bar, and it will tell you what "command line" invocation you should be using. Just add --allow-file-access-from-files to that.

    0 讨论(0)
  • 2020-11-29 10:43

    I encountered similar problem, but related to microphone access. Chrome blocks device access if you serve your file via file://(note that on Microsoft Edge and Firefox it worked via file:://).

    One solution i've found for Chrome:

    1. open chrome an type in the URL chrome://version/
    2. copy the value of "Command Line" field in your command line and append --allow-file-access-from-files and run it
    3. after Chrome opened and enter your file:// url.

    For starting Chrome always like that, right click on Chrome icon, and then click on properties. In the Shortcut tab append to the Target value all the command line parameters from 2.

    0 讨论(0)
  • 2020-11-29 10:46

    Chrome blocks a lot of stuff on file:/// URIs without reporting a security error (eg. Geolocation). Your best option is to run from a local webserver, if you have Python installed try SimpleHTTPServer.

    0 讨论(0)
  • 2020-11-29 10:53

    You can use the --allow-file-access-from-files flag from the command line when opening chrome to be able to use getUserMedia from a local file system.

    0 讨论(0)
  • 2020-11-29 10:59

    Try Installing Simple Server ( light weight ) , one click install , can be downloaded here

    Once it is installed , refer the app to the page you want to run.

    0 讨论(0)
提交回复
热议问题