问题
I've been prototyping a few pages that use webkitspeechrecognition. I learned quickly that you cannot load these from a file, you have to serve them from a webserver. I'm using osx so I just moved my files to the local apache that was already running and enabled. This worked fine for quite a while.
For some reason, none of my pages that were working fine will prompt me to deny/allow the microphone usage. I even copied an existing working page from another webserver and if I load it from http://localhost/speech.html it will not prompt. It skips the prompt and goes to my recognition.onerror handler and logs "not-allowed"
However, if I load the same page (or any of my other prototypes) from http://127.0.0.1/speech.html it works fine. This made me think I had accidentally cached a response like "always deny" or something. I think I cleared/reset all my chrome settings but I'm still getting the same behavior. 127.0.0.1 will properly prompt, but localhost will not prompt at all.
Where might chrome be storing some additional settings that I need to clear?
回答1:
Your microphone settings might be stored at chrome://settings/contentExceptions#media-stream-mic
. You can view the websites that have permissions saved there.
回答2:
getUserMedia permissions requesting in chrome currently works something like:
- If you have a request by http, getUserMedia will only remember the permissions for that session. If you go back to the same page. it asks again.
- If you do the same request by https, once you set the permissions, you always have permissions.
- My memory is that an exception is granted for http://localhost/... for debugging purposes. In this case, you don't need to repeatedly grant permissions.
- If you use http and 127.0.0.1/, I think no exception is made.
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
来源:https://stackoverflow.com/questions/29330977/webkitspeechrecognition-no-longer-prompts-for-permission