通过API可实现多种类型的内容共享,包括:
各平台实现情况请参考各平台文档详情。 除了基础的内容共享,通过SDK还可以实现电子白板、内容标注等高级功能。 开发者可通过各平台高级功能列表查看详情。 共享内容的状态变更将通过事件回调进行通知。
首先调用startContentSharing方法开始内容共享,参数描述
示例代码为共享图片到结束的流程
1.选择图片,开始共享
XYShareViewModel.ets
private async selectPicture(): Promise<void> {
...
XYRTCEngine.getInstance().startContentSharing(XYSDKDualStreamMode.VIDEO, true, false);
...
}
2.发送共享数据流
XYShareViewModel.ets
/**
* put Content 数据
* @param imageBuffer
* @param length
* @param width
* @param height
* @param stride
*/
async putContentData(imageBuffer: ArrayBuffer, length: number, width: number, height: number,
stride: number): Promise<void> {
...
XYRTCEngine.getInstance().putContentData(imageBuffer, length, width, height, stride);
...
}
3.结束共享
XYRTCEngine.getInstance().stopContentSharing();