createAudioMessage static method

Future<NIMResult<NIMMessage>> createAudioMessage(
  1. {required String sessionId,
  2. required NIMSessionType sessionType,
  3. required String filePath,
  4. required int fileSize,
  5. required int duration,
  6. String? base64,
  7. String? displayName,
  8. NIMNosScene nosScene = NIMNosScenes.defaultIm}
)

创建音频消息 displayName 字段无效,不建议使用 base64 字段为web端专用,web端filePath 可传空字符串

Implementation

static Future<NIMResult<NIMMessage>> createAudioMessage(
    {required String sessionId,
    required NIMSessionType sessionType,
    required String filePath,
    required int fileSize,
    required int duration,
    String? base64,
    String? displayName,
    NIMNosScene nosScene = NIMNosScenes.defaultIm}) async {
  var message = NIMMessage.audioEmptyMessage(
      sessionId: sessionId,
      sessionType: sessionType,
      filePath: filePath,
      fileSize: fileSize,
      base64: base64,
      duration: duration,
      displayName: displayName,
      nosScene: nosScene);
  return NimCore.instance.messageService._createMessage(message: message);
}