互动白板
更新时间: 2023/08/30 06:58:50
您可以通过 NERoom 的互动白板,实现互动涂鸦、实时同步、文档共享等功能,满足在线教育、互动娱乐、金融面签、视频会议等低延时高互动场景的需求。
功能介绍
互动白板的应用场景包括:
- 在线教育:用于线上语言培训、K12 学科辅导等课堂教学场景,教师可借助涂鸦、文本、直线、激光笔等基础教具,边演示课件边勾画要点。
- 视频会议:用于视频会议、在线培训等企业协同场景,满足主讲实时演示讲解、多方协同交流的需求。
- 互动娱乐:用于你画我猜、互动涂鸦等娱乐场景,满足更多有趣的游戏互动玩法。
- 金融面签:用于视频面签、远程见证等金融场景,满足面签双方远程办理业务、进行签名确认的需求。
前提条件
创建房间时,已在NECreateRoomOptions
方法中,设置enableWhiteboard=true
,具体操作方法请参见创建房间。
配置步骤
-
开始共享白板。
fun startWhiteboardShare(callback: NECallback<Unit>)
-
设置白板视图。
fun setupWhiteboardCanvas(view: NEWhiteboardView)
-
设置白板是否可绘制。
fun setEnableDraw(enable: true/false, callback: NECallback<Unit>)
enable的参数说明如下:
- true:允许绘制。
- false:不允许绘制。
-
停止共享白板。
fun stopWhiteboardShare(callback: NECallback<Unit>)
-
重置白板视图。
fun resetWhiteboardCanvas(view: NEWhiteboardView?)
-
关闭某成员的白板共享。
stopMemberWhiteboardShare(userUuid: String, callback: NECallback<Unit>)
示例代码
1.实现共享白板功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext!=null){
roomContext.getWhiteboardController().startWhiteboardShare(new NECallback2<Unit>() {
@Override
public void onSuccess(@Nullable Unit unit) {
super.onSuccess(unit);
Log.d(TAG,"success");
}
@Override
public void onError(int code, @Nullable String message) {
super.onError(code, message);
Log.d(TAG,"error");
}
});
}
2.实现设置白板视图功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext!=null){
NEWhiteboardView whiteboardView = new NEWhiteboardView(this);
whiteboardContainer.removeAllViews();
whiteboardContainer.addView(whiteboardView);
whiteboardController.setupWhiteboardCanvas(whiteboardView);
roomContext.getWhiteboardController().setupWhiteboardCanvas(whiteboardView);
}
3.实现重置白板视图功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext!=null){
if (whiteboardContainer.getChildCount() > 0) {
NEWhiteboardView whiteboardView = (NEWhiteboardView) whiteboardContainer.getChildAt(0);
whiteboardController.resetWhiteboardCanvas(whiteboardView);
}
}
4.实现设置白板是否可绘制功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext != null) {
roomContext.getWhiteboardController().setEnableDraw(true, new NECallback2<Unit>() {
@Override
public void onSuccess(@Nullable Unit unit) {
super.onSuccess(unit);
Log.d(TAG,"success");
}
@Override
public void onError(int code, @Nullable String message) {
super.onError(code, message);
Log.d(TAG,"error");
}
});
}
5.实现停止共享白板功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext!=null){
roomContext.getWhiteboardController().stopWhiteboardShare(new NECallback2<Unit>() {
@Override
public void onSuccess(@Nullable Unit unit) {
super.onSuccess(unit);
Log.d(TAG,"success");
}
@Override
public void onError(int code, @Nullable String message) {
super.onError(code, message);
Log.d(TAG,"error");
}
});
}
6.实现监听白板状态变更功能的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext!=null){
roomContext.addRoomListener(new NERoomListener() {
@Override
public void onMemberWhiteboardStateChanged(@NonNull NERoomMember member, boolean isSharing) {
if (isSharing){
Log.d(TAG,member.getUuid()+"is sharing whiteboard")
}else{
Log.d(TAG,member.getUuid()+"stop sharing whiteboard")
}
}
});
}
- 实现关闭某成员的白板共享的示例代码如下:
NERoomService roomService = NERoomKit.getInstance().getService(NERoomService.class);
NERoomContext roomContext = roomService.getRoomContext(roomUuid);
if (roomContext != null) {
String userUuid = "uuid";
roomContext.getWhiteboardController().stopMemberWhiteboardShare(userUuid, new NECallback2<Unit>() {
@Override
public void onSuccess(@Nullable Unit unit) {
Log.d(TAG,"success");
}
@Override
public void onError(int code, @Nullable String message) {
Log.d(TAG,"error");
}
});
}
相关API文档
方法 | 功能描述 |
---|---|
setEnableDraw | 设置白板可绘制。 |
setupWhiteboardCanvas | 设置白板视图。 |
resetWhiteboardCanvas | 重置白板视图。 |
startWhiteboardShare | 开始共享白板。 |
stopWhiteboardShare | 停止共享白板。 |
onMemberWhiteboardStateChanged | 白板共享状态变更回调。 |
stopMemberWhiteboardShare | 关闭某成员的白板共享。 |
此文档是否对你有帮助?