sendAudioMessage method
dynamic
sendAudioMessage(
- String filePath,
- bool isRecorded,
- String duration,
- BuildContext context,
Implementation
sendAudioMessage(String filePath, bool isRecorded, String duration,
BuildContext context) async {
var busyStatus = !profile.isGroupProfile.checkNull()
? await Mirrorfly.isBusyStatusEnabled()
: false;
if (!busyStatus.checkNull()) {
var replyMessageId = Constants.emptyString;
if (isReplying.value) {
replyMessageId = replyChatMessage.messageId;
}
isUserTyping(false);
isReplying(false);
debugPrint("Sending Audio path $filePath");
var file = File(filePath);
var fileExists = await file.exists();
debugPrint("filepath exists $fileExists");
Mirrorfly.sendAudioMessage(
profile.jid!, filePath, isRecorded, duration, replyMessageId)
.then((value) {
mirrorFlyLog("Audio Message sent", value);
ChatMessageModel chatMessageModel = sendMessageModelFromJson(value);
chatList.insert(0, chatMessageModel);
scrollToBottom();
return chatMessageModel;
});
} else {
//show busy status popup
messageObject = MessageObject(
toJid: profile.jid.toString(),
replyMessageId: (isReplying.value) ? replyChatMessage.messageId : Constants.emptyString,
messageType: Constants.mAudio,
file: filePath,
isAudioRecorded: isRecorded,
audioDuration: duration);
if (context.mounted) showBusyStatusAlert(disableBusyChatAndSend, context);
}
}