Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Create video message from URL

Create a video message from pre-uploaded video and cover thumbnail resource metadata.

Copy

Creates a video message object using remote URLs and metadata for both video and thumbnail cover assets.

Code example

import sdk, { CreateVideoMessageByURLReq, CreateVideoMessageResp } from '@openimsdk/imsdk';

const request: CreateVideoMessageByURLReq = {
  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',
};
const response: CreateVideoMessageResp = await sdk.createVideoMessageByURL(request);
const message = response.message;

Parameters

ParameterTypeRequiredDescription
videoPathstringYesLocal video path if retained, or empty string "" for remote files.
videoUUIDstringYesUnique identifier for the video asset.
videoURLstringYesRemote video download URL.
videoTypestringYesVideo MIME type (such as video/mp4).
videoSizenumberYesVideo file size in bytes.
durationnumberYesVideo playback duration in seconds.
snapshotPathstringYesLocal thumbnail path if retained, or empty string "".
snapshotUUIDstringYesUnique identifier for the cover thumbnail asset.
snapshotSizenumberYesCover thumbnail file size in bytes.
snapshotURLstringYesRemote thumbnail download URL.
snapshotWidthnumberYesThumbnail pixel width.
snapshotHeightnumberYesThumbnail pixel height.
snapshotTypestringYesThumbnail MIME type (such as image/jpeg).

Return value

Returns a Promise resolving to CreateVideoMessageResp:

PropertyTypeDescription
messageIMMessageLocally instantiated video message object referencing remote URLs.

State changes after the call

Note that property names use uppercase URL. All sizes, dimensions, types, and durations must match actual resource attributes; even if no local files exist, pass empty strings "" for videoPath and snapshotPath. This method instantiates the message object locally; call Send message to dispatch it.