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

Posted

技术标签:

【中文标题】流添加永远不会被 agora.io 触发【英文标题】:stream-added never gets triggered with agora.io 【发布时间】:2020-05-16 20:31:20 【问题描述】:

我有:

        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 local,但SHAMOON added stream 永远不会被调用。我做错了什么?

【问题讨论】:

【参考方案1】:

stream-added 回调仅在向频道添加远程流时触发。您要监听的事件是stream-published 事件,即本地流添加到频道时。

this.agoraClient.on('stream-published', function (evt) 
  console.log("local stream published successfully");
);

【讨论】:

以上是关于流添加永远不会被 agora.io 触发的主要内容,如果未能解决你的问题,请参考以下文章

messages().onNotificationOpenedApp 永远不会被触发,messaging().getInitialNotification() 被触发但 remoteMessage 始

SystemVolumeDidChangeNotification 永远不会在 iOS 14 上触发

UISwipeGestureRecognizer 没有触发

Android Facebook 登录回调永远不会触发

为啥 Qt mouseReleaseEvent 不会触发?

Rails WebSocket 客户端永远不会触发 OnOpen