TUIRoomKit
屏幕共享功能,帮助您更好地掌握TUIRoomKit
会议过程中的屏幕共享相关功能操作。通过本文档,您能够充分利用TUIRoomKit
的功能,实现高质量的音视频会议。 若 TUIRoomKit 的 UI 交互不满足您的产品需求,您有自己的交互和业务逻辑需要自定义实现屏幕共享 相关的交互功能,可以接入 TUIRoomEngineSDK 调用来实现您的需求。Android&iOS&Flutter
端用户进入房间后,通过点击底部工具栏共享按钮,可以实现屏幕共享操作。屏幕分享 | | |
| | |
import ReplayKitimport TXLiteAVSDK_ReplayKitExtlet APPGROUP = "group.com.tencent.comm.trtc.demo"class SampleHandler: RPBroadcastSampleHandler, TXReplayKitExtDelegate {let recordScreenKey = Notification.Name.init("TRTCRecordScreenKey")override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) {// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.TXReplayKitExt.sharedInstance().setup(withAppGroup: APPGROUP, delegate: self)}override func broadcastPaused() {// User has requested to pause the broadcast. Samples will stop being delivered.}override func broadcastResumed() {// User has requested to resume the broadcast. Samples delivery will resume.}override func broadcastFinished() {// User has requested to finish the broadcast.TXReplayKitExt.sharedInstance().broadcastFinished()}func broadcastFinished(_ broadcast: TXReplayKitExt, reason: TXReplayKitExtReason) {var tip = ""switch reason {case TXReplayKitExtReason.requestedByMain:tip = "屏幕共享已结束"breakcase TXReplayKitExtReason.disconnected:tip = "应用断开"breakcase TXReplayKitExtReason.versionMismatch:tip = "集成错误(SDK 版本号不相符合)"breakdefault:break}let error = NSError(domain: NSStringFromClass(self.classForCoder), code: 0, userInfo: [NSLocalizedFailureReasonErrorKey:tip])finishBroadcastWithError(error)}override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {switch sampleBufferType {case RPSampleBufferType.video:// Handle video sample bufferTXReplayKitExt.sharedInstance() .sendVideoSampleBuffer(sampleBuffer)breakcase RPSampleBufferType.audioApp:// Handle audio sample buffer for app audiobreakcase RPSampleBufferType.audioMic:// Handle audio sample buffer for mic audiobreak@unknown default:// Handle other sample buffer typesfatalError("Unknown type of sample buffer")}}}
#import "SampleHandler.h"@import TXLiteAVSDK_ReplayKitExt;#define APPGROUP @"group.com.tencent.comm.trtc.demo"@protocol TXReplayKitExtDelegate;@interface SampleHandler()@end@implementation SampleHandler- (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {[[TXReplayKitExt sharedInstance] setupWithAppGroup:APPGROUP delegate:self];}- (void)broadcastPaused {// User has requested to pause the broadcast. Samples will stop being delivered.}- (void)broadcastResumed {// User has requested to resume the broadcast. Samples delivery will resume.}- (void)broadcastFinished {[[TXReplayKitExt sharedInstance] broadcastFinished];// User has requested to finish the broadcast.}#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:0userInfo:@{NSLocalizedFailureReasonErrorKey:tip}];[self finishBroadcastWithError:error];}- (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {switch (sampleBufferType) {case RPSampleBufferTypeVideo:[[TXReplayKitExt sharedInstance] sendSampleBuffer:sampleBuffer withType:sampleBufferType];break;case RPSampleBufferTypeAudioApp:// Handle audio sample buffer for app audiobreak;case RPSampleBufferTypeAudioMic:// Handle audio sample buffer for mic audiobreak;default:// Handle other sample buffer typesbreak;}}@end
import ReplayKitimport TXLiteAVSDK_ReplayKitExtlet APPGROUP = "group.com.tencent.comm.trtc.demo"class SampleHandler: RPBroadcastSampleHandler, TXReplayKitExtDelegate {let recordScreenKey = Notification.Name.init("TRTCRecordScreenKey")override func broadcastStarted(withSetupInfo setupInfo: [String : NSObject]?) {// User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.TXReplayKitExt.sharedInstance().setup(withAppGroup: APPGROUP, delegate: self)}override func broadcastPaused() {// User has requested to pause the broadcast. Samples will stop being delivered.}override func broadcastResumed() {// User has requested to resume the broadcast. Samples delivery will resume.}override func broadcastFinished() {// User has requested to finish the broadcast.TXReplayKitExt.sharedInstance() .finishBroadcast()}func broadcastFinished(_ broadcast: TXReplayKitExt, reason: TXReplayKitExtReason) {var tip = ""switch reason {case TXReplayKitExtReason.requestedByMain:tip = "屏幕共享已结束"breakcase TXReplayKitExtReason.disconnected:tip = "应用断开"breakcase TXReplayKitExtReason.versionMismatch:tip = "集成错误(SDK 版本号不相符合)"breakdefault:break}let error = NSError(domain: NSStringFromClass(self.classForCoder), code: 0, userInfo: [NSLocalizedFailureReasonErrorKey:tip])finishBroadcastWithError(error)}override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) {switch sampleBufferType {case RPSampleBufferType.video:// Handle video sample bufferTXReplayKitExt.sharedInstance() .sendVideoSampleBuffer(sampleBuffer)breakcase RPSampleBufferType.audioApp:// Handle audio sample buffer for app audiobreakcase RPSampleBufferType.audioMic:// Handle audio sample buffer for mic audiobreak@unknown default:// Handle other sample buffer typesfatalError("Unknown type of sample buffer")}}}.
本页内容是否解决了您的问题?