Reputation:
I am learning html5 and want to try to play on speakers what I say on microphone. So I wrote the following js code:
navigator.getUserMedia = navigator.getUserMedia ||navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var aCtx;
var analyser;
var microphone;
if (navigator.getUserMedia) {
navigator.getUserMedia(
{audio: true},
function(stream) {
aCtx = new AudioContext();
analyser = aCtx.createAnalyser();
microphone = aCtx.createMediaStreamSource(stream);
microphone.connect(analyser);
var destination=aCtx.destination;
analyser.connect(destination);
},
function(){ console.log("Error 003.")}
);
}
I test it on firefox 47 and ubuntu 14. I see the panel to share my microphone, I select share and nothing I hear nothing. How to fix it?
EDIT: However, it works on firefox 47 in windows7. But in ubuntu I have all drivers installed and I use skype, youtube etc everything works except this js script.
Upvotes: 0
Views: 1318
Reputation:
It works for me on both firefox and chrome (I'm on a Macbook Pro OSX 10.11)
https://jsfiddle.net/greggman/g88v7p8c/
Note it doesn't run on stackoverflow because using the mic requires HTTPS (at least on Chrome, didn't check firefox). If the page is not HTTPS then I get
getUserMedia()
no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See httpsgoo.gl/rStTGz for more details.`
stupid stackoverflow won't let me post the actual message from chrome because stackoverflow bans goo.gl
Upvotes: 2
Reputation:
I found out the problem. There are some additional
settings:CubebUtils
Upvotes: 1