Skip to main content
Version: v4

Media Recorder

CometChatMediaRecorder is a class that allows users to record and send audio messages. It has a start button to start recording, a stop button to stop recording, a play button to play the recorded message, a pause button to pause the recorded message, a submit button to submit the recorded message and a close button to close the media recorder.

Usage

CometChatMediaRecorder can be used as a child view inside another view or be launched with a bottom sheet.

if let cometChatMediaRecorder = UIStoryboard(name: "CometChatMediaRecorder", bundle: CometChatUIKit.bundle).instantiateViewController(identifier: "CometChatMediaRecorder") as? CometChatMediaRecorder {
self.present(cometChatMediaRecorder, animated: true)
}

Properties

PropertyTypeDescription
mediaRecorderStyleMediaRecorderStyleused to customize the appearance of CometChatMediaRecorder
startIconUIImageused to set the start icon
playIconUIImageused to set the play icon
pauseIconUIImageused to set the pause icon
closeIconUIImageused to set the close icon
stopIconUIImageused to set the stop icon
submitIconUIImageused to set the submit icon
pauseIconTintUIColorused to set the color of pause icon
playIconTintUIColorused to set the color of play icon
deleteIconTintUIColorused to set the color of delete icon
submitIconTintUIColorused to set the color of submit icon
startIconTintUIColorused to set the color of start icon
stopIconTintUIColorused to set the color of stop icon
timerTextFontUIFontused to set the font of timer text
timerTextColorUIColorused to set the color of timer text
onSubmit(String) -> VoidonSubmit is used to set the action to be performed when submit icon is tapped
onClose() -> ()onClose is used to set the action to be performed when close icon is tapped

mediaRecorderStyle

A MediaRecorderStyle object is used to customize the appearance of CometChatMediaRecorder.

if let cometChatMediaRecorder = UIStoryboard(name: "CometChatMediaRecorder", bundle: CometChatUIKit.bundle).instantiateViewController(identifier: "CometChatMediaRecorder") as? CometChatMediaRecorder {
let mediaRecorderStyle = MediaRecorderStyle()
mediaRecorderStyle.set(pauseIconTint: CometChatTheme.palatte.primary)
mediaRecorderStyle.set(playIconTint: CometChatTheme.palatte.primary)
mediaRecorderStyle.set(deleteIconTint: CometChatTheme.palatte.error)
mediaRecorderStyle.set(timerTextFont: CometChatTheme.typography.text1)
mediaRecorderStyle.set(timerTextColor: CometChatTheme.palatte.primary)
mediaRecorderStyle.set(submitIconTint: CometChatTheme.palatte.primary)
mediaRecorderStyle.set(startIconTint: CometChatTheme.palatte.secondary)
mediaRecorderStyle.set(stopIconTint: CometChatTheme.palatte.error)
cometChatMediaRecorder.set(style: mediaRecorderStyle)

cometChatMediaRecorder.setSubmit(onSubmit: {url in
print("file url", url)
})
self.present(cometChatMediaRecorder, animated: true)