Browse SDKs · Flutter
Platform
SDKsFlutter

Create a video message from local paths

Create a video message from absolute paths with the OpenIM Flutter SDK.

Copy

Construct a video message object using absolute filesystem paths for the video file and its thumbnail cover image:

Parameters

ParameterTypeRequiredDescription
videoPathStringYesAbsolute filesystem path to the video file on the current device.
videoTypeStringYesMIME type of the video file (for example, video/mp4).
durationintYesVideo playback duration in seconds.
snapshotPathStringYesAbsolute filesystem path to the first-frame thumbnail cover image.

Code example

final message = await OpenIM.iMManager.messageManager
    .createVideoMessageFromFullPath(
  videoPath: videoPath,
  videoType: 'video/mp4',
  duration: durationSeconds,
  snapshotPath: snapshotPath,
);

The absolute paths for both the video and the thumbnail cover image must exist and have read permissions on the current platform.

Return value

Returns a Future resolving to a video Message object ready for transmission. Its video and thumbnail properties are stored in videoElem.

State changes after the call

Creating a message only constructs the local message data structure in memory; it does not perform network transmission, does not upload files, and does not trigger new-message event callbacks. Once constructed, pass the returned Message instance to Send a message, which handles media upload and message delivery. To create a video message from a relative platform path, see Create a video message; if the video and thumbnail are already hosted on object storage, see Create a video message by URL.