pod 'TCICSDK_Pro', '1.8.3.3'
<key>NSCameraUsageDescription</key><key>NSMicrophoneUsageDescription</key><key>NSPhotoLibraryAddUsageDescription</key><key>NSPhotoLibraryUsageDescription</key>
字段 | 类型 | 含义 | 备注 | 必填 |
schoolId | int | 学校编号 | 是 | |
classId | long | 课堂编号 | 是 | |
userId | string | 用户账号 | 是 | |
token | string | 后台鉴权参数 | 是 | |
scene | string | 场景名称 | [roomConfig setValue:@"scene_name" forKey:@"scene"]; | 否 |
lng | string | 语言参数 | 可传入zh-Hans、en,默认为中文(zh-Hans)。可通过此接口设置 [roomConfig setValue:@"en" forKey:@"language"]; | 否 |
camera | int | 初始化开启摄像头 | 1为开启摄像头,0为关闭摄像头,可通过roomConfig.jsParams 设置 | 否 |
mic | int | 初始化开启麦克风 | 1为开启麦克风,0为关闭麦克风,可通过roomConfig.jsParams 设置 | 否 |
speaker | int | 初始化开启扬声器 | 1为开启扬声器,0为关闭扬声器,可通过roomConfig.jsParams 设置 | 否 |
TCICClassConfig *roomConfig = [[TCICClassConfig alloc] init];roomConfig.schoolId = 123456;roomConfig.userId = "test";roomConfig.token = "test_token";roomConfig.classId = 654321;[roomConfig setValue:@"en" forKey:@"language"]; //语言设置,可选[roomConfig setValue:@"scene_name" forKey:@"scene"]; //可根据场景配置不同的定制,可选[roomConfig setValue:@(0) forKey:@"preferPortrait"]; //默认横屏,可选(0 是横屏,1是竖屏)TCICClassController *vc = [TCICClassController classRoomWithConfig:roomConfig];if (vc) {[(UINavigationController *)self.window.rootViewController pushViewController:vc animated:YES];}else {NSLog(@"参数有误");}
[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(yourselector)name:@"TCICExitClassRoomCompleteNotify" object:nil];
App Group
, 参见 TRTC 文档。Broadcast Upload Extension
,参见 TRTC 文档。Target
,依赖依赖 TCICSDK_ReplayKit
,如下,之后重新 pod install
即可。target '新target名' do# Comment the next line if you don't want to use dynamic frameworks# use_frameworks!pod 'TCICSDK_Pro_ReplayKit'end
SampleHandler.m
中,将 APPGROUP
改为第 1 步创建的 App Group
。#import "SampleHandler.h"#import <TXLiteAVSDK_ReplayKitExt/TXLiteAVSDK_ReplayKitExt.h>#import <TCICScreenKit/TCICScreenKit.h>// 注意:此处的 APPGROUP 需要改成上文中的创建的 App Group Identifier。#define APPGROUP ""@interface SampleHandler() <TXReplayKitExtDelegate>@end@implementation SampleHandler- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {[[TXReplayKitExt sharedInstance] setupWithAppGroup:APPGROUP delegate:self];[[TCICScreenKit sharedScreenKit] onScreenKitStarted];}- (void)broadcastPaused {// User has requested to pause the broadcast. Samples will stop being delivered.[[TCICScreenKit sharedScreenKit] onScreenKitPaused];}- (void)broadcastResumed {// User has requested to resume the broadcast. Samples delivery will resume.[[TCICScreenKit sharedScreenKit] onScreenKitResumed];}- (void)broadcastFinished {[[TXReplayKitExt sharedInstance] finishBroadcast];// User has requested to finish the broadcast.[[TCICScreenKit sharedScreenKit] onScreenKitFinished];}#pragma mark - TXReplayKitExtDelegate- (void)broadcastFinished:(TXReplayKitExt *)broadcast reason:(TXReplayKitExtReason)reason{NSString *tip = @"";switch (reason) {case TXReplayKitExtReasonRequestedByMain:tip = @"屏幕共享已结束";break;case TXReplayKitExtReasonDisconnected:tip = @"应用断开";break;case TXReplayKitExtReasonVersionMismatch:tip = @"集成错误(SDK 版本号不相符合)";break;}NSError *error = [NSError errorWithDomain:NSStringFromClass(self.class) code:0 userInfo:@{NSLocalizedFailureReasonErrorKey:tip}];[self finishBroadcastWithError:error];}- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType: (RPSampleBufferType)sampleBufferType {switch (sampleBufferType) {case RPSampleBufferTypeVideo:[[TXReplayKitExt sharedInstance] sendVideoSampleBuffer:sampleBuffer];break;case RPSampleBufferTypeAudioApp:// Handle audio sample buffer for app audiobreak;case RPSampleBufferTypeAudioMic:// Handle audio sample buffer for mic audiobreak;default:break;}}@end
TCICClassConfig *roomConfig = [[TCICClassConfig alloc] init];roomConfig.userId = "test";roomConfig.token = "test_token";roomConfig.classId = 123454;roomConfig.schoolId = xxxxx;// 通过KVC方式设置AppGroup[roomConfig setValue:@"group.com.xx.xxxx" forKey:@"appGroup"];
Scenedelegate
,可参见 Xcode 11 删除 Scenedelegate,进行移除。以 Demo 为例,弹出效果如下,单击开始直播即可。Broadcast Upload Extension
进行触发,下图以腾讯会议为例:Upload Extension
的 Deployment target
配置在 iOS 11.0
(Replay Kit
于 iOS11
才开始支持),调试时真机也尽量在 iOS11
之后。 Background Modes
。
本页内容是否解决了您的问题?