Custom short video message

Implement the short video feature using the SDK’s existing mechanisms. Here’s how:

  1. Start by understanding the SDK’s custom message mechanism.

  2. Custom short video messages must also inherit from RCMessageContent. Add message attributes as needed, such as localPath for the local file path and mediaUrl for the HTTP/HTTPS address after uploading to the file server. Include other attributes like video size, file name, and thumbnail as required.

  3. The SDK doesn’t provide interfaces for shooting and playing short videos—developers need to implement these themselves.

  4. After shooting, upload the video to your application server, then construct a custom video message and send it using the following method:

    //RCIM.h
    
    /*!
    
     Send a message (all messages except image and file messages), which will automatically update the UI
    
     @param conversationType The conversation type of the message
     @param targetId The target conversation ID of the message
     @param content The content of the message
     @param pushContent The remote push content to display when the recipient is offline
     @param pushData The non-display data to include in the remote push when the recipient is offline
     @param successBlock Callback for successful message sending [messageId: The ID of the message]
     @param errorBlock Callback for failed message sending [nErrorCode: The error code for the failure, messageId: The ID of the message]
    
     @return The sent message entity
    
     @discussion When the recipient is offline and allows remote push, they will receive a remote push.
    
     The remote push contains two parts: pushContent for display and pushData for non-display data.
     For SDK-built-in message types, if you set pushContent and pushData to nil, the default push format will be used for remote push.
     For custom message types, you need to set pushContent and pushData to define the push content, otherwise, no remote push will be sent.
    
     @warning If you use IMKit, the SDK will automatically update the UI when sending a message with this method.
    
     If you use IMLib, use the same method in RCIMClient to send a message, which will not automatically update the UI.
    
     */
    - (RCMessage *)sendMessage:(RCConversationType)conversationType
     targetId:(NSString *)targetId
     content:(RCMessageContent *)content
     pushContent:(NSString *)pushContent
     pushData:(NSString *)pushData
     success:(void (^)(long messageId))successBlock
     error:(void (^)(RCErrorCode nErrorCode, long messageId))errorBlock;
    

Here are some potential issues and solutions during development:

  1. For thumbnails, the SDK doesn’t provide an interface to upload an image and return a URL. You can upload the thumbnail to your server, similar to mediaUrl, and load it as a network image. Alternatively, use base64 encoding for the thumbnail, similar to how the SDK handles image messages. This involves converting the thumbnail to base64 when sending and decoding it when receiving.
  2. You may also need to handle progress updates for video uploads. Since videos are uploaded to your server, you’ll need to manage both the progress and UI updates yourself.