AgoraIO-Community / Angular-Agora-RTC

11 stars 16 forks source link

Config with one-to-many #14

Open victjam opened 4 years ago

victjam commented 4 years ago

I have so much problems to run agora.io broadcast, the user enter to the link but instead to enter on the channel of the person who is broadcasting, is creating another channel.

I need to know how can I create a channel and another user enter to this channel.

I'm doing this.

this is my 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);
    });
  }
} 

and this is my app.html


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