sendMediaMessage static method
      
Future<MediaMessage?> 
sendMediaMessage(
    
- MediaMessage mediaMessage, {
- required dynamic onSuccess(- MediaMessage message
 
- required dynamic onError(- CometChatException excep
 
send a media message like photos, videos & files.
filePath The file path object to be sent,  need to prefix the path with 'file://' for IOS.
messageType type of the message that needs to be sent image,video,audio,file
receiver Group or User class from which UID and GUID will be fetched according to need.
receiverType ype of the receiver to whom the message is to be sent user,group.
On success, you will receive an object of the MediaMessage class containing all the information related to the sent media message.
The method could throw PlatformException with error codes specifying the cause
Implementation
static Future<MediaMessage?> sendMediaMessage(MediaMessage mediaMessage,
    {required Function(MediaMessage message)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    bool hasAttachment = false;
    String? attachmentFileName;
    String? attchemntFileExtension;
    String? attachmentFileUrl;
    String? attachmentMimeType;
    if (mediaMessage.attachment != null) {
      hasAttachment = true;
      attachmentFileName = mediaMessage.attachment?.fileName;
      attchemntFileExtension = mediaMessage.attachment?.fileExtension;
      attachmentFileUrl = mediaMessage.attachment?.fileUrl;
      attachmentMimeType = mediaMessage.attachment?.fileMimeType;
    }
    if (mediaMessage.attachments != null && mediaMessage.attachments!.isNotEmpty) {
      hasAttachment = true;
    }
    List<Map<String, dynamic>> attachmentsList = [];
    if(mediaMessage.attachments != null && mediaMessage.attachments!.isNotEmpty) {
      for (var messageAttachment in mediaMessage.attachments!) {
        attachmentsList.add(messageAttachment.toJson());
      }
    }
    final result = await channel.invokeMethod('sendMediaMessage', {
      'receiverId': mediaMessage.receiverUid,
      'receiverType': mediaMessage.receiverType,
      'filePath': Platform.isIOS ? '${mediaMessage.file}' : mediaMessage.file,
      'messageType': mediaMessage.type,
      'caption': mediaMessage.caption,
      'metadata': json.encode(mediaMessage.metadata ?? {}),
      'hasAttachment': hasAttachment,
      'attachmentFileName': attachmentFileName,
      'attchemntFileExtension': attchemntFileExtension,
      'attachmentFileUrl': attachmentFileUrl,
      "attachmentMimeType": attachmentMimeType,
      'muid': mediaMessage.muid,
      'tags': mediaMessage.tags,
      'parentMessageId': mediaMessage.parentMessageId,
      'attachments': attachmentsList,
      'files': mediaMessage.files,
    });
    final res = MediaMessage.fromMap(result);
    if (onSuccess != null) onSuccess(res);
    return res;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}