Browse SDKs · WASM
SDKsWASM

Create a video message from URLs

Create a video message from uploaded video and thumbnail resources with the WASM SDK.

Copy

createVideoMessageByURL() creates a message from an uploaded video and its video thumbnail. The SDK field names retain snapshot, while this page uses “video thumbnail” for the user-facing concept.

Parameters

ParameterTypeRequiredDescription
videoPathstringYesLocal filename or application-defined path of the video file. Pass an empty string when only a remote resource is available.
durationnumberYesVideo duration in seconds.
videoTypestringYesVideo MIME type.
videoUUIDstringYesUnique identifier for the video resource.
videoUrlstringYesAccessible URL of the uploaded video.
videoSizenumberYesVideo size in bytes.
snapshotPathstringYesLocal filename or application-defined path of the thumbnail file. Pass an empty string when only a remote resource is available.
snapshotUUIDstringYesUnique identifier for the thumbnail resource.
snapshotSizenumberYesThumbnail size in bytes.
snapshotUrlstringYesAccessible URL of the uploaded thumbnail.
snapshotWidthnumberYesThumbnail width in pixels.
snapshotHeightnumberYesThumbnail height in pixels.
snapShotTypestringNoThumbnail MIME type.
const { data: message } = await openimsdk.createVideoMessageByURL({
  videoPath: '',
  duration,
  videoType: uploadedVideo.contentType,
  videoUUID: crypto.randomUUID(),
  videoUrl: uploadedVideo.url,
  videoSize: uploadedVideo.size,
  snapshotPath: '',
  snapshotUUID: crypto.randomUUID(),
  snapshotSize: uploadedSnapshot.size,
  snapshotUrl: uploadedSnapshot.url,
  snapshotWidth,
  snapshotHeight,
  snapShotType: uploadedSnapshot.contentType,
});

Pass the video duration in seconds. When the Promise resolves, it has created only a pending message object. Send it with sendMessageNotOss().