【问题标题】:When two people join my Twilio Video room, only one participant receives audio and video? [closed]当两个人加入我的 Twilio 视频房间时,只有一个参与者接收音频和视频? [关闭]
【发布时间】:2020-10-28 06:19:08
【问题描述】:

每次参与者 2 出现时,他们的音频和摄像记录都会显示在参与者 1 的屏幕上。但是参与者 1 的音频/视频没有显示在参与者 2 的屏幕上。那么谁是第一个加入他们的视频和音频的人不会传输给其他参与者?

<h1>Hi there!</h1>
<div class="videos">
  <div id="video-container"></div>
</div>
<div id="remote-media-div">
</div>



<?php
include('./vendor/autoload.php');
include('./config.php');

use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\VideoGrant;

// Use identity and room from query string if provided

$identity = isset($_GET["identity"]) ? $_GET["identity"] : "identity" . rand();
$room = isset($_GET["room"]) ? $_GET["room"] :  "testingreal";

// Create access token, which we will serialize and send to the client
$token = new AccessToken(
    $TWILIO_ACCOUNT_SID,
    $TWILIO_API_KEY,
    $TWILIO_API_SECRET,
    3600,
    $identity
);

// Grant access to Video
$grant = new VideoGrant();
$grant->setRoom($room);
$token->addGrant($grant);

echo $token->toJWT();

?>



<script src="//media.twiliocdn.com/sdk/js/video/releases/2.7.3/twilio-video.min.js"></script>

<script>

var Video = Twilio.Video;
console.log(Video);


var connect = Video.connect;

Video.connect('<?=$token->toJWT()?>', { name: 'testingreal' }).then(room => {
  console.log('Conmnected to Room "%s"', room.name);

    room.on('participantConnected', participant => {
    console.log(`Participant "${participant.identity}" connected`);
    console.log('testing 213');

    participant.tracks.forEach(publication => {

        if (publication.isSubscribed) {
        const track = publication.track;
        document.getElementById('remote-media-div').appendChild(track.attach());
        }
    });

    participant.on('trackSubscribed', track => {
        document.getElementById('remote-media-div').appendChild(track.attach());
    });
    });  


});

我在 room.on('participantConnected',participant => { //code } 中插入的日志在我第一次作为参与者 1 加入房间时没有显示。但是我注意到一旦参与者 2 显示了日志确实出现了。所以我想知道如何将 room.on('participantConnected') 代码设置为在第一个参与者加入时执行,而不是第二个。

【问题讨论】:

    标签: javascript php twilio twilio-php


    【解决方案1】:

    Twillio 视频只是基于点对点连接。 一个房间内超过 2~4 个以上的用户应该基于 SFU 和 MCU 方法。

    这里是更多详细信息的链接。

    • [ https://medium.com/linagora-engineering/scalability-in-video-conferencing-part-1-276f52b4acac ]​​i>

    p2p 连接始终适用于 1:1 连接,但正如您在上面的文章中看到的那样,它应该基于 SFU 或 MCU 以超过 3 个参与者。 其实hangout和zoom也是基于MCU的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 2019-03-02
      • 2019-12-22
      • 2019-03-24
      • 2018-05-30
      相关资源
      最近更新 更多