javascript - In the browser, how can I detect if a user has given microphone permissions? -
not more title. on browser, i'm requesting mic use. how can i, dev, access if they've chosen , choice made? thanks.
window.audiocontext = window.audiocontext || window.webkitaudiocontext; var audiocontext = new audiocontext(); var audioinput = null, realaudioinput = null, inputpoint = null, audiorecorder = null; initaudio(); function initaudio(){ if (!navigator.getusermedia) { navigator.getusermedia = navigator.webkitgetusermedia || navigator.mozgetusermedia; console.log("no microphone detected"); } if (!navigator.cancelanimationframe) { navigator.cancelanimationframe = navigator.webkitcancelanimationframe || navigator.mozcancelanimationframe; } if (!navigator.requestanimationframe) { navigator.requestanimationframe = navigator.webkitrequestanimationframe || navigator.mozrequestanimationframe; } navigator.getusermedia({audio:true}, gotstream, function(e) { alert('error getting audio'); console.log(e); }); } function gotstream(stream) { // create audionode stream , set input devices }
Comments
Post a Comment