【问题标题】:Videocall from Web SDK to iOS SDK从 Web SDK 到 iOS SDK 的视频通话
【发布时间】:2019-07-17 09:02:35
【问题描述】:

WebSDK 不接收来自 iOS SDK 的发布流

目前,我已经完成了基于 WebSDK 的视频通话。 User1 加入 chatX 并发布他的流。 User2 通过 chatX 中的“stream-added”事件接收到这个流并成功订阅它。 但是当 user1 从 iOS 应用加入视频聊天时,“添加流”事件不会触发。

        client.on('stream-added', function (evt) {
            var stream = evt.stream;
            console.log("New stream added: " + stream.getId());
            console.log("Subscribe ", stream);
            client.subscribe(stream, function (err) {
                console.log("Subscribe stream failed", err);
            });
        });

        client.on('stream-subscribed', function (evt) {
            var stream = evt.stream;
            console.log("Subscribe remote stream successfully: " + stream.getId());
            if ($('#videochat-remoteVideo #agora_remote'+stream.getId()).length === 0) {
                $('#videochat-remoteVideo').append('<div id="agora_remote'+stream.getId()+'"></div>');
            }
            remoteBigLocalSmall();
            stream.play('agora_remote' + stream.getId());
        });

iOS 应用接收从 Web 发布的流,而 Web 客户端不接收来自 iOS 客户端的流。

我的实施可能有什么问题?如何从 iOS 客户端接收流?

更新: 加入聊天代码:

user_id = '111';
client.join(channel_key, videochat_id, user_id, function(uid) {
...

我已将 user_id 类型从 string 更改为 int,现在它可以工作了。我不明白为什么,因为文档允许字符串 uid:

join(tokenOrKey: string | null, channel: string, uid: number | string | null, onSuccess?: 函数, onFailure?: 函数): void

【问题讨论】:

  • 您使用的是哪个版本的 Agora.io Web SDK?
  • @Hermes,最新,2.8
  • 您确定在 iOS 上启用 WebInteroperabilityMode 了吗? docs.agora.io/en/Voice/API%20Reference/oc/Classes/…:
  • iOS 开发者说这个选项被禁用了
  • WebInteroperabilityMode 需要设置为启用。

标签: agora.io


【解决方案1】:

您面临的问题与您使用了错误的 API 方法有关。您正在使用 joinChannelByToken,它仅在您应该使用 joinChannel(byUserAccount: ...) 时适用于整数值,因为它将字符串 uid 作为参数。

let myStringId = "someStringId"
agoraKit.joinChannel(byUserAccount: myStringId, token: nil, channelId: "demoChannel1") { (sid, uid, elapsed) in
    // Did join channel "demoChannel1"
}

【讨论】:

    【解决方案2】:

    将 client.join 方法参数 uid 从字符串更改为整数解决了问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-18
      • 2020-09-23
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多