Twilio 视频——没有视频和静音方法 [英] Twilio video -- no video and mute methods

查看:30
本文介绍了Twilio 视频——没有视频和静音方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何使本地参与者静音和不录像?https://www.twilio.com/docs/api/video/getting-开始

How do you mute and no-video the local participant? https://www.twilio.com/docs/api/video/getting-started

此代码已在别处提出 - 但这是轨道数据吗?

this code has been proposed elsewhere - but is this the track data?

var localMedia = conversation.localMedia;
localMedia.mute();

那么我会得到当地参与者的踪迹吗

So would I get the tracks of the local participant

var tracks = Array.from(participant.tracks.values())

audioTrack.mute()?videoTrack.mute()?

audioTrack.mute()? videoTrack.mute()?

document.getElementById('button-mute').onclick = function () {
  log('Mute call...')
  console.log('mute call')
  // var localMedia = conversation.localMedia
  // localMedia.mute()
}
document.getElementById('button-no-video').onclick = function () {
  log('No Vid call...')
  console.log('no vid')
}

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

您实际上想使用 禁用本地媒体轨道上的方法将它们静音.

You actually want to use the disable method on the local media tracks to mute them.

首先,确保您使用的是 Twilio Video Rooms API(您在问题中提到了 conversation,对话 API 已弃用).

First, make sure you're using the Twilio Video Rooms API (you mention conversation in the question, the conversations API is deprecated).

然后,当您连接时,您可以获取本地参与者的媒体轨道,并根据需要禁用或启用它们.像这样:

Then, when you connect you can get hold of the local participants media tracks and disable or enable them when you like. Something like this:

Video.connect(token, { name: 'room-name' }).then(room => {
  const localParticipant = room.localParticipant;

  $button.on('click', event => {
    localParticipant.tracks.forEach((trackId, track) => {
      if (track.isEnabled) {
        track.disable();
      } else {
        track.enable();
      }
    })
  })
});

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于Twilio 视频——没有视频和静音方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆