Create a video message from a local file
Create a pending video message from accessible local video and cover thumbnail file paths.
Invoke createVideoMessageFromFullPath() to construct a pending video message using local file paths for both the video and its cover thumbnail snapshot.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoPath | string | Yes | Local video file path accessible to the native runtime. |
videoType | string | Yes | Video MIME type (for example, 'video/mp4'). |
duration | number | Yes | Video duration in seconds. |
snapshotPath | string | Yes | Local thumbnail cover image path accessible to the native runtime. |
Code example
import {
createVideoMessageFromFullPath,
} from '@/uni_modules/unix-openim-sdk'
const message = await createVideoMessageFromFullPath({
videoPath: `${uni.env.USER_DATA_PATH}/demo.mp4`,
videoType: 'video/mp4',
duration: 18,
snapshotPath: `${uni.env.USER_DATA_PATH}/demo-cover.jpg`,
})
if (message == null) returnBoth paths should be POSIX absolute paths or unifile:// URIs. When handling files generated by video recorders or camera pickers, persist them in uni.env.USER_DATA_PATH if they will not be transmitted immediately. Specify duration in seconds and ensure the cover image accurately reflects the video content.
Return value
The Promise resolves with an OpenIMMessageItem | null object.
State changes after the call
Pass the constructed message item to Send a message. The SDK automatically uploads the video and thumbnail before delivering the message payload. Monitor upload progress with onSendMessageProgress and index updates by clientMsgID.
Was this page helpful?