MediaStreamAudioSourceOptions.mediaStream

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

Syntax

mediaStreamAudioSourceOptions = {
  mediaStream: audioSourceStream;
}

mediaStreamAudioSourceOptions.mediaStream = audioSourceStream;

Value

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

Example

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);
        source.connect(audioCtx.destination);
      }).catch(function(err) {
       console.log('The following gUM error occured: ' + err);
      });
} else {
  console.log('new getUserMedia not supported on your browser!');
}

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
mediaStreamChrome Full support 55Edge ? Firefox Full support 53IE No support NoOpera ? Safari ? WebView Android Full support 55Chrome Android Full support 55Firefox Android Full support 53Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown