AgoraEduMediaContext
AgoraEduMediaContext
类。
AgoraEduMediaContext
类提供的方法用于:
-
管理本地音视频设备。
-
播放本地音频。
-
渲染本地视频。
getLocalDevices
获取本地设备。
Array<AgoraEduContextDeviceInfo> getLocalDevices(deviceType AgoraEduContextDeviceType)
参数
参数名 | 描述 |
---|---|
deviceType | 设备类型。详见 |
返回值
由 AgoraEduContextDeviceInfo
组成的设备列表。
openLocalDevice
开启指定本地设备。
AgoraEduContextError openLocalDevice(AgoraEduContextDeviceInfo device)
参数
参数名 | 描述 |
---|---|
device | 设备信息,详见 |
返回值
如果传入的 deviceId
不存在,则返回 AgoraEduContextError
。
openLocalDevice
开启指定本地设备。
AgoraEduContextError openLocalDevice(AgoraEduContextSystemDevice device)
参数
参数名 | 描述 |
---|---|
device | 系统设备枚举,详见 |
closeLocalDevice
关闭本地设备。
AgoraEduContextError closeLocalDevice(AgoraEduContextDeviceInfo device)
参数
参数名 | 描述 |
---|---|
device | 设备信息,详见 |
返回值
如果传入的 deviceId
不存在,则返回 AgoraEduContextError
。
closeLocalDevice
关闭本地设备。
AgoraEduContextError closeLocalDevice(AgoraEduContextSystemDevice device)
参数
参数名 | 描述 |
---|---|
device | 系统设备枚举,详见 |
返回值
调用失败,则返回 AgoraEduContextError
。
getLocalDeviceState
获取本地设备状态。
void getLocalDeviceState(AgoraEduContextDeviceInfo device,
Callback<AgoraEduContextDeviceState> success,
Callback<AgoraEduContextError> fail)
参数
参数名 | 描述 |
---|---|
device | 设备信息,详见 |
success | 调用成功,则返回设备状态 |
fail | 调用失败,则返回 |
startRenderVideo
开始渲染视频流。
AgoraEduContextError startRenderVideo(View view,
AgoraEduContextRenderConfig config,
String streamUuid)
该方法在加入房间前后均可调用。如果你想要在加入房间前预览摄像头采集的视频流,可将 streamUuid
设为 0。
参数
参数名 | 描述 |
---|---|
config | 视频渲染配置,详见 |
view | 渲染的 View。 |
streamUuid | 待渲染的流 ID。 |
返回值
调用失败,则返回 AgoraEduContextError
。
startRenderVideo
开始渲染视频流。
AgoraEduContextError startRenderVideo(String roomUuid,
View view,
AgoraEduContextRenderConfig config,
String streamUuid)
该方法只能在加入房间后调用。
参数
参数名 | 描述 |
---|---|
roomUuid | 房间 ID。 |
config | 视频渲染配置,详见 |
view | 渲染的 View。 |
streamUuid | 待渲染的流 ID。 |
返回值
调用失败,则返回 AgoraEduContextError
。
startRenderVideoFromCdn
开始渲染 CDN 视频流。
AgoraEduContextError startRenderVideoFromCdn(View view,
AgoraEduContextVideoRenderMode mode,
String streamUrl)
参数
参数名 | 描述 |
---|---|
view | 渲染的 View。 |
mode | 渲染模式,详见 |
streamUrl | CDN 流地址。 |
返回值
调用失败,则返回 AgoraEduContextError
。
stopRenderVideo
停止渲染视频流。
AgoraEduContextError stopRenderLocalVideo(String streamUuid)
该方法在加入房间前后均可调用。
参数
参数名 | 描述 |
---|---|
streamUuid | 流 ID。如果你想要在加入房间前停止预览摄像头采集的视频流,可将 |
返回值
调用失败,则返回 AgoraEduContextError
。
stopRenderVideo
停止渲染视频流。
AgoraEduContextError stopRenderVideo(String roomUuid, String streamUuid) 该方法只能在加入房间后调用。
参数
roomUuid房间 ID。streamUuid流 ID。如果你想要在加入房间前停止预览摄像头采集的视频流,可将 streamUuid
设为 0。
返回值
调用失败,则返回 AgoraEduContextError
。
stopRenderVideoFromCdn
停止渲染 CDN 视频流。
AgoraEduContextError stopRenderVideoFromCdn(String streamUrl)
参数
参数名 | 描述 |
---|---|
streamUrl | CDN 流地址。 |
返回值
调用失败,则返回 AgoraEduContextError
。
startAudioMixing
开始混音。
AgoraEduContextError startAudioMixing(String filePath,
Boolean loopback,
Boolean replace,
Int cycle)
将麦克风采集的音频流与本地客户端的音乐文件中的音频混合,以便远端用户能更为清晰地听到该音乐文件。
参数
参数名 | 描述 |
---|---|
filePath | 需要进行混音的音乐文件路径。 |
loopback | 是否只在本地客户端播放音乐文件。 |
replace | 是否将麦克风采集的音频替换为音乐文件。 |
cycle | 音乐文件的播放次数。设为 -1 表示循环播放。 |
返回值
调用失败,则返回 AgoraEduContextError
。
stopAudioMixing
startPlayAudio
开始播放音频流。
AgoraEduContextError startPlayAudio(String roomUuid,
String streamUuid)
参数
参数名 | 描述 |
---|---|
roomUuid | 房间 ID。 |
streamUuid | 流 ID。 |
返回值
调用失败,则返回 AgoraEduContextError
。
startPlayAudioFromCdn
开始播放 CDN 音频流。
AgoraEduContextError startPlayAudioFromCdn(String streamUrl)
参数
参数名 | 描述 |
---|---|
streamUuid | CDN 流地址。 |
startPos | 开始播放的位置。 |
返回值
调用失败,则返回 AgoraEduContextError
。
stopPlayAudio
停止播放音频流。
AgoraEduContextError stopPlayAudio(String roomUuid,
String streamUuid)
参数
参数名 | 描述 |
---|---|
roomUuid | 房间 ID。 |
streamUuid | 流 ID。 |
返回值
调用失败,则返回 AgoraEduContextError
。
stopPlayAudioFromCdn
停止播放 CDN 音频流。
AgoraEduContextError stopPlayAudioFromCdn(String streamUrl)
参数
参数名 | 描述 |
---|---|
streamUrl | CDN 流地址。 |
setAudioMixingPosition
设置用于混音的音乐文件的起始播放位置。
AgoraEduContextError setAudioMixingPosition(Int position)
参数
参数名 | 描述 |
---|---|
position | 音乐文件的起始播放位置(毫秒)。 |
返回值
调用失败,则返回 AgoraEduContextError
。
getSnapshot
视频流截图。
void getSnapshot(String roomUuid,
String streamUuid,
String filePath,
Callback<FcrSnapshotInfo> success,
Callback<AgoraEduContextError> failure)
从视频流中截图,生成 JPG 文件。每次调用此 API 需间隔至少一秒。
参数
参数名 | 描述 |
---|---|
roomUuid | 房间 ID。 |
streamUuid | 流 ID |
filePath | 保存截图的本地绝对路径。需完整写出文件名,例如 xxx/xxx/example.jpg。 |
success | 调用成功,则返回截图信息 |
fail | 调用失败,则返回 |
setAudioRawDataConfig
设置音频管道中每个环节的输出配置。
FcrError setAudioRawDataConfig(FcrAudioRawDataConfig config,
FcrAudioRawDataPosition position)
可添加多个观察者,以最后一次设置为准。
参数
参数名 | 描述 |
---|---|
config | 观察者,详见 |
position | 音频管道的输出位置,详见 |
addAudioRawDataObserver
注册音频管道某个环节的原始数据监听。
FcrError addAudioRawDataObserver(FcrAudioRawDataObserver observer,
FcrAudioRawDataPosition position)
参数
参数名 | 描述 |
---|---|
observer | 观察者,详见 |
position | 音频管道的输出位置,详见 |
removeAudioRawDataObserver
移除音频管道某个环节的原始音频数据监听。
FcrError removeAudioRawDataObserver(FcrAudioRawDataObserver observer,
FcrAudioRawDataPosition position)
参数
参数名 | 描述 |
---|---|
observer | 观察者,详见 |
position | 音频管道的输出位置,详见 |