Class AudioStreamTrack
Represents a single audio track within a stream.
Implements
Inherited Members
Namespace: Unity.WebRTC
Assembly: Unity.WebRTC.dll
Syntax
public class AudioStreamTrack : MediaStreamTrack, IDisposable
Remarks
AudioStreamTrack
is a MediaStreamTrack
that represents a single audio track within a stream.
Examples
AudioStreamTrack audioStreamTrack = new AudioStreamTrack(texture);
Constructors
AudioStreamTrack()
Creates a new AudioStreamTrack object.
Declaration
public AudioStreamTrack()
Remarks
AudioStreamTrack
constructor creates an instance of AudioStreamTrack
.
Examples
AudioStreamTrack audioStreamTrack = new AudioStreamTrack();
See Also
AudioStreamTrack(AudioListener)
Creates a new AudioStreamTrack object.
Declaration
public AudioStreamTrack(AudioListener listener)
Parameters
Type | Name | Description |
---|---|---|
AudioListener | listener |
|
Remarks
AudioStreamTrack
constructor creates an instance of AudioStreamTrack
with a listener
.
Examples
AudioStreamTrack audioStreamTrack = new AudioStreamTrack(listener);
See Also
AudioStreamTrack(AudioSource)
Creates a new AudioStreamTrack object.
Declaration
public AudioStreamTrack(AudioSource source)
Parameters
Type | Name | Description |
---|---|---|
AudioSource | source |
|
Remarks
AudioStreamTrack
constructor creates an instance of AudioStreamTrack
with a source
.
Examples
AudioStreamTrack audioStreamTrack = new AudioStreamTrack(source);
See Also
Properties
Loopback
This flag only works on sender side track. If True, Send audio input to remote and Play audio in local. If False, only send to remote. Not play audio in local.
Declaration
public bool Loopback { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
Source
AudioSource object.
Declaration
public AudioSource Source { get; }
Property Value
Type | Description |
---|---|
AudioSource |
See Also
Methods
Dispose()
Disposes of AudioStreamTrack.
Declaration
public override void Dispose()
Overrides
Remarks
Dispose
method disposes of the AudioStreamTrack
and releases the associated resources.
Examples
audioStreamTrack.Dispose();
See Also
SetData(float[], int, int)
Provides the audio data to the track.
Declaration
public void SetData(float[] array, int channels, int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
float[] | array | Float array containing audio data samples. |
int | channels | Number of audio channels. |
int | sampleRate | Sample rate of the audio data |
Remarks
SetData
method provides the audio data to the track.
Examples
audioStreamTrack.SetData(array, channels, sampleRate);
See Also
SetData(ReadOnly, int, int)
Declaration
public void SetData(NativeArray<float>.ReadOnly nativeArray, int channels, int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<float>.ReadOnly | nativeArray | |
int | channels | |
int | sampleRate |
See Also
SetData(NativeSlice<float>, int, int)
Declaration
public void SetData(NativeSlice<float> nativeSlice, int channels, int sampleRate)
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<float> | nativeSlice | |
int | channels | |
int | sampleRate |
See Also
Events
onReceived
Event to be fired when new audio data is received.
Declaration
public event AudioReadEventHandler onReceived
Event Type
Type | Description |
---|---|
AudioReadEventHandler |
Remarks
onReceived
event is fired when new audio data is received.
Examples
audioStreamTrack.onReceived += (data, channels, sampleRate) =>
{
}