Skip to main content

Short Video Message

Users can send short videos via IMKit's gallery (local album) or the short video plugin. These messages will appear in the message list component of the chat UI. By default, the plugin sends messages containing the short video content object SightMessage (type identifier: RC:SightMsg).

(width=220) (width=220)

Limitations

The short video feature currently has the following restrictions:

  • IMKit only supports sending short video messages in one-to-one chat and group chat.
  • When using the short video plugin for recording, the maximum duration is 10 seconds.
  • For video files selected from the local album, note that the server-side default maximum duration is 2 minutes. Contact sales to adjust this limit.
  • Only H.264 + AAC encoded video files are supported, as IMKit's short video recording and playback only implement this encoding combination.
  • For App Keys using IM Flagship Edition or IM Premium Edition, file storage duration defaults to 180 days (excluding short video files, which are stored for 7 days). Note that the IM Commercial Edition (discontinued) defaults to 7 days. For details on IM Flagship Edition or IM Premium Edition features and pricing, see the RC official pricing page and billing documentation.

Usage

We recommend integrating the IMKit short video plugin for this feature.

Integrating the Short Video Plugin

The IMKit short video plugin handles message registration, recording, and playback. Once integrated, the short video option automatically appears in the extension panel of the input area for one-to-one and group chats.

  1. Add the short video dependency in your app's build.gradle file.

    dependencies{
    // The plugin version must match the main SDK version.
    api 'cn.rongcloud.sdk:sight:x.y.z'
    }
tip

SDK versions may vary (e.g., x.y.z.h). Check the RC SDK download page or RC's Maven repository for the latest version.

  1. Register the SightExtensionModule with IMKit's input area RongExtension via RongExtensionManager. This module registers SightMessage with IMLib and adds the short video plugin SightPlugin to the extension panel.

    RongExtensionManager.getInstance().registerExtensionModule(new SightExtensionModule());

Selecting Short Videos from Local Album

tip

Prerequisite: After integrating the IMKit short video plugin, the plugin internally registers the SightMessage type with IMLib. Complete the plugin integration first; otherwise, the SDK won't recognize short video messages.

By default, the IMKit gallery plugin ImagePlugin excludes video files, preventing users from selecting them for sending.

You can modify the global configuration to include video files in the local album.

RongConfigCenter.featureConfig().rc_media_selector_contain_video = true;

To adjust this via XML resources, create an rc_config.xml file in your app's res/values directory and add:

<bool name="rc_media_selector_contain_video">true</bool>

If your project doesn't use the IMKit short video plugin but still needs to support sending short videos locally, manually register SightMessage with IMLib (otherwise, the SDK can't send these messages). You'll also need to implement recording and playback (handled in the chat UI message click event).

// Register SightMessage—must be done before connection
RongIMClient.registerMessageType(SightMessage.class);

Sending Short Video Messages

Users can tap the + button in the input bar to expand the extension panel, then select the Image or Short Video icon to send a short video message.

extension(width=250)

Customization

Changing the Short Video Save Location

When users long-press to save a received short video in the chat UI, the SDK defaults to /RongCloud/Video/. To modify this globally, create an rc_config file in your app's res/values directory:

<string name="rc_file_default_saved_path">/RongCloud/Video/</string>

Adjusting Short Video Compression Quality

Short videos are compressed to 544 × 960 resolution. The first frame generates a thumbnail for display in the chat UI. By default, the SDK uploads thumbnails at 30% of the original quality (max 240 px on the longest side).

We recommend keeping the default compression settings. To adjust them, see How to Modify SDK Default Image/Video Compression Settings.

Customizing Short Video Message UI

IMKit generates and sends short video messages (RC:SightMsg) by default, displayed via the SightMessageItemProvider template in the message list.

All message templates inherit from BaseMessageItemProvider<CustomMessage>. You can either:

  • Subclass BaseMessageItemProvider<CustomMessage> to create a custom template.
  • Replace the style resources, string resources, or icons referenced in the default template (see resources in IMKit's SightMessageItemProvider.java).

Example: Copy all content from IMKit's rc_item_sight_message.xml to your project's /res/layout/rc_item_sight_message.xml and modify styles. Do not remove default controls or alter View IDs.

For recording/playback UI modifications, refer to the IMKit short video plugin source code Sight.

Dynamically Hiding the Short Video Option

To hide the short video option in the extension panel dynamically, create a custom MyExtensionConfig class extending DefaultExtensionConfig, then override getPluginModules(). See Input Area.