stream-added 永远不会被 agora.io 触发
stream-added never gets triggered with 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 local
,但 SHAMOON added stream
永远不会被调用。我做错了什么?
stream-added
回调仅在频道添加远程流时触发。您要监听的事件是 stream-published
事件,即本地流添加到频道时的事件。
this.agoraClient.on('stream-published', function (evt) {
console.log("local stream published successfully");
});
我有:
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
永远不会被调用。我做错了什么?
stream-added
回调仅在频道添加远程流时触发。您要监听的事件是 stream-published
事件,即本地流添加到频道时的事件。
this.agoraClient.on('stream-published', function (evt) {
console.log("local stream published successfully");
});