Real time streaming by using IVS Stage

0

In the context of our server side composition for broadcasting stage to an IVS channel, how can we display the participant's name when they choose to hide their camera?

Ramesh
質問済み 5ヶ月前181ビュー
1回答
1
承認された回答

One way to accomplish this is to create a separate LocalStageStream and swap to that instead of calling setMuted.

toggleCamMute() {
  if (!this.isCamMuted) {
    const canvas = document.createElement('canvas');
    canvas.width = 1280;
    canvas.height = 720;
    const ctx = canvas.getContext("2d");
    ctx.font = "30px Arial";
    ctx.fillStyle = "white";
    ctx.textAlign = "center";
    ctx.fillText("Todd", canvas.width / 2, canvas.height / 2); // make text dynamic as necessary
    const stream = canvas.captureStream();
    this.mutedLocalVideoStream = new LocalStageStream(stream.getVideoTracks()[0]);
    console.log(this.mutedLocalVideoStream);
  }
  else {
    this.mutedLocalVideoStream = null;
  }
  //this.localVideoStream.setMuted(!this.isCamMuted); not necessary, we're swapping the source track instead
  this.isCamMuted = !this.isCamMuted;
  this.stage.refreshStrategy();
}

In your stage strategy, check for the isCamMuted flag and swap the video stream accordingly.

stageStreamsToPublish: () => {
  const videoTrack = this.videoStream.getVideoTracks()[0];
  const audioTrack = this.audioStream.getAudioTracks()[0];
  this.localAudioStream = new LocalStageStream(audioTrack);
  this.localVideoStream = new LocalStageStream(videoTrack);
  const streamsToPublish = [
    this.localAudioStream, 
    this.isCamMuted ? 
      this.mutedLocalVideoStream : this.localVideoStream
  ];
  return streamsToPublish;
}
profile picture
回答済み 5ヶ月前
  • Thank you sir

  • Anytime! Glad to help.

  • I have also shared a request for a more programatic solution to this problem.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ