createSoundMessage

Introduction

Create a sound or audio message.

To create an audio message, you need to get the local audio file path and audio duration first, the latter of which can be used for display on the receiver UI.

During message sending, the audio is uploaded to the server, and the upload progress is called back. The message is sent after the audio is uploaded successfully.

For details, you can referring to this document.

Parameter details

Parameter name Parameter type Required Platform Description
soundPath String yes All Absolute path of the local audio file.
duration int yes All The duration of the audio.

Returned template

V2TimValueCallback<V2TimMsgCreateInfoResult>

{
    code: int,
    desc: String,
    data: {
        id: String,
        messageInfo: V2TimMessage,
    }
}

Return value details

name type description
code int Request result: Error codes. 0 means success.
desc String The description of the failure.
data V2TimMsgCreateInfoResult The sound message created.

Code example

    V2TimValueCallback<V2TimMsgCreateInfoResult> createSoundMessageRes =
        await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .createSoundMessage(
              soundPath: "The absolute path of the sound file.", 
              duration: 10, 
            );
    if (createSoundMessageRes.code == 0) {
      String? id = createSoundMessageRes.data?.id;
      V2TimValueCallback<V2TimMessage> sendMessageRes = await TencentImSDKPlugin
          .v2TIMManager
          .getMessageManager()
          .sendMessage(id: id!, receiver: "userID", groupID: "groupID");
      if (sendMessageRes.code == 0) {
      }
    }

results matching ""

    No results matching ""