Skip to content
Related Articles

Related Articles

HTML AudioContext createMediaStreamTrackSource() Method

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 25 Oct, 2020

Prerequisite: AudioContext baseLatency Property

The HTML AudioContext.createMediaStreamTrackSource() is used to create an instance of MediaStreamAudioSourceNode object which can be used by the user to manipulate the stream feed in the 
AudioContext.createMediaStreamTrackSource() method. The MediaStreamAudioSourceNode is used in audio processing graph for use and manipulation.


audioSourceNode = audioContext.createMediaStreamSource(stream)

Parameter: This method accepts single parameter stream that holds the ediaStream(stream) to serve as an audio source.

Return Value: This method returns the MediaStreamAudioSourceNode object.



<!DOCTYPE html>
<body style="text-align:center;">
        <h1 style="color:green">
        <h2>AudioContext.createMediaStreamSource() Method</h2>
                { audio: true, video: true })
                .then(function (stream) {
                    video.srcObject = stream;
                    // Create a MediaStreamAudioSourceNode
                    // Feed the HTMLMediaElement into it
                    var audioCtx = new AudioContext();
                    var source = audioCtx
                    if (source)
                        console.log('Geeks For Geeks is On');
                .catch(function (err) {
                    console.log('Error occured: ' + err);


When some Error Occurs 

Explanation: In this example, we grab a media (audio + video) stream from navigator.getUserMedia, feed the media into a video element to play then mute the audio, but then also feed the audio into a MediaStreamAudioSourceNode.

Supported Browsers: 

  • Google Chrome 
  • Microsoft Edge 
  • Firefox 
  • Opera 
  • Safari

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!