教學白闆是線上教育平台中不可缺少的功能,它的作用就如線下教室的黑闆,講師通過它進行闆書、課件展示等操作。下面小編以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版本的線上教育平台開發過程中,教學白闆的實作和調用過程。
聲明:以上内容為作者本人原創,未經作者本人同意,禁止轉載,否則将追究相關法律責任。