【问题标题】:Agora.io problems with angular 8 and live broadcastAgora.io Angular 8 和直播的问题
【发布时间】:2019-10-09 03:09:45
【问题描述】:

我在运行 agora.io 广播时遇到很多问题,用户进入链接,而是进入正在广播的人的频道,正在创建另一个频道。

我需要知道如何创建频道并让其他用户进入该频道。

我正在这样做。

这是我的 app.ts

  title = 'agorademo';
  localStream: Stream // Add
  constructor(private agoraService: AngularAgoraRtcService) {
    this.agoraService.createClient();
  }

  startCall() {
    this.agoraService.client.join(null, '1000', null, (uid) => {
      this.localStream = this.agoraService.createStream(uid, true, null, null, true, false);
      this.localStream.setVideoProfile('720p_3');
      this.subscribeToStreams();
    });
  }

  private subscribeToStreams() {
    this.localStream.on("accessAllowed", () => {
      console.log("accessAllowed");
    });
    // The user has denied access to the camera and mic.
    this.localStream.on("accessDenied", () => {
      console.log("accessDenied");
    });

    this.localStream.init(() => {
      console.log("getUserMedia successfully");
      this.localStream.play('agora_local');
      this.agoraService.client.publish(this.localStream, function (err) {
        console.log("Publish local stream error: " + err);
      });
      this.agoraService.client.on('stream-published', function (evt) {
        console.log("Publish local stream successfully");
      });
    }, function (err) {
      console.log("getUserMedia failed", err);
    });
  }
} 

这是我的 app.html

<div id="agora_local"> </div>
<button (click)="startCall()">Start Call</button> ```

【问题讨论】:

    标签: typescript streaming broadcast live


    【解决方案1】:

    我被困在同一个问题上几个小时,我不知道为什么他们没有在 angular-agora-rtc 文档或 ngx-agora 中提到,但正如 Agora API 文档中所述,角色需要设置为主持人或观众

    client.setClientRole(role)
    

    对于主持人,您创建本地流并发布它,对于观众,您只需加入频道。 参考这里, https://docs.agora.io/en/Video/start_live_web

    【讨论】:

      【解决方案2】:

      而不是这个:

      this.agoraService.client.join(null, '1000', null, (uid)
      

      使用:

      this.agoraService.client.join(token, channel_name, null, (uid)
      

      【讨论】:

      • 请尝试解释为什么要进行更改,或者原始代码有什么问题。而不是仅仅显示它应该被改变成什么。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 2020-05-29
      • 1970-01-01
      相关资源
      最近更新 更多