可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I cloned a project about real-time image processing on a web browser from this link:
Then I could not allow my browser to access my camera.
I got this javascript alert:
Uh-oh, the webcam didn't start. Do you have a webcam? Did you give it
permission? Refresh to try again.
And the allow button is not shown as if I access his site.
回答1:
Are you accessing the webpage that is served over HTTP, on localhost? If you are accessing it from http://localhost/...
, Chrome will ask for your permission to use the camera.
If you are opening the web page directly, i.e. /Users/Methuz/Documents/index.html then it will not work, even if you explicitly allows it permission
In this case, the workaround I use is to host the HTML file on a webserver. A quick hack is to use python, in the folder where the HTML page is lcoated: python -m SimpleHTTPServer
回答2:
Step 1:
Find your chrome preferences file:
http://www.forensicswiki.org/wiki/Google_Chrome#Configuration
Step 2:
Open it and Find the "profile" key
Step3:
Under profile there will be a "content_settings" hash, that will have a "pattern_pairs" hash
Add this to it:
"*,*": {
"media-stream-camera": 1
}
Final example:
"profile": {
....
"content_settings": {
....
"pattern_pairs": {
"*,*": {
"media-stream-camera": 1
},
....
}
}
}
WARNING: This will allow all websites access to your camera
回答3:
Chrome now only allows https:// servers to persistent list (version 39.xx)
https://support.google.com/chrome/answer/2693767?hl=en
Allow: This allows the site to access your camera and microphone at this time and a notification will appear confirming that you’ve granted access. If you select Allow on a "http" URL your preference will not be remembered in future visits. If you select Allow on a "https" URL, your preference will be remembered in future visits.
Maybe this link helps to set your local secure server if you are using Wamp.
http://forum.wampserver.com/read.php?2,32986
Then you can add your local server to persistent allow list of chrome.
回答4:
Another solution is to use iframe
tag. Jest deploy your page on server (localhost or external) and include it in your local html.
Example:
<iframe src="http://localhost/your_project/index.html"></iframe>
回答5:
Chrome on HTTP or any other port won't save the preference of Camara share choice.
To save the selection you will need to run on HTTPs, even if you don't have SSL certificate on localhost that fine. Just add https before the localhost url and it will ask you its unsafe, if you want to proceed add it as an exception under Advance options. Do that and then Chrome will save you camera sharing preference for this website. and won't ask you to select allow
回答6:
You can choose a different default permission setting and manage exceptions in Content settings.
- Click the Chrome menu Chrome menu on the browser toolbar.
- Select Settings.
- Click Show advanced settings.
- In the "Privacy" section, click Content settings.
- In the "Media" section:
* Ask me when a site requires access to my camera and microphone: Select this option if you want Chrome to alert you whenever a site requests access to your camera and microphone.
* Do not allow sites to access my camera and microphone: Select this option to automatically deny any site requests to access your camera and microphone.
Or click Manage exceptions to remove previously-granted permissions for specific sites.
Source: https://support.google.com/chrome/answer/2696491?hl=en
P/D: the link you provided has an error. I can't access.
回答7:
Open localhost/webcam.swf
then right click on the flash file then allow the webcam and tick remember
that will add exception for localhost