SDKsuni-app / uni-app x
Create a video message from a URL
Construct a pending video message from uploaded video and cover thumbnail URLs.
Invoke createVideoMessageByURL() when video and thumbnail cover assets have already been uploaded to your application server or object storage and possess publicly accessible remote URLs.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoPath | string | No | Original local video file path; pass an empty string "" when only remote URLs exist. |
videoUUID | string | No | Unique video asset identifier returned by the upload service. |
videoUrl | string | Recommended | Remote playback URL of the video. |
videoType | string | Recommended | Video MIME type (for example, 'video/mp4'). |
videoSize | number | Recommended | Video file size in bytes. |
duration | number | Recommended | Video playback duration in seconds. |
snapshotPath | string | No | Original local thumbnail path; pass an empty string "" when using remote URLs. |
snapshotUUID | string | No | Unique thumbnail image identifier. |
snapshotSize | number | Recommended | Thumbnail image file size in bytes. |
snapshotUrl | string | Recommended | Remote image URL of the video cover snapshot. |
snapshotWidth | number | Recommended | Thumbnail cover width in pixels. |
snapshotHeight | number | Recommended | Thumbnail cover height in pixels. |
snapshotType | string | Recommended | Thumbnail MIME type (for example, 'image/jpeg'). |
Code example
import { createVideoMessageByURL } from '@/uni_modules/unix-openim-sdk'
const message = await createVideoMessageByURL({
videoPath: '',
videoUUID: uploadedVideo.uuid,
videoUrl: uploadedVideo.url,
videoType: 'video/mp4',
videoSize: uploadedVideo.size,
duration: 18,
snapshotPath: '',
snapshotUUID: uploadedCover.uuid,
snapshotSize: uploadedCover.size,
snapshotUrl: uploadedCover.url,
snapshotWidth: 1280,
snapshotHeight: 720,
snapshotType: 'image/jpeg',
})
if (message == null) returnWhile individual fields are typed as optional, practical video playback and preview rendering require valid videoUrl and snapshotUrl values, alongside accurate dimensions and durations.
Return value
The Promise resolves with an OpenIMMessageItem | null object.
State changes after the call
Pass the constructed message item to Send a non-OSS message to transmit the payload without re-uploading the video or snapshot. Track message state using clientMsgID.
Was this page helpful?