Manage in-meeting annotation
The code on this page works with either the default UI or the custom UI.
When users start sharing their screens, others can annotate on top of the shared video feed. Through the SDK, you can manage many settings related to the appearance and availability of annotation.
Annotation settings
Before starting to annotate, check the meeting settings in the web portal to confirm that it is currently enabled. Check synchronously through the annotation controller, or receive updates asynchronously through the MobileRTCAnnotationServiceDelegate.
if let annotationService = MobileRTC.shared().getAnnotationService() {
annotationService.delegate = self
}
extension TestVC: MobileRTCAnnotationServiceDelegate {
func onAnnotationService(_ service: MobileRTCAnnotationService?, supportStatusChanged support: Bool, shareSouceID shareSourceID: UInt) {
if support {
// Annotations are enabled
}
shareSourceID; // The user's ID that is currently sharing
}
}
// OR you can check manually if annotations are supported
if let annotationService = MobileRTC.shared().getAnnotationService() {
/*
As the sharer (local user), you can either:
- check if you can disable viewer annotation
- check if you have disabled annotation for your viewer, or
- enable/disable annotation for your viewer
*/
annotationService.canDisableViewerAnnotation()
annotationService.isViewerAnnotationDisabled()
annotationService.disableViewerAnnotation(true) // or false
/*
As the viewer, check if annotation can be done on a shareView either:
For Zoom's Default UI
- shareView: nil = check the current active subscribed shareView
- shareView: provided = check the provided shareView
For Zoom's Custom UI
- shareView cannot be nil.
- For remote user's sharing: shareView will be its MobileRTCActiveShareView
- For local user's sharing: shareView will be its own UIView
*/
var yourSelectedShareView:UIView = UIView() // based on above description
if annotationService.canDoAnnotation(yourSelectedShareView) {
// annotation can be performed on yourSelectedShareView
}
}
// In your .h file
@interface TestViewController : UIViewController <MobileRTCAnnotationServiceDelegate>
// In your .m file
// Add MobileRTCAnnotationServiceDelegate
MobileRTCAnnotationService *annotationService = [[MobileRTC sharedRTC] getAnnotationService];
if (annotationService) {
annotationService.delegate = self;
}
// Check onAnnotationService's callback
- (void)onAnnotationService:(MobileRTCAnnotationService *)service supportStatusChanged:(BOOL)support shareSouceID:(NSUInteger)shareSourceID {
if (support) {
// Annotations are enabled
}
shareSourceID; // The user's ID that is currently sharing
}
// OR you can check manually if annotations are supported
MobileRTCAnnotationService *annotationService = [[MobileRTC sharedRTC] getAnnotationService];
if (annotationService) {
/*
As the sharer (local user), you can
- check if you can disable viewer annotation
- check if you have disable annotation for your viewer, or
- enable/disable annotation for your viewer
*/
[annotationService canDisableViewerAnnotation];
[annotationService isViewerAnnotationDisabled];
[annotationService disableViewerAnnotation:YES]; // or NO
/*
As the viewer, check if annotation can be done on a shareView either:
For Zoom's Default UI
- shareView: nil = check the current active subscribed shareView
- shareView: provided = check the provided shareView
For Zoom's Custom UI
- shareView cannot be nil.
- For remote user's sharing: shareView will be its MobileRTCActiveShareView
- For local user's sharing: shareView will be its own UIView
*/
UIView *yourSelectedShareView = [[UIView alloc] init];
if ([annotationService canDoAnnotation:yourSelectedShareView]) {
// annotation can be performed on yourSelectedShareView
}
}
If the current user is sharing their UIView, they can enable or disable viewers annotating the shared screen. Be aware that annotation does not work for the entire device screen share through ReplayKit.
if annotationService.canDisableViewerAnnotation() {
annotationService.disableViewerAnnotation(true) // or false
}
if ([annotationService canDisableViewerAnnotation]) {
[annotationService disableViewerAnnotation:YES]; // or NO
}
Control annotation properties
To annotate when another user in the meeting shares their screen, use the MobileRTCAnnotationService to manage annotations.
To start annotating, call startAnnotation. When annotation is finished, use stopAnnotation.
/*
As the viewer, check if annotation can be done on a shareView either:
For Zoom's Default UI
- shareView: nil = check the current active subscribed shareView
- shareView: provided = check the provided shareView
For Zoom's Custom UI
- shareView cannot be nil.
- For remote user's sharing: shareView will be its MobileRTCActiveShareView
- For local user's sharing: shareView will be its own UIView
*/
var yourSelectedShareView:UIView = UIView() // based on above description
if annotationService.canDoAnnotation(yourSelectedShareView) {
if annotationService.startAnnotation(withSharedView: nil) == .successed {
// You can begin using the annotation tool
annotationService.setToolColor(.blue)
annotationService.setToolType(.pen)
annotationService.setToolWidth(10)
annotationService.undo()
annotationService.redo()
annotationService.clear(.all) // .all, .my, .others
}
}
annotationService.stopAnnotation()
/*
As the viewer, check if annotation can be done on a shareView either:
For Zoom's Default UI
- shareView: nil = check the current active subscribed shareView
- shareView: provided = check the provided shareView
For Zoom's Custom UI
- shareView cannot be nil.
- For remote user's sharing: shareView will be its MobileRTCActiveShareView
- For local user's sharing: shareView will be its own UIView
*/
UIView *yourSelectedShareView = [[UIView alloc] init];
if ([annotationService canDoAnnotation:yourSelectedShareView]) {
if ([annotationService startAnnotationWithSharedView:nil] == MobileRTCAnnotationError_Successed) {
// You can begin using the annotation tool
}
}
[annotationService stopAnnotation];
Optionally, after verifying that annotation started based on the return value of startAnnotation, you can modify the annotation appearance programmatically.
annotationService.setToolColor(.blue)
annotationService.setToolType(.pen)
annotationService.setToolWidth(10)
[annotationService setToolColor:UIColor.blueColor];
[annotationService setToolType:MobileRTCAnnoTool_Pen];
[annotationService setToolWidth:10];
Interact with annotations users create by undoing, redoing or clear annotations.
annotationService.undo()
annotationService.redo()
annotationService.clear(.all) // .all, .my, .others
[annotationService undo];
[annotationService redo];
[annotationService clear:MobileRTCAnnoClearType_All]; // All, My, Others
Based on your use case, you may also need to know if the current user is the presenter before updating your annotation UI.
if annotationService.isPresenter() {
}
if ([annotationService isPresenter]) {
}
When the meeting no longer needs annotation, remove the listener.
annotationService.delegate = nil;
annotationService.delegate = nil