SDKsAndroid
Create a video message
Create a video message from paths relative to the SDK data directory.
Construct a video message object from relative file paths within the SDK initialization data directory. Provide the relative paths for both the video file and its thumbnail preview snapshot. When sending via Send a message, the SDK automatically uploads the video and snapshot.
Code example
String videoPath = "videos/sample.mp4";
String mimeType = "video/mp4";
long durationSeconds = 15L;
String snapshotPath = "snapshots/sample_thumb.jpg";
Message message = OpenIMClient.getInstance().messageManager.createVideoMessage(
videoPath,
mimeType,
durationSeconds,
snapshotPath
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
videoPath | String | Yes | Video file path relative to the SDK initialization data directory. |
mimeType | String | Yes | MIME type of the video (such as video/mp4 or file extension mp4). |
duration | long | Yes | Playback duration of the video in seconds. |
snapshotPath | String | Yes | Video thumbnail snapshot path relative to the SDK initialization data directory. |
Return value
Returns the created Message object with contentType set to MessageType.VIDEO.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without starting network uploads. - Transmission: Call Send a message to upload the video and send it to a single user or group. For absolute filesystem paths, see Create a video message from local paths.
Was this page helpful?