Difference between window.AudioContext and navigator.getUserMedia

1k views Asked by At

I've searched and read a few articles found through Google search, but can't find a laid out answer.

Besides initiation what is the difference between window.AudioContext and navigator.getUserMedia?

Also I already know getUserMedia can be used to also get camera stream, but this is more in the scope of audio. Browser support info would also be very helpful.

2

There are 2 answers

2
Obscure Geek On

There is a lot of difference between window.AudioContext and navigator.getUserMedia. GetUserMedia gives you the audio stream generated in terms of a MediaStream object whereas AudioContext is used mainly in terms of audio-processing. You will also get the supported browsers in the provided links.

0
jesup On

getUserMedia() gets input data from microphones, camera or other locations (screencaptures (which will include audio capture soon), etc). It creates a MediaStream (with one or more MediaStreamTracks). You can also create MediaStreams from media elements (element.captureStream()/etc) or canvases (canvas.captureStream(...) - obviously video only). Note that captureStream() is in the process of being incorporated into the specs for MediaStreams.

An AudioContext is the grouping construct for WebAudio graphs. It isn't a source or even a processing node, it's a context (graph) the WebAudio code works in. You can feed a MediaStream (the audio tracks thereof) into a WebAudio AudioContext, or use other recorded or synthetic inputs/generators.

Very different constructs.