QSound play sounds one after another

378 Views Asked by At

I'm working on a program that receive an event every 200ms, and I want to play a sound depending on the last event received when the last sound playing is finished. Unfortunately the isFinished() function doesn't work on windows for unlooped sounds.

So I'm trying to find a way to wait until a sound has finished playing before playing an other one from the last event (like a LIFO with only one element).

I manage to do that :

QSound *sound[5];
int select, lastSelect;

if(sound[lastSelect]->loopsRemaining() >=1)
  sound[lastSelect]->stop();
else {
  sound[select]->setLoops(2);
  sound[select]->play();
  lastSelect = select;
}

But it's queuing the sounds and that's not what I want.
Otherwise I can do it by setting the number of loop to 2 but it plays the sound twice before playing the next one.

Do you have any idea how to do it ?

0

There are 0 best solutions below