2

i have code like this

function initAudio() {
    if (!navigator.webkitGetUserMedia)
        return(alert("Error: getUserMedia not supported!"));

    navigator.webkitGetUserMedia({audio:true}, gotStream, function(e) {
            alert('Error getting audio');
            console.log(e);
        });
}

window.addEventListener('load', initAudio );

my output in console is this

NavigatorUserMediaError {code: 1, PERMISSION_DENIED: 1} 

why permission deny for me? I try to make audio recorder from source code of this page http://webaudiodemos.appspot.com/AudioRecorder/index.html

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
open source guy
  • 2,727
  • 8
  • 38
  • 61

1 Answers1

4

If your running your code from a file saved on your machine not through a web server, chrome sometimes has issues with allowing access due to its secuirty policy.

Two options to try are

  1. Putting it on a web server
  2. Opening chrome through terminal using the command below if you are on mac

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

Dominic Green
  • 10,142
  • 4
  • 30
  • 34
  • The second option does not work anymore. See here on how to set up a simple server in one line: http://stackoverflow.com/a/19292612/2293095. Then access your "index.html" by opening up a browser and accessing this site in http://127.0.0.1:8000/ – Tariq Aug 07 '15 at 17:47