Skip to main content

Enable and disable the whiteboard

The whiteboard module in Flexible Classroom is implemented based on AgoraWidget. You can turn the whiteboard module on or off in the classroom by setting the widget state as active or inactive.

After disabling the whiteboard module, drawing tools including pencil, text box, shape, and eraser will no longer be available and users cannot upload, delete, or display class files on the whiteboard. Other features that do not rely on the whiteboard, such as uploading or deleting class files, pop-up quiz, count-down timer, and screen sharing will not be affected.

Turn the whiteboard on or off

The component corresponding to the Whiteboard widget is named AgoraEduWhiteBoardComponent, and the widget ID can be obtained using AgoraWidgetDefaultId.WhiteBoard.id. Use this component to turn the Whiteboard on or off.

To enable or disable the Whiteboard, you monitor the status changes of the Whiteboard caused by the teacher client and adjust the UI accordingly. See initView() in the file AgoraEduUIKit/src/main/java/com/agora/edu/component/whiteboard/AgoraEduWhiteBoardComponent.kt for the logic of registering observers, listening for active states, and creating or destroying Whiteboard components in the methods.

If you want to open and close the Whiteboard by yourself, you can refer to the following code examples:

  • To turn on the Whiteboard, add the following code to the file where the button to open the Whiteboard is located:


    _2
    val info = AgoraWidgetRoomPropsUpdateReq(state = 1)
    _2
    eduContext?.widgetContext()?.setWidgetActive(AgoraWidgetDefaultId.WhiteBoard.id, info)

  • To close the Whiteboard, add the following code to the file where the button to close the Whiteboard is located:


    _1
    eduContext?.widgetContext()?.setWidgetInActive(AgoraWidgetDefaultId.WhiteBoard.id)

  • To register an observer, use the following code:


    _1
    eduContext?.widgetContext()?.addWidgetActiveObserver(widgetActiveObserver, AgoraWidgetDefaultId.LargeWindow.id)

  • To monitor the status of the widget, use the following code:


    _15
    private val widgetActiveObserver = object : AgoraWidgetActiveObserver {
    _15
    override fun onWidgetActive(widgetId: String) {
    _15
    // The Whiteboard has been created, here is the child thread
    _15
    if (widgetId == AgoraWidgetDefaultId.WhiteBoard.id) {
    _15
    _15
    }
    _15
    }
    _15
    _15
    override fun onWidgetInActive(widgetId: String) {
    _15
    // The Whiteboard has been removed, here is the child thread
    _15
    if (widgetId == AgoraWidgetDefaultId.WhiteBoard.id) {
    _15
    _15
    }
    _15
    }
    _15
    }