【问题标题】:Tokbox Screen Sharing On/Off Toggle in iOS Objective CiOS Objective C 中的 Tokbox 屏幕共享开/关切换
【发布时间】:2016-06-11 12:46:57
【问题描述】:

我想使用 Tokbox 在 iOS 中提供屏幕共享 On/Off 功能。

我可以切换到设备屏幕共享,但共享屏幕后我无法切换回设备 Camara。

我已尝试使用以下代码。

-(void)toogleScreen{
    if (isSharingEnable == YES) {
        isSharingEnable = NO;
        NSLog(@"%@",_publisher.description);

        _publisher.videoCapture = nil;
        [_publisher setVideoType:OTPublisherKitVideoTypeCamera];
       _publisher.audioFallbackEnabled = YES;
    } else {
        isSharingEnable = YES;
          [_publisher setVideoType:OTPublisherKitVideoTypeScreen];
        _publisher.audioFallbackEnabled = NO;

         TBScreenCapture* videoCapture =
        [[TBScreenCapture alloc] initWithView:self.view];
        [_publisher setVideoCapture:videoCapture];
    }
}

【问题讨论】:

标签: ios objective-c opentok tokbox screensharing


【解决方案1】:

您在关闭屏幕捕捉时似乎没有设置任何视频捕捉器。这一行:

        _publisher.videoCapture = nil;

具有不必要的破坏性。尝试保留对相机和屏幕捕获器的内部引用,并在 toggleScreen 函数之外对其进行初始化:

@implementation MyPublisher {
  id <OTVideoCapture> _cameraCapture;
  id <OTVideoCapture> _screenCapture;
}

然后,将您的切换方法更改为:

-(void)toogleScreen{
    if (isSharingEnable == YES) {
        isSharingEnable = NO;
        [_publisher setVideoCapture:_cameraCapture];
        [_publisher setVideoType:OTPublisherKitVideoTypeCamera];
       _publisher.audioFallbackEnabled = YES;
    } else {
        isSharingEnable = YES;
        [_publisher setVideoCapture:_screenCapture];
        [_publisher setVideoType:OTPublisherKitVideoTypeScreen];
        _publisher.audioFallbackEnabled = NO;    
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多