NIMMessage.audioEmptyMessage constructor

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

Implementation

factory NIMMessage.audioEmptyMessage(
    {required String sessionId,
    required NIMSessionType sessionType,
    required String filePath,
    required int fileSize,
    required int duration,
    String? displayName,
    String? base64,
    NIMNosScene nosScene = NIMNosScenes.defaultIm}) {
  /// 最低显示1秒
  if (duration < 1000) duration = 1000;

  var extension = filePath.split('.').last;

  var audioAttachment = NIMAudioAttachment(
      path: filePath,
      size: fileSize,
      duration: duration,
      base64: base64,
      extension: extension,
      nosScene: nosScene);
  return NIMMessage(
      messageDirection: NIMMessageDirection.outgoing,
      messageType: NIMMessageType.audio,
      timestamp: new DateTime.now().millisecondsSinceEpoch,
      status: NIMMessageStatus.sending,
      sessionId: sessionId,
      sessionType: sessionType,
      messageAttachment: audioAttachment);
}