Replies: 4 comments
-
I think AVURLAsset downloads the asset to check the duration even if the user doesn't want to play that audio, so I opted for storing the AVAudioRecorder final duration before stopping it. There might be better solutions out there but with my current skills, this is what I was able to come up with. |
Beta Was this translation helpful? Give feedback.
-
@mendimr Ok, but when you store it, then you loose it when you dismiss the app from memory. Sending it to a server along with file would be one option, but that is something I can't do right now. Nor I want to store all durations on disk... I tried loading durations in async way... But that brings other issues with UI updates and UX. I guess I am looking for a quick fix for something that requires a bit more work :) |
Beta Was this translation helpful? Give feedback.
-
lets look at #1566 |
Beta Was this translation helpful? Give feedback.
-
What I did to address this issue was to save the duration of a message in database (both locally and on the server). So when a user sends a voice message, I store the duration in the metadata of the message. On the receiving end, when re-creating the message object, I do not load the AVAsset (too ressource intensive if you need to load multiple messages), I simply assign the duration of the AudioItem from the duration value saved as metadata. |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions