教学白板是在线教育平台中不可缺少的功能,它的作用就如线下教室的黑板,讲师通过它进行板书、课件展示等操作。下面小编以iOS版本的在线教育平台开发为例,来说明白板功能是如何实现和调用的。
1、向服务器获取对应 room uuid 所需要的房间 roomToken,实际使用中,这步可以放在服务端。
{
[WhiteUtils getRoomTokenWithUuid:self.roomUuid completionHandler:^(NSString * _Nullable roomToken, NSError * _Nullable error) {
if (roomToken) {
self.roomToken = roomToken;
//获取到token之后加入房间
[self joinRoomWithToken:roomToken];
} else {
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"获取 RoomToken 失败", nil) message:[NSString stringWithFormat:@"错误信息:%@", [error description]] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"确定", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[self.navigationController popViewControllerAnimated:YES];
}];
[alertVC addAction:action];
[self presentViewController:alertVC animated:YES completion:nil];
}
}];
}
2、加入白板房间
{
//配置头像,可以在操作的白板的时候展示头像
NSDictionary *payload = @{@"avatar": [Config getavatarThumb]};
WhiteRoomConfig *roomConfig = [[WhiteRoomConfig alloc] initWithUuid:self.roomUuid roomToken:roomToken userPayload:payload];
// * isWritable 默认为 yes,此处为了单元测试用
roomConfig.isWritable = YES;
// 配置,橡皮擦是否能删除图片。默认为 false,能够删除图片。
// roomConfig.disableEraseImage = YES;
[self.sdk joinRoomWithConfig:roomConfig callbacks:nil completionHandler:^(BOOL success, WhiteRoom * _Nonnull room, NSError * _Nonnull error) {
if (success) {
self.roomToken = roomToken;
self.room = room;
isDisableTeachingAids = YES;
//禁止用户的教具操作 ture为禁止
[_room disableDeviceInputs:YES];
} else {
self.title = NSLocalizedString(@"加入失败", nil);
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"加入房间失败", nil) message:[NSString stringWithFormat:@"错误信息:%@", [error localizedDescription]] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"确定", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[self.navigationController popViewControllerAnimated:YES];
}];
[alertVC addAction:action];
[self presentViewController:alertVC animated:YES completion:nil];
}
}];
}
3、教具的使用操作
/*
WhiteApplianceNameKey const AppliancePencil = @"pencil";
WhiteApplianceNameKey const ApplianceSelector = @"selector";
WhiteApplianceNameKey const ApplianceText = @"text";
WhiteApplianceNameKey const ApplianceEllipse = @"ellipse";
WhiteApplianceNameKey const ApplianceRectangle = @"rectangle";
WhiteApplianceNameKey const ApplianceEraser = @"eraser";
*/
currentmState.currentApplianceName = AppliancePencil;
//颜色可以自定义
currentmState.strokeColor = [UIColor redColor];
//画线宽度可以自定义
currentmState.strokeWidth = 10;
[self.room setMemberState:currentmState];
4、退出房间
以上就是iOS版本的在线教育平台开发过程中,教学白板的实现和调用过程。
声明:以上内容为作者本人原创,未经作者本人同意,禁止转载,否则将追究相关法律责任。