Browse SDKs · Android
Platform
SDKsAndroid

Create a video message

Create a video message from paths relative to the SDK data directory.

Copy

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

ParameterTypeRequiredDescription
videoPathStringYesVideo file path relative to the SDK initialization data directory.
mimeTypeStringYesMIME type of the video (such as video/mp4 or file extension mp4).
durationlongYesPlayback duration of the video in seconds.
snapshotPathStringYesVideo 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

  1. Local initialization: Initializes the local Message structure without starting network uploads.
  2. 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.