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 occurred: ' + err); }); } else { console.log('new getUserMedia not supported on your browser!'); }
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
mediaStream |
55 |
≤79 |
53 |
No |
? |
14.1 |
55 |
55 |
53 |
? |
14.5 |
6.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamAudioSourceOptions/mediaStream