Browse SDKs · Android
Platform
SDKsAndroid

Create a video message from URLs

Use VideoElem to create a video message for an uploaded resource.

Copy

Construct a video message object using remote URLs hosted on external cloud storage or a CDN. The SDK does not re-upload the video or thumbnail snapshot, making this suitable for applications managing their own media storage pipelines.

Code example

VideoElem videoElem = new VideoElem();
videoElem.setVideoUrl("https://example.com/videos/sample.mp4");
videoElem.setVideoSize(10485760L);
videoElem.setDuration(30L);
videoElem.setSnapshotUrl("https://example.com/videos/snapshot.jpg");
videoElem.setSnapshotSize(12400L);

Message message = OpenIMClient.getInstance().messageManager.createVideoMessageByURL(videoElem);

Parameters

ParameterTypeRequiredDescription
videoElemVideoElemYesVideo model object. Must specify video URL videoUrl, video file size videoSize, duration duration, and snapshot URL snapshotUrl.

Return value

Returns the created Message object ready for transmission, with contentType set to MessageType.VIDEO.

State changes after the call

  1. Local initialization: Initializes the local Message structure without initiating network uploads.
  2. Transmission: Because the media files are pre-hosted, call Send a message without OSS upload to deliver the message without redundant uploads.