Create a video message
Create a video message from platform-readable paths with the OpenIM Flutter SDK.
Construct a video message object using local filesystem paths for the video file and its thumbnail cover image:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoPath | String | Yes | Local filesystem path to the video file on the current device. |
videoType | String | Yes | MIME type of the video file (for example, video/mp4). |
duration | int | Yes | Video playback duration in seconds. |
snapshotPath | String | Yes | Local filesystem path to the first-frame thumbnail cover image. |
Code example
final message = await OpenIM.iMManager.messageManager.createVideoMessage(
videoPath: videoPath,
videoType: 'video/mp4',
duration: durationSeconds,
snapshotPath: snapshotPath,
);Both the video file and thumbnail cover image paths must exist and have read permissions on the current device, and duration is measured in seconds.
Return value
Returns a Future resolving to a video Message object ready for transmission. Its detailed attributes 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 an absolute filesystem path, see Create a video message from full path; if the video and thumbnail are already hosted on object storage, see Create a video message by URL.
Was this page helpful?