SDKsAndroid
Create a video message from URLs
Use VideoElem to create a video message for an uploaded resource.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
videoElem | VideoElem | Yes | Video 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
- Local initialization: Initializes the local
Messagestructure without initiating network uploads. - Transmission: Because the media files are pre-hosted, call Send a message without OSS upload to deliver the message without redundant uploads.
Was this page helpful?