There is a MessageKit's example from Github, about how we could use chat audio item...It looks like this:
private struct ChatAudioItem: AudioItem {
var url: URL
var size: CGSize
var duration:Float
init(url: URL) {
self.url = url
self.size = CGSize(width: 160, height: 35)
// compute duration
let audioAsset = AVURLAsset(url: url)
self.duration = Float(CMTimeGetSeconds(audioAsset.duration))
}
}
I wonder if there is some more performant way to do this. If we have 20 voice messages, one after another, this code will cause a delay of few seconds on iPhone XS.
I am sure that this is the issue, cause if I remove current code, and replace it with self.duration = 0, it loads instantly.
So can somebody give some suggestion? I guess I could use async loading of duration property of AVURLAsset. But that kinda improved performance, but still its a bit laggy.
Also I can't get this data currently from my backed, so I wonder if there is some way to improve performance of this.
There is a MessageKit's example from Github, about how we could use chat audio item...It looks like this:
I wonder if there is some more performant way to do this. If we have 20 voice messages, one after another, this code will cause a delay of few seconds on iPhone XS.
I am sure that this is the issue, cause if I remove current code, and replace it with self.duration = 0, it loads instantly.
So can somebody give some suggestion? I guess I could use async loading of duration property of AVURLAsset. But that kinda improved performance, but still its a bit laggy.
Also I can't get this data currently from my backed, so I wonder if there is some way to improve performance of this.