gpt4 book ai didi

ios - iOS Objective C 中的 Tokbox 屏幕共享开/关切换

转载 作者:行者123 更新时间:2023-11-29 11:59:12 25 4
gpt4 key购买 nike

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

我可以切换到设备屏幕共享,但在共享屏幕后我无法切换回设备 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];
}
}

最佳答案

看起来您在关闭屏幕捕获时可能没有设置任何视频捕获器。这一行:

        _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;
}
}

关于ios - iOS Objective C 中的 Tokbox 屏幕共享开/关切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37763898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com