添加的流永远不会被 agora.io 触发

我有:


        this.agoraClient = AgoraRTC.createClient({ mode: "rtc", codec: "h264" })


        this.agoraClient.on('stream-added', (evt) => {

            console.log('SHAMOON added stream', evt)

            this.remoteStream = evt.stream

            this.agoraClient.subscribe(this.remoteStream)

        })



        this.agoraClient.on('stream-subscribed', (evt) => {

            console.log('SHAMOON subscribed stream', evt)

            this.remoteStream.play(this.remoteHtmlElementId, { muted: true });

        })

        await new Promise((resolve, reject) => this.agoraClient.init(this.appId, resolve, reject))

        await new Promise((resolve, reject) => this.agoraClient.join(null, this.channelName, this.uid, resolve, reject))


        this.localStream = AgoraRTC.createStream({

            streamID: this.uid,

            audio: true,

            video: false,

            screen: false

        })



        await new Promise(this.localStream.init)

        this.localStream.play(this.localHtmlElementId, { muted: true })

        console.log('playing local')



        this.agoraClient.publish(this.localStream)

        console.log('publishing local')

它到达了,但永远不会被调用。我做错了什么?publishing localSHAMOON added stream


森栏
浏览 106回答 1
1回答

有只小跳蛙

仅当将远程流添加到通道时,才会触发回调。要侦听的事件是将本地流添加到通道时的事件。stream-addedstream-publishedthis.agoraClient.on('stream-published', function (evt) {  console.log("local stream published successfully");});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript