mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
partial development in add audio message support
This commit is contained in:
@@ -26,6 +26,7 @@ import UIKit
|
||||
import MapKit
|
||||
import MessageKit
|
||||
import MessageInputBar
|
||||
import AVFoundation
|
||||
|
||||
final class BasicExampleViewController: ChatViewController {
|
||||
|
||||
@@ -96,7 +97,38 @@ extension BasicExampleViewController: MessagesDisplayDelegate {
|
||||
|
||||
return LocationMessageSnapshotOptions(showsBuildings: true, showsPointsOfInterest: true, span: MKCoordinateSpan(latitudeDelta: 10, longitudeDelta: 10))
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Audio Messages
|
||||
|
||||
func audioTintColor(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UIColor {
|
||||
return self.isFromCurrentSender(message: message) ? .white : UIColor(red: 15/255, green: 135/255, blue: 255/255, alpha: 1.0)
|
||||
}
|
||||
|
||||
// func configureAudioCell(_ audioCell: AudioMessageCell, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
|
||||
// // if audio player is in pause or currently playing configure the cell accordingly
|
||||
// guard let player = audioPlayer else {
|
||||
// return
|
||||
// }
|
||||
// switch message.kind {
|
||||
// case .audio(let item):
|
||||
// if item.url.absoluteString == player.url?.absoluteString { // make sure you configure the right cell
|
||||
// let totalDuration = self.audioPlayer?.duration ?? 0.0
|
||||
// let currentTime = self.audioPlayer?.currentTime ?? 0.0
|
||||
// let percent = (totalDuration != 0) ? (Float(currentTime/totalDuration)) : 0.0
|
||||
// audioCell.updateProgress(percent: percent, duration: currentTime)
|
||||
// // restart audio timer since the cell was reconfigured
|
||||
// if self.audioTimer?.isValid == true {
|
||||
// self.audioTimer?.invalidate()
|
||||
// print("Restart timer with new cell: \(audioCell)")
|
||||
// self.audioTimer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(ChatViewController.didFireAudioTimer(_:)), userInfo: audioCell, repeats: true)
|
||||
// } else {
|
||||
// audioCell.pasue() // if the audio timer is invalidate it means the cell is in pause
|
||||
// }
|
||||
// }
|
||||
// default: break
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// MARK: - MessagesLayoutDelegate
|
||||
|
||||
Reference in New Issue
Block a user