The MediaStreamAudioSourceOptions dictionary's mediaStream property must specify the MediaStream from which to retrieve audio data when instantiating a MediaStreamAudioSourceNode using the MediaStreamAudioSourceNode() constructor.


mediaStreamAudioSourceOptions = {
  mediaStream: audioSourceStream;

mediaStreamAudioSourceOptions.mediaStream = audioSourceStream;


A MediaStream representing the stream from which to use a MediaStreamTrack as the source of audio for the node.


This example uses getUserMedia() to obtain access to the user's camera, then creates a new MediaStreamAudioSourceNode from its MediaStream.

// define variables
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();

// getUserMedia block - grab stream
// put it into a MediaStreamAudioSourceNode
if (navigator.mediaDevices.getUserMedia) {
   navigator.mediaDevices.getUserMedia (
      // constraints: audio and video for this app
         audio: true,
         video: false
      }).then(function(stream) {
        var options = {
          mediaStream : stream

        var source = new MediaStreamAudioSourceNode(audioCtx, options);
      }).catch(function(err) {
       console.log('The following gUM error occurred: ' + err);
} else {
  console.log('new getUserMedia not supported on your browser!');


Specification Status Comment
Web Audio API
The definition of 'MediaStreamAudioSourceOptions.mediaStream' in that specification.
Working Draft

Browser compatibility

BCD tables only load in the browser