SDKsHarmonyOSEnterprise
Create video message from local file
Create a video message from local video and thumbnail image filesystem paths.
Creates a video message object using local filesystem paths for both the video file and cover thumbnail image.
Code example
import sdk, { CreateVideoMessageReq, CreateVideoMessageResp } from '@openimsdk/imsdk';
const request: CreateVideoMessageReq = {
videoSourcePath: videoPath,
videoType: 'video/mp4',
duration: 18,
snapshotSourcePath: coverPath,
};
const response: CreateVideoMessageResp = await sdk.createVideoMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoSourcePath | string | Yes | Local filesystem path to the video file readable by the native SDK. |
videoType | string | Yes | Video MIME type (such as video/mp4). |
duration | number | Yes | Video playback duration in seconds. |
snapshotSourcePath | string | Yes | Local filesystem path to the cover thumbnail image. |
Return value
Returns a Promise resolving to CreateVideoMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated video message object. |
State changes after the call
Both video and cover snapshot paths must be readable by the native SDK. duration is in seconds, and videoType represents the true MIME type. Promise resolution creates the message object locally; calling Send message subsequently uploads both files through the SDK and transmits the message.
Was this page helpful?