视频设备管理
介绍跟视频设备管理相关的方法和回调。
getDeviceInfo
获取当前设备名称。
- (AgoraRtcDeviceInfo * _Nullable)getDeviceInfo:(AgoraMediaDeviceType)type;
详情
该方法通过 type 参数获取当前音、视频采集或播放设备。
参数
- type
-
设备的类型,包括音、视频采集或播放设备,详见 AgoraMediaDeviceType。
返回值
- 调用成功时,返回 AgoraRtcDeviceInfo
- 调用失败时,返回
nil
getDeviceVolume
获取当前设备的音量。
- (int)getDeviceVolume:(AgoraMediaDeviceType)type;
参数
- type
-
设备的类型,包括音、视频采集或播放设备,详见 AgoraMediaDeviceType。
返回值
- 调用成功,返回设备的音量
- < 0: 方法调用失败
monitorDeviceChange
监测设备变化。
- (void)monitorDeviceChange:(BOOL)enabled;
详情
该方法用来开启设备插拔监测,这里设备指的是音视频外接设备,比如外接摄像头等。
参数
- enabled
- 是否开启监测:
YES
: 开启。NO
: 关闭。
setDevice
指定设备。
- (int)setDevice:(AgoraMediaDeviceType)type deviceId:(NSString * _Nonnull)deviceId;
参数
- type
-
设备的类型,包括音、视频采集或播放设备,详见 AgoraMediaDeviceType。
- deviceId
- 设备 ID。可通过 enumerateDevices 获取。插拔设备不会影响 deviceId。
返回值
- 0: 方法调用成功。
- < 0: 方法调用失败。
setDeviceVolume
设置设备音量。
- (int)setDeviceVolume:(AgoraMediaDeviceType)type volume:(int)volume;
详情
设置音、视频采集或播放设备的音量。
注意: 该方法需要在加入频道后调用。
参数
- type
-
设备的类型,包括音、视频采集或播放设备,详见 AgoraMediaDeviceType。
- volume
- 设备音量。取值范围 [0,255]。0 表示无声,255 表示最大音量。
返回值
- 0:方法调用成功。
- < 0:方法调用失败。
stateChanged
设备状态改变回调。
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine device:(NSString* _Nonnull)deviceId type:(AgoraMediaDeviceType)deviceType stateChanged:(NSInteger)state;
详情
参数
- engine
- AgoraRtcEngineKit 对象。
- deviceId
- 设备 ID。
- deviceType
-
设备的类型,包括音、视频采集或播放设备,详见 AgoraMediaDeviceType。
- state
-
设备状态:
- 0:设备插入,但未使用。
- 1:设备正在使用。
- 8:设备被拔出。