# 设备操作

# 音视频状态有两种active表示活跃,inactive表示停止.

# 禁用音频输入

使用Promise (opens new window)Manis.disableLocalAudio()禁用本地音频输入,

返回一个Promise对象实例

示例:

Manis.disableLocalAudio().then(res => {
    console.log('本地输入静音成功: ', res)
}).catch(err => {
    console.error('本地输入静音失败: ', err)
})

# 启用音频输入

使用Promise (opens new window)Manis.enableLocalAudio()启用本地音频输入,

返回一个Promise对象实例

示例:

Manis.enableLocalAudio().then(res => {
    console.log('取消本地静音成功: ', res)
}).catch(err => {
    console.error('取消本地静音失败: ', err)
})

# 禁用视频输入

使用Promise (opens new window)Manis.disableLocalVideo()禁用本地视频输入,

返回一个Promise对象实例

示例:

Manis.disableLocalVideo().then(res => {
    console.log('暂停本地视频输入成功: ', res)
}).catch(err => {
    console.error('暂停本地视频输入失败: ', err)
})

# 启用视频输入

使用Promise (opens new window)Manis.enableLocalVideo()启用本地视频输入,

返回一个Promise对象实例

示例:

Manis.enableLocalVideo().then(res => {
    console.log('激活本地视频输入成功: ', res)
}).catch(err => {
    console.error('激活本地视频输入失败: ', err)
})

# 音视频开关状态通知

使用Manis.onStreamStatusChange()捕获音视频开关状态通知, 包含本地和远端的音视频开关状态变化.

接收一个CallBack捕获变化事件通知

示例:

Manis.onStreamStatusChange(resp => {
  console.log('捕获媒体资源状态变化: ', resp);
  // {
  //   data: {field: "audio.status", value: "inactive", participantId: "用户在频道中标识,在加入频道是返回和用户状态变化中获取的"}
  //   kind: "audio"
  //   type: "mute"
  // }
})

# 获取音频输入设备

使用Manis.getMicrophones()获取音频输入设备,

返回一个音频输入列表

示例:

const list = Manis.getMicrophones()
console.log('获取到音频输入设备: ', list)

# 获取视频输入设备

使用Manis.getCameras()获取视频输入设备,

返回一个音频输入列表

示例:

const list = Manis.getCameras()
console.log('获取到视频输入设备: ', list)

# 获取音频输出设备

使用Manis.getSpeakers()获取音频输出设备,

返回一个音频输入列表

示例:

const list = Manis.getSpeakers()
console.log('获取到扬声器设备: ', list)

# 创建本地音频对象

使用Promise (opens new window)Manis.createMicrophoneAudioTrack()构建本地音频资源, 此资源可以通过Manis.publish推送到频道中,接收可选参数audioConstraints (opens new window)

返回一个Promise对象实例

示例:

const options = {
  deviceId: 'xxxxxxxxxxxxxxxxxx'
}

Manis.createMicrophoneAudioTrack(options).then(res => {
    console.log('构建本地音频媒体成功: ', res)
}).catch(err => {
    console.error('构建本地音频媒体失败: ', err)
})

# 创建本地视频对象

使用Promise (opens new window)Manis.createCameraVideoTrack()构建本地视频资源, 此资源可以通过Manis.publish推送到频道中,接收可选参数videoConstraints (opens new window)

返回一个Promise对象实例

示例:

const options = {
  deviceId: 'xxxxxxxxxxxxxxxxxx',
  height: '180',
  width: '320',
  frameRate: '30'
}

Manis.createCameraVideoTrack(options).then(res => {
    console.log('构建本地视频媒体成功: ', res)
}).catch(err => {
    console.error('构建本地视频媒体失败: ', err)
})