0

i am struggling with playing sounds in my loop. I am getting user value and depending on the amount of input data exact sound is being repeated. Minimal example code:

 auto sound = new QMediaPlayer();
 sound->setMedia(QUrl("path to sound.wav"));
 //(...) 
 QString input = getInputFromUser();
    for (const auto &character : text) {
        //depending of character play some sound:
        sound->play();
    }

If i provide for example "ffff" input, i hear sound only once instead of four times. Why? I suspect that while short sound is being played, whole QString is being iterated through.

So how can i force loop to wait for sound to end and then let it do next iteration?

Thanks.

JoJo
  • 43
  • 1
  • 4

0 Answers0