This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

createMediaStreamSource

Summary

Creates a MediaStreamAudioSourceNode, given a MediaStream. As a consequence of calling this method, audio playback from the MediaStream will be re-routed into the processing graph of the AudioContext.

Method of apis/webaudio/AudioContextapis/webaudio/AudioContext

Syntax

var  = AudioContext.createMediaStreamSource();

Return Value

Returns an object of type

MediaStreamAudioSourceNode

Examples

//it may be necessary to prefix getUserMedia and AudioContext in order to work in some browsers

//request microphone stream
navigator.getUserMedia({ audio: true }, function(stream){
     var context = new AudioContext();
     var micStreamSource = context.createMediaStreamSource(stream);

     micStreamSource.connect(context.destination);  //redirects mic input to speakers
}, function(){ console.log('Error getting Microphone stream'); });

Related specifications

W3C Web Audio API
W3C Editor’s Draft