OTAcceleratorCoreCTIAfrica 1.1.0

OTAcceleratorCoreCTIAfrica 1.1.0

Samuel K 维护。



 
依赖于
OTKAnalytics= 2.1.0
OpenTok= 2.16.5
SVProgressHUD= 2.2.1
 

logo

Build Status Version Status license MIT Platform PRs Welcome

加速器核 iOS

加速器核为通过 OpenTok 平台将音频/视频通信集成到任何 iOS 应用程序提供了一种简单的方法。您可以轻松完成以下操作:

  • 一对一音频/视频通话
  • 多人音频/视频通话
  • 一对一屏幕共享
  • 多人群屏共享
  • 处理音频/视频启用/禁用的 UI 组件

配置、构建和运行示例应用程序

  1. 获取 API 密钥会话 ID令牌 的值。请参阅 获取 OpenTok 凭据 获取重要信息。

  2. 按照 CocoaPods 入门指南 中的说明安装 CocoaPods。

  3. 在终端中,使用 cd 命令转到您的项目目录,并输入 pod install

  4. 使用新的 *.xcworkspace 文件在 Xcode 中重新打开您的项目。

  5. 将以下空字符串替换为相应的 API 密钥、会话 ID 和令牌值

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        sharedSession = [[OTAcceleratorSession alloc] initWithOpenTokApiKey:@"apikey" sessionId:@"sessionid" token:@"token"];
        return YES;
    }
  6. 使用 Xcode 构建和运行在 iOS 模拟器或设备上的应用程序。

  7. 为了测试音频/视频通信,我们包含了一个简单的网页应用程序,使其更易于使用:Browser-Demo。只需打开它并替换相应的 API 密钥、会话 ID 和令牌值。然后将其保存并加载到浏览器中。对于多人通话,您可以打开多个标签页。

  8. 您可能想要在其他平台上运行

加速器核 JavaScript
加速器核 Android

示例代码

每个通信实例将从 OTOneToOneCommunicatorDataSource 获取 OpenTok 会话,因此这适用于每个通信实例

  • 传递会话

    - (OTAcceleratorSession *)sessionOfOTOneToOneCommunicator:(OTOneToOneCommunicator *)oneToOneCommunicator {
        return <#OTAcceleratorSession#>;
    }
  • 一对一

    self.communicator = [[OTOneToOneCommunicator alloc] init];
    self.communicator.dataSource = self;
    [self.communicator connectWithHandler:^(OTCommunicationSignal signal, NSError *error) {
        if (signal == OTPublisherCreated && !error) {
            weakSelf.communicator.publisherView.frame = CGRectMake(0, 0, 100, 100);
            [self.publisherView addSubview:weakSelf.communicator.publisherView];
        }
        else if (signal == OTSubscriberReady && !error) {
            weakSelf.communicator.subscriberView.frame = CGRectMake(0, 0, 100, 100);
            [self.subscriberView addSubview:weakSelf.communicator.subscriberView];
        }
    }];
  • 多方

    self.communicator = [[OTMultiPartyCommunicator alloc] init];
    self.communicator.dataSource = self;
    [self.communicator connectWithHandler:^(OTCommunicationSignal signal, OTMultiPartyRemote *subscriber, NSError *error) {
        if (signal == OTPublisherCreated && !error) {
            weakSelf.communicator.publisherView.frame = CGRectMake(0, 0, 100, 100);
            [self.publisherView addSubview:weakSelf.communicator.publisherView];
        }
        else if (signal == OTSubscriberReady && !error) {
            subscriber.subscriberView.frame = <#your desired frame for this remote subscriberview#>;
            // your logic to handle multiple remote subscriberview(s)
        }
    }];
  • 屏幕共享

    使用 - (instancetype)initWithView:- (instancetype)initWithView:name:,例如

    self.screenSharer = [[OTOneToOneCommunicator alloc] initWithView:[UIApplication sharedApplication].keyWindow.rootViewController.view];

    或者

    self.screenSharer = [[OTMultiPartyCommunicator alloc] initWithView:[UIApplication sharedApplication].keyWindow.rootViewController.view];
  • 预定义 UI

    启用音频和视频控制

    self.communicator.publisherView.controlView.isVerticalAlignment = YES;
    self.communicator.publisherView.controlView.frame = CGRectMake(10, 10, CGRectGetWidth(self.publisherView.frame) * 0.1, CGRectGetHeight(self.publisherView.frame) * 0.3);

    处理视频启用/禁用控制

    // default
    // enable handleAudioVideo property, the publisherView will be covered by a silhouette automatically.
    self.communicator.publisherView.handleAudioVideo = YES; 
    
    // disable handleAudioVideo property, the publisherView will do nothing for enabling/disabling publishVideo.
    self.communicator.publisherView.handleAudioVideo = NO; 

就绪可用的组件

  • 一对一通信

ready-in-use-2 ready-in-use-3

OTOneToOneCommunicationController *vc = [OTOneToOneCommunicationController oneToOneCommunicationControllerWithSession:<#OTAcceleratorSession#>];
[self.navigationController pushViewController:vc animated:YES];

使用核心的示例应用程序

以下示例应用程序使用 加速器核心

获取 OpenTok 凭证

为了使用 OpenTok 框架,您需要一个 Session ID、Token 和 API Key。您可以在 OpenTok 开发者仪表板 获取这些值。对于生产部署,您必须通过 OpenTok 服务器 SDK 之一生成 Session ID 和 Token 值。

加速器核心作为依赖项

每次您使用任何 OpenTok 加速器时都需要加速器核心。加速器核心是一个通用层,包含所有 OpenTok 一对一通信示例应用程序 中包含的音频-视频通信逻辑,允许所有加速器和样本使用相同的 OpenTok 会话。加速器包和示例应用程序通过通用加速器会话包层访问 OpenTok 会话,这使得它们可以共享单个 OpenTok 会话。

architecture

在Android和iOS移动平台上,当尝试设置监听器(Android)或代理(iOS)时,通常不可能为同一事件设置多个监听器或代理。例如,在这些移动平台上,您只能设置一个OpenTok信号监听器。然而,Common Accelerator Session Pack允许您为同一事件设置多个监听器。