Skip to main content

Audio Cell

Overview

The LMChatAudioViewCell is a subclass of LMChatMessageCell designed to display audio messages. It encapsulates LMChatAudioContentView to handle the presentation of audio content, including both audio files and voice notes.

UI Components

  • audioMessageView: An instance of LMChatAudioContentView that handles the display and interaction of audio content within the cell.

Methods

  • setData(with:index:): Populates the cell with data from a ContentModel and configures the "Show More" callback.
  • resetAudio(): Resets the audio playback state of the audio content view.
  • seekSlider(to:url:): Updates the seeker position for a specific audio URL in the audio content view.
  • updateForSeeMore(for:index:): Triggers the "See More" action for audio attachments.

Customization

CustomAudioViewCell.swift
class CustomAudioViewCell: LMChatAudioViewCell {
override func setupViews() {
super.setupViews()
// Add custom views or modify existing ones
}

override func setData(with data: ContentModel, index: IndexPath) {
super.setData(with: data, index: index)
// Customize data population or add additional configuration
}

override func updateForSeeMore(for messageID: String, index: IndexPath) {
super.updateForSeeMore(for: messageID, index: index)
// Add custom behavior when "See More" is triggered
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.chatMessageAudioCell = CustomAudioViewCell.self
// ...
return true
}