massoudss / waveformSeekBar

Android Waveform SeekBar library
488 stars 81 forks source link

setSampleFrom is freezing ui #37

Closed Arsenii76 closed 2 years ago

Arsenii76 commented 2 years ago

I'm building a music player and I'm facing a problem where when I call setSampleFrom with a new song my ui freezes. the problem is 100% with this, because if I remove that line, everything works correctly. the song itself is 4 minutes

massoudss commented 2 years ago

You have to create samples in background thread and apply it on view in UI thread

Background thread:

val sample = WaveformOptions. getSampleFrom(...)

UI thread:

waveformSeekBar.sample = sample