-1

我想订阅频道中的现有用户。如果用户(主持人)在观众加入并订阅主持人之前发布。远程曲目不播放。client.getClient().on("user-published", async (user, mediaType) => {

4

1 回答 1

0

我找到了解决方案。如果你在这篇文章中,你可以试试下面的代码: 我们可以使用 client.remoteUsers 来获取远程用户。示例代码如下:

if (client.remoteUsers.length > 0) {
  const host = client.remoteUsers[0];
  setState((s) => {
    return {
      ...s,
      statusLive: StatusLive.live,
      isPlayed: true,
    };
  });
  if (host.hasVideo) {
    await client.subscribe(host, "video");
    host.videoTrack?.play(ref.current as HTMLElement);
  }
  if (host.hasAudio) {
    await client.subscribe(host, "audio");
    host.audioTrack?.play();
  }
}
于 2021-09-22T02:28:11.200 回答