首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >在线教育平台开发中,教学白板是如何实现的

在线教育平台开发中,教学白板是如何实现的

作者头像
万岳教育系统
修改2020-06-04 14:12:18
9620
修改2020-06-04 14:12:18
举报

教学白板是在线教育平台中不可缺少的功能,它的作用就如线下教室的黑板,讲师通过它进行板书、课件展示等操作。下面小编以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、退出房间

[self.room disconnect:nil];

以上就是iOS版本的在线教育平台开发过程中,教学白板的实现和调用过程。

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档