Browse SDKs · Android
Platform
SDKsAndroid

Create a video message from local paths

Create a video message from absolute video and thumbnail paths.

Copy

Construct a video message object using absolute filesystem paths on the local device. Provide the absolute paths for both the local video file and its thumbnail preview snapshot. When sending via Send a message, the SDK automatically uploads the video and thumbnail files.

Code example

String absoluteVideoPath = "/storage/emulated/0/DCIM/Camera/VID_20261012.mp4";
String mimeType = "video/mp4";
long durationSeconds = 15L;
String absoluteSnapshotPath = "/storage/emulated/0/DCIM/Camera/VID_thumb.jpg";

Message message = OpenIMClient.getInstance().messageManager.createVideoMessageFromFullPath(
    absoluteVideoPath,
    mimeType,
    durationSeconds,
    absoluteSnapshotPath
);

Parameters

ParameterTypeRequiredDescription
videoPathStringYesAbsolute filesystem path of the video file on the local device. Ensure read permissions are granted.
mimeTypeStringYesMIME type of the video (such as video/mp4).
durationlongYesPlayback duration of the video in seconds.
snapshotPathStringYesAbsolute filesystem path of the video thumbnail snapshot on the local device.

Return value

Returns the created Message object with contentType set to MessageType.VIDEO.

State changes after the call

  1. Local initialization: Initializes the local Message structure without starting network uploads.
  2. Transmission: Call Send a message to deliver the message to a single user or group.