Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Create a video message from a URL

Construct a pending video message from uploaded video and cover thumbnail URLs.

Copy

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

ParameterTypeRequiredDescription
videoPathstringNoOriginal local video file path; pass an empty string "" when only remote URLs exist.
videoUUIDstringNoUnique video asset identifier returned by the upload service.
videoUrlstringRecommendedRemote playback URL of the video.
videoTypestringRecommendedVideo MIME type (for example, 'video/mp4').
videoSizenumberRecommendedVideo file size in bytes.
durationnumberRecommendedVideo playback duration in seconds.
snapshotPathstringNoOriginal local thumbnail path; pass an empty string "" when using remote URLs.
snapshotUUIDstringNoUnique thumbnail image identifier.
snapshotSizenumberRecommendedThumbnail image file size in bytes.
snapshotUrlstringRecommendedRemote image URL of the video cover snapshot.
snapshotWidthnumberRecommendedThumbnail cover width in pixels.
snapshotHeightnumberRecommendedThumbnail cover height in pixels.
snapshotTypestringRecommendedThumbnail 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) return

While 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.