Whiteboard sharing
The Video SDK lets an app share a whiteboard within a session, allowing users to start, view, and collaborate on a digital canvas. Manage this feature through the dedicated ZoomVideoSDKWhiteboardHelper.
Integrate the module
To add whiteboard support to your Android app, you will primarily use the ZoomVideoSDKWhiteboardHelper interface, which is part of the ZoomVideoSDKShareHelper interface. Manage events using the ZoomVideoSDKDelegate.
Add these dependencies to your app-level build.gradle file.
| Module | Purpose |
|---|---|
:whiteboard | Contains the core rendering and collaboration logic for the Whiteboard feature. |
:zm-annoter | Provides annotation support, which the whiteboard feature depends on. |
dependencies {
// ... other dependencies
// Required for core whiteboard features
implementation project(':whiteboard')
// Required dependency for whiteboard annotation services
implementation project(':zm-annoter')
}
Share and manage the whiteboard
These helper classes are available for you to manage the whiteboard.
| Method | Purpose |
|---|---|
ZoomVideoSDKShareHelper.getWhiteboardHelper() | Retrieves the instance of the whiteboard helper. |
ZoomVideoSDKWhiteboardHelper.canStartShareWhiteboard() | Checks if the current user is permitted to start a new whiteboard. |
ZoomVideoSDKWhiteboardHelper.startShareWhiteboard() | Starts a new, blank whiteboard session. |
ZoomVideoSDKWhiteboardHelper.canStopShareWhiteboard() | Checks if the current user can stop the active whiteboard share. |
ZoomVideoSDKWhiteboardHelper.stopShareWhiteboard() | Stops the current whiteboard share. |
// 1. Get the Whiteboard Helper (Using safe calls is recommended)
val whiteboardHelper = ZoomVideoSDK.getInstance()
?.shareHelper
?.whiteboardHelper
// 2. Start Sharing
whiteboardHelper?.let { helper ->
if (helper.canStartShareWhiteboard()) {
val result = helper.startShareWhiteboard()
// Check 'result' for success (ZoomVideoSDKErrors.ZoomVideoSDKErrors_Success)
}
}
// 3. Stop Sharing
whiteboardHelper?.let { helper ->
if (helper.canStopShareWhiteboard()) {
val result = helper.stopShareWhiteboard()
// Check 'result' for success
}
}
// 1. Get the Whiteboard Helper
ZoomVideoSDKWhiteboardHelper whiteboardHelper = ZoomVideoSDK.getInstance()
.getShareHelper()
.getWhiteboardHelper();
// 2. Start Sharing
if (whiteboardHelper.canStartShareWhiteboard()) {
int result = whiteboardHelper.startShareWhiteboard();
// Check 'result' for success (ZoomVideoSDKErrors.ZoomVideoSDKErrors_Success)
}
// 3. Stop Sharing
if (whiteboardHelper.canStopShareWhiteboard()) {
int result = whiteboardHelper.stopShareWhiteboard();
// Check 'result' for success
}
View or subscribe to the whiteboard
To allow users to see and interact with a shared whiteboard, you must subscribe to the stream and provide a container for rendering.
| Method | Purpose |
|---|---|
ZoomVideoSDKWhiteboardHelper.subscribeWhiteboard(FragmentActivity activity, ViewGroup container) | Subscribes to the active whiteboard stream and renders it within the specified container. |
ZoomVideoSDKWhiteboardHelper.unSubscribeWhiteboard(FragmentActivity activity) | Unsubscribes from the whiteboard stream and stops rendering. |
ZoomVideoSDKWhiteboardHelper.isOtherSharingWhiteboard() | Checks if any other user is currently sharing a whiteboard. |
To view the whiteboard
// Get the helper as shown above
val whiteboardHelper = ZoomVideoSDK.getInstance()
?.shareHelper
?.whiteboardHelper
// Provide an Activity and a container (e.g., a FrameLayout) in your layout
val whiteboardContainer = findViewById<ViewGroup>(R.id.whiteboard_render_view)
whiteboardHelper?.let { helper ->
val result = helper.subscribeWhiteboard(this, whiteboardContainer)
// The whiteboard UI will now be displayed in the container
}
// Get the helper as shown above
ZoomVideoSDKWhiteboardHelper whiteboardHelper = ZoomVideoSDK.getInstance()
.getShareHelper()
.getWhiteboardHelper();
// Provide an Activity and a container (e.g., a FrameLayout) in your layout
ViewGroup whiteboardContainer = findViewById(R.id.whiteboard_render_view);
int result = helper.subscribeWhiteboard(this, whiteboardContainer);
// The whiteboard UI will now be displayed in the container
To stop viewing the whiteboard
whiteboardHelper?.unSubscribeWhiteboard(this)
helper.unSubscribeWhiteboard(this);
Whiteboard events and status changes
You'll handle whiteboard events in your ZoomVideoSDKDelegate implementation.
| Callback/Method | Purpose |
|---|---|
onUserWhiteboardShareStatusChanged(ZoomVideoSDKUser user, ZoomVideoSDKWhiteboardHelper helper) | Called when any user starts or stops sharing a whiteboard. This is your cue to subscribe or unsubscribe. |
ZoomVideoSDKUser.getWhiteboardStatus() | Returns a user's current whiteboard status (WhiteboardStatus_Started or WhiteboardStatus_Stopped). |
override fun onUserWhiteboardShareStatusChanged(
user: ZoomVideoSDKUser,
helper: ZoomVideoSDKWhiteboardHelper
) {
val status = user.whiteboardStatus
// Check if the user is the one sharing and if you need to subscribe
if (status == ZoomVideoSDKWhiteboardStatus.WhiteboardStatus_Started) {
// A user has started sharing a whiteboard. Subscribe to display it.
// Assuming 'myActivity' and 'myWhiteboardContainer' are available references
helper.subscribeWhiteboard(myActivity, myWhiteboardContainer)
} else if (status == ZoomVideoSDKWhiteboardStatus.WhiteboardStatus_Stopped) {
// The whiteboard sharing has ended. Unsubscribe to remove the view.
helper.unSubscribeWhiteboard(myActivity)
}
}
@Override
public void onUserWhiteboardShareStatusChanged(ZoomVideoSDKUser user, ZoomVideoSDKWhiteboardHelper helper) {
super.onUserWhiteboardShareStatusChanged(user, helper);
ZoomVideoSDKWhiteboardStatus status = user.getWhiteboardStatus();
// Check if the user is the one sharing and if you need to subscribe
if (status == ZoomVideoSDKWhiteboardStatus.WhiteboardStatus_Started) {
// A user has started sharing a whiteboard. Subscribe to display it.
// The helper parameter is the correct helper instance to use for subscription.
helper.subscribeWhiteboard(myActivity, myWhiteboardContainer);
} else if (status == ZoomVideoSDKWhiteboardStatus.WhiteboardStatus_Stopped) {
// The whiteboard sharing has ended. Unsubscribe to remove the view.
helper.unSubscribeWhiteboard(myActivity);
}
}
Export whiteboard content
Export the whiteboard as a PDF document.
| Method/Enum | Purpose |
|---|---|
ZoomVideoSDKWhiteboardHelper.exportWhiteboard(ZoomVideoSDKExportFormat format) | Triggers the asynchronous export process. Currently supports EXPORT_FORMAT_PDF. |
ZoomVideoSDKExportFormat.EXPORT_FORMAT_PDF | The enum value to specify PDF as the export format. |
onWhiteboardExported(ZoomVideoSDKExportFormat format, byte[] data) | The delegate callback that provides the exported file data as a byte array. |
To export and retrieve data
// 1. Trigger the export
whiteboardHelper?.let { helper ->
helper.exportWhiteboard(ZoomVideoSDKExportFormat.EXPORT_FORMAT_PDF)
}
// 2. Receive the data in your delegate
override fun onWhiteboardExported(
format: ZoomVideoSDKExportFormat,
data: ByteArray
) {
if (format == ZoomVideoSDKExportFormat.EXPORT_FORMAT_PDF) {
// 'data' is the byte array of the PDF file.
// You can now write this byte array to a file on the device.
savePdfFile(data)
}
}
// 1. Trigger the export
ZoomVideoSDKWhiteboardHelper helper = ...;
helper.exportWhiteboard(ZoomVideoSDKExportFormat.EXPORT_FORMAT_PDF);
// 2. Receive the data in your delegate
@Override
public void onWhiteboardExported(ZoomVideoSDKExportFormat format, byte[] data) {
super.onWhiteboardExported(format, data);
if (format == ZoomVideoSDKExportFormat.EXPORT_FORMAT_PDF) {
// 'data' is the byte array of the PDF file.
// You can now write this byte array to a file on the device.
savePdfFile(data);
}
}
Manage the data
Because the whiteboard data isn't stored in the cloud, you'll need to handle the data storage. Data can be lost when someone stops sharing the whiteboard, a user leaves a session, when a user joins a sub-session, or when the app crashes or has network connectivity issues.