EMMessage.createVoiceSendMessage constructor

EMMessage.createVoiceSendMessage(
  1. {required String targetId,
  2. required String filePath,
  3. int duration = 0,
  4. int? fileSize,
  5. String? displayName,
  6. ChatType chatType = ChatType.Chat}
)

创建一条待发送的语音消息。

Param targetId 消息接收方,可以是:

  • 用户:用户 ID;
  • 群组:群组 ID;
  • 聊天室:聊天室 ID。

Param filePath 文件路径。

Param duration 语音时长,单位为秒。

Param fileSize 语音文件大小,单位是字节。

Param displayName 文件名。

Param chatType 聊天类型, 默认为单聊,如果是群聊或者聊天室,可以参考ChatType

Return 消息体实例。

Implementation

EMMessage.createVoiceSendMessage({
  required String targetId,
  required String filePath,
  int duration = 0,
  int? fileSize,
  String? displayName,
  ChatType chatType = ChatType.Chat,
}) : this.createSendMessage(
          chatType: chatType,
          to: targetId,
          body: EMVoiceMessageBody(
              localPath: filePath,
              duration: duration,
              fileSize: fileSize,
              displayName: displayName));