Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaStreamAudioSourceNode

MediaStreamAudioSourceNode

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨September 2017⁩.

TheMediaStreamAudioSourceNode interface is a type ofAudioNode which operates as an audio source whose media is received from aMediaStream obtained using the WebRTC or Media Capture and Streams APIs.

This media could be from a microphone (throughgetUserMedia()) or from a remote peer on a WebRTC call (using theRTCPeerConnection's audio tracks).

AMediaStreamAudioSourceNode has no inputs and exactly one output, and is created using theAudioContext.createMediaStreamSource() method.

TheMediaStreamAudioSourceNode takes the audio from thefirstMediaStreamTrack whosekind attribute's value isaudio. SeeTrack ordering for more information about the order of tracks.

The number of channels output by the node matches the number of tracks found in the selected audio track.

EventTarget AudioNode MediaStreamAudioSourceNode
Number of inputs0
Number of outputs1
Channel count 2 (but note thatAudioNode.channelCount is only used for up-mixing and down-mixingAudioNode inputs, andMediaStreamAudioSourceNode doesn't have any input)

Constructor

MediaStreamAudioSourceNode()

Creates a newMediaStreamAudioSourceNode object instance with the specified options.

Instance properties

In addition to the following properties,MediaStreamAudioSourceNode inherits the properties of its parent,AudioNode.

mediaStreamRead only

TheMediaStream used when constructing thisMediaStreamAudioSourceNode.

Instance methods

Inherits methods from its parent,AudioNode.

Usage notes

Track ordering

For the purposes of theMediaStreamTrackAudioSourceNode interface, the order of the audio tracks on the stream is determined by taking the tracks whosekind isaudio, then sorting the tracks by theirid property's values, in Unicode code point order (essentially, in alphabetical or lexicographical order, for IDs which are simple alphanumeric strings).

Thefirst track, then, is the track whoseid comes first when the tracks' IDs are all sorted by Unicode code point.

However, it's important to note that the rule establishing this ordering was added long after this interface was first introduced into theWeb Audio API. As such, you can't easily rely on the order matching between any two browsers or browser versions.

TheMediaStreamTrackAudioSourceNode interface is similar toMediaStreamAudioSourceNode, but avoids this problem by letting you specify which track you want to use.

Example

SeeAudioContext.createMediaStreamSource() for example code that uses this object.

Specifications

Specification
Web Audio API
# MediaStreamAudioSourceNode

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp