dmrschmidt / DSWaveformImage

Generate waveform images from audio files on iOS, macOS & visionOS in Swift. Native SwiftUI & UIKit views.
MIT License
978 stars 109 forks source link

Waveform is changing every time I scroll my chat message's table view how to manage it ? #60

Closed darkcodes00 closed 1 year ago

darkcodes00 commented 1 year ago

After assigning the URL of the audio file(Downloaded URL path) to waveformimageview. My table has multiple cells which have waveformimageview. When I scroll up or scroll down with multiple cell tables every cell's waveform is changing. despite of having already downloaded audio file.

dmrschmidt commented 1 year ago

Hey darkcodes00,

thanks for using the library and reporting your issue. I have a few clarifying questions:

Just some speculative thoughts at the end:

If they scroll out of view completely, then it would be expected that they have to be redrawn. That’s to do with how a UITableView works.

If they literally change how they look, that would - at first glance - sound like an application later bug. The same input file will always generate the exact same looking waveform. Unless the frame changes, which then causes the calculation to use different dimensions. Frame changes fyi also cause re-draws.

Generally speaking, it may be advisable in your case to approach the problem differently. If you are having multiple (how many?) waveforms inside a table view, you would inevitably run into the first problem. To avoid that, you can use WaveformImageDrawer directly. Pre-render all waveform images, cache them locally and show those inside your UITableView.

The self-drawing classes are optimized for ease of use, not performance. On 2. Mar 2023 at 00:44 +0800, Darshan Virani @.***>, wrote:

After assigning the URL of the audio file(Downloaded URL path) to waveformimageview. My table has multiple cells which have waveformimageview. When I scroll up or scroll down with multiple cell tables every cell's waveform is changing. despite of having already downloaded audio file. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

dmrschmidt commented 1 year ago

Closing this for now since I didn't hear back. Feel free to re-open if there's still anything I can help with.