(Non)concurrency-related problem

That’s not problem with Crystal concurrency, but what you are doing is invoking async operation which runs its own thread (external to crystal), so using a spawn doesn’t make any difference.

you should be invoking Sound#status in a loop with some delay and when you library is done with playing, you can continue with your current logic of sending some value to Channel.

so pseudo code like below

  ......

  loop do
   break if sound.status == SoundSource::Status::Stopped
   sleep some_duration
 end
  ........

HIH

4 Likes