如何在Agora.io中全球访问Camara和麦克风

问题描述 投票:0回答:1

[我将Angular 7Angora.Io结合使用,我的问题是当我在本地运行Angular项目时,我可以成功访问摄像机和麦克风,但是当我尝试像“ 192.105.2.448”一样在全球范围内运行时,我不知道无法访问我的相机和麦克风,并会引发类似错误。请帮助我!

join(): void {

    this.client.setClientRole('host');
    this.localStream = this.agoraService.createStream({ streamID: this.uid, audio: true, video: true, screen: false });
    this.localStream.setVideoProfile('720p_3');
    this.assignLocalStreamHandlers();
    this.init();
    this.client.join(null , this.channel.value, this.uid);
}

publish(): void {

    this.liveplay = true;
    this.client.publish(this.localStream, err =>   console.log('Publish local stream error: ' + err));  }

protected init(): void {

    this.localStream.init(
        () => {
            // The user has granted access to the camera and mic.
            console.log('getUserMedia successfully' , this.localStream);
            this.localStream.play('agora_local');
            this.connected = true;
        },
        err => console.log('getUserMedia failed', err)
    );
}


private assignLocalStreamHandlers(): void {

    console.log('==========>>>>>>>2 ');
    this.localStream.on(StreamEvent.MediaAccessAllowed, () => {
        console.log('accessAllowed --->>> ', this.localStream);
    });
    // The user has denied access to the camera and mic.
        this.localStream.on(StreamEvent.MediaAccessDenied, () => {
        console.log('accessDenied');
    });
}

11:35:01:76 Agora-SDK [错误]:[3]媒体访问NOT_SUPPORTED:仅允许安全来源

[Deprecation] getUserMedia()不再适用于不安全的来源。要使用此功能,应考虑将应用程序切换到安全来源,例如HTTPS。

angular7 agora.io
1个回答
0
投票

我不喜欢Angular,但自agora起,提供了一些有关自定义音频/视频源的api。您可以检查https://docs.agora.io/en/Interactive%20Broadcast/custom_video_web?platform=Web

© www.soinside.com 2019 - 2024. All rights reserved.