API Reference for web - Class: RemoteAudioTrack
# Class: RemoteAudioTrack
track/RemoteAudioTrack.RemoteAudioTrack
# Hierarchy
RemoteTrack
↳
RemoteAudioTrack
# Properties
# config
config: any
# Inherited from
RemoteTrack.config
# consumer
consumer: Consumer
# Inherited from
RemoteTrack.consumer
# userId
userId: string
# Inherited from
RemoteTrack.userId
# defaultMaxListeners
Static
defaultMaxListeners: number
# Inherited from
RemoteTrack.defaultMaxListeners
# errorMonitor
Static
Readonly
errorMonitor: typeof errorMonitor
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
# Inherited from
RemoteTrack.errorMonitor
# Accessors
# enabled
get
enabled(): boolean
本地轨道当前的启用状态。
# Returns
boolean
# Inherited from
RemoteTrack.enabled
# isPlaying
get
isPlaying(): boolean
媒体轨道是否正在页面上播放。
true
: 媒体轨道正在页面上播放。false
: 媒体轨道没有在页面上播放。
# Returns
boolean
# Methods
# addListener
addListener(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.addListener
# close
close(): void
关闭本地轨道,并释放相关采集设备。
一旦本地轨道被关闭,就无法再次使用。如需再次使用本地轨道,需要重新创建。
# Returns
void
# Inherited from
RemoteTrack.close
# emit
emit(event
, ...args
): boolean
# Parameters
Name | Type |
---|---|
event | string | symbol |
...args | any [] |
# Returns
boolean
# Inherited from
RemoteTrack.emit
# eventNames
eventNames(): (string
| symbol
)[]
# Returns
(string
| symbol
)[]
# Inherited from
RemoteTrack.eventNames
# getListeners
getListeners(event
): Function
[]
指定一个事件名,获取当前所有监听这个事件的回调函数。
# Parameters
Name | Type | Description |
---|---|---|
event | string | 事件名称。 |
# Returns
Function
[]
# Inherited from
RemoteTrack.getListeners
# getMaxListeners
getMaxListeners(): number
# Returns
number
# Inherited from
RemoteTrack.getMaxListeners
# getMediaStreamTrack
getMediaStreamTrack(): MediaStreamTrack
获取浏览器原生的 MediaStreamTrack (opens new window) 对象。
# Returns
MediaStreamTrack
# Inherited from
RemoteTrack.getMediaStreamTrack
# getTrackId
getTrackId(): string
获取由 SDK 生成的对于媒体轨道来说的唯一 ID。
# Returns
string
媒体轨道 ID。
# Inherited from
RemoteTrack.getTrackId
# getTrackLabel
getTrackLabel(): undefined
| string
获取本地轨道的来源描述。
# Returns
undefined
| string
可能返回以下值:
- 如果是通过
createMicrophoneAudioTrack
或createCameraVideoTrack
创建的轨道,返回 MediaDeviceInfo.label (opens new window) 字段。 - 如果是通过
createScreenVideoTrack
创建的轨道,返回屏幕共享的sourceId
。 - 如果是 createCustomAudioTrack 或 createCustomVideoTrack 创建的轨道,返回 MediaStreamTrack.label (opens new window) 字段。
# Inherited from
RemoteTrack.getTrackLabel
# getUserId
getUserId(): string
获取发布远端轨道的远端用户 ID。
# Returns
string
远端轨道对应的 uid
。
# Inherited from
RemoteTrack.getUserId
# getVolumeLevel
getVolumeLevel(): number
获取远端音频轨道的音量等级。
# Returns
number
音量等级值,范围 [0, 1],1 代表理论最大音量。
# listenerCount
listenerCount(event
): number
# Parameters
Name | Type |
---|---|
event | string | symbol |
# Returns
number
# Inherited from
RemoteTrack.listenerCount
# listeners
listeners(event
): Function
[]
# Parameters
Name | Type |
---|---|
event | string | symbol |
# Returns
Function
[]
# Inherited from
RemoteTrack.listeners
# off
off(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.off
# on
on(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.on
# once
once(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.once
# play
play(): void
播放远端音频轨道。
播放音频时 SDK 不会创建任何 DOM 元素,所以无需像视频一样提供 DOM 元素。
# Returns
void
# prependListener
prependListener(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.prependListener
# prependOnceListener
prependOnceListener(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.prependOnceListener
# rawListeners
rawListeners(event
): Function
[]
# Parameters
Name | Type |
---|---|
event | string | symbol |
# Returns
Function
[]
# Inherited from
RemoteTrack.rawListeners
# removeAllListeners
removeAllListeners(event?
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event? | string | symbol |
# Returns
# Inherited from
RemoteTrack.removeAllListeners
# removeListener
removeListener(event
, listener
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
event | string | symbol |
listener | (...args : any []) => void |
# Returns
# Inherited from
RemoteTrack.removeListener
# safeEmit
safeEmit(event
, ...args
): boolean
# Parameters
Name | Type |
---|---|
event | string |
...args | any [] |
# Returns
boolean
# Inherited from
RemoteTrack.safeEmit
# safeEmitAsPromise
safeEmitAsPromise(event
, ...args
): Promise
<any
>
# Parameters
Name | Type |
---|---|
event | string |
...args | any [] |
# Returns
Promise
<any
>
# Inherited from
RemoteTrack.safeEmitAsPromise
# setMaxListeners
setMaxListeners(n
): RemoteAudioTrack
# Parameters
Name | Type |
---|---|
n | number |
# Returns
# Inherited from
RemoteTrack.setMaxListeners
# setPlaybackDevice
setPlaybackDevice(deviceId
): Promise
<void
>
设置音频输出设备,比如扬声器。
该方法只支持 Chrome 浏览器,其他浏览器调用将会抛出
NOT_SUPPORTED
错误。
# Parameters
Name | Type | Description |
---|---|---|
deviceId | string | 设备 ID,可以通过 getPlaybackDevices 方法获取。 |
# Returns
Promise
<void
>
# setVolume
setVolume(volume
): void
设置远端音频轨道的播放音量
# Parameters
Name | Type | Description |
---|---|---|
volume | number | 音量值,范围 [0, 100],0 代表静音,100 代表原始音量。 |
# Returns
void
# stop
stop(): void
停止播放。
# Returns
void
# listenerCount
Static
listenerCount(emitter
, event
): number
deprecated
since v4.0.0
# Parameters
Name | Type |
---|---|
emitter | EventEmitter |
event | string | symbol |
# Returns
number
# Inherited from
RemoteTrack.listenerCount