如何在TokBox中连接到用户流 [英] How to connect to user's stream in TokBox

查看:83
本文介绍了如何在TokBox中连接到用户流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TokBox制作一对一的视频通话应用程序.我正在使用以下代码打开会话:

I'm making a 1 on 1 video call app using TokBox. I'm opening a session using this code:

[_ session connectWithApiKey:kApiKey令牌:kToken];

收到didConnect消息后,我正在使用以下代码在一个用户设备上发布流:

after getting the didConnect message i'm publishing a stream on one user device using this code:

    _publisher = [[OTPublisher alloc] initWithDelegate:self];
    [_publisher setName:@"PublishName"];
    [_session publish:_publisher];
    [self.view addSubview:_publisher.view];
    [_publisher.view setFrame:CGRectMake(0, 0, widgetWidth, widgetHeight)];

我需要转移到其他用户以便他看到第一个用户发布的内容吗?我曾尝试过文档,但对我来说真的很不清楚.我需要一个会话ID吗?发布ID?

What do I need to transfer to the other user in order for him to see what the first user publishes? I tried going through the docs but It's really unclear to me. Do I need a session ID? Publish ID?

谢谢.

推荐答案

将会议视为会议室.连接到同一会话的人们将在同一房间内,以便彼此见面.假设您有2部iPhone,分别是A和B.iPhoneA调用 [_ session publish ...] 之后,iPhone B将获得A创建的流事件,其中包含A的视频流.只需订阅该视频流,B便可以将其作为视频观看.

Think of sessions as rooms. People connected to the same session will be in the same room so they are able to see each other. Lets say you have 2 iPhones, A and B. After iPhone A calls [_session publish...], iPhone B will get a stream created event with A's video stream. Simply subscribe to that stream and B should be able to see As video.

您可能想要一个streamCreated委托.在您的streamCreated委托中,只需调用 [session subscription ...] 即可订阅发布流.

You probably want to have a streamCreated delegate. In your streamCreated delegate, simply call [session subscribe...] to subscribe to the publishing stream.

例如,请查看 OpenTok HelloWorld教程.它是一个简单的小组视频聊天,每个人都在彼此发布和订阅.

For an example, check out the OpenTok HelloWorld Tutorial. Its a simple group video chat where everybody is publishing and subscribing to each other.

这篇关于如何在TokBox中连接到用户流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆