SDKsWASM
Create a video message from files
Create a video message from browser video and snapshot files with the WASM SDK.
createVideoMessageByFile() creates a message from browser video and snapshot files and their metadata.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoFile | File | Yes | Original video file from the browser. |
snapshotFile | File | Yes | Video snapshot file from the browser. |
videoPath | string | Yes | Local filename or application-defined path of the video file. |
duration | number | Yes | Video duration. |
videoType | string | Yes | Video MIME type. |
videoUUID | string | Yes | Unique identifier for the video resource. |
videoUrl | string | Yes | Video URL. Pass an empty string when creating from a file. |
videoSize | number | Yes | Video size in bytes. |
snapshotPath | string | Yes | Local filename or application-defined path of the snapshot file. |
snapshotUUID | string | Yes | Unique identifier for the snapshot resource. |
snapshotSize | number | Yes | Snapshot size in bytes. |
snapshotUrl | string | Yes | Snapshot URL. Pass an empty string when creating from a file. |
snapshotWidth | number | Yes | Snapshot width in pixels. |
snapshotHeight | number | Yes | Snapshot height in pixels. |
snapShotType | string | No | Snapshot MIME type. |
const { data: message } = await openimsdk.createVideoMessageByFile({
videoFile,
snapshotFile,
videoPath: videoFile.name,
duration,
videoType: videoFile.type,
videoUUID: crypto.randomUUID(),
videoUrl: '',
videoSize: videoFile.size,
snapshotPath: snapshotFile.name,
snapshotUUID: crypto.randomUUID(),
snapshotSize: snapshotFile.size,
snapshotUrl: '',
snapshotWidth,
snapshotHeight,
snapShotType: snapshotFile.type,
});When the Promise resolves, it has created only a pending message object. Use sendMessage() afterward to upload and send it.
Was this page helpful?