I'm playing with browser and audio.
I'm doing this
var session = {
audio: true,
video: false
};
var recordRTC = null;
navigator.getUserMedia(session, initializeRecorder, onError);
But, using latest FF available I got a javascript error, saying that
navigator.getUserMedia is not a function
I copied this code from this blog post: https://blog.groupbuddies.com/posts/39-tutorial-html-audio-capture-streaming-to-nodejs-no-browser-extensions
And similar on latest Chrome:
Uncaught TypeError: undefined is not a function
But I know that this api is supported from both browser
What am I doing wrong?
getUserMedia() Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes.
getUserMedia() is a part of the webRTC media capture API and is used to get access to the camera and the microphone connected to the user device (user computer, smartphone, etc.) from the browser.
getUserMedia API This API is used for accessing and controlling the media devices like the camera in our device. It is available in the navigator. mediaDevices object.
It's not supported unprefixed yet. See http://caniuse.com/#search=getusermedia
You'll need to get the browser-specific prefix and use that. As posted in another answer:
navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
This will set navigator.getUserMedia
to whatever it detects to be the proper prefixed version.
Since navigator.getUserMedia()
is deprecated, use this :
navigator.getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia
);
if (typeof navigator.mediaDevices.getUserMedia === 'undefined') {
navigator.getUserMedia({
audio: true
}, streamHandler, errorHandler);
} else {
navigator.mediaDevices.getUserMedia({
audio: true
}).then(streamHandler).catch(errorHandler);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With