[Qt-interest] play audio in thread

Moises Augusto jr.jorro at gmail.com
Fri Mar 5 01:47:30 CET 2010


Hi all,

I need to play a small audio in my app. On Linux, I do a
 the loop in app, and call the run() the thread:

thread::run() {
       Phonon::MediaObject *audio =
Phonon::createPlayer(Phonon::MusicCategory,

Phonon::MediaSource(QDir::homePath() + path_som));

       audio->play();
       sleep(intervalo);
       audio->stop();
}

in WINDOWS :@ dosen't work. When I put exec() at the end of the run(),
it plays only once. (he does ???). but after the crash screen.

On Linux if you put exec() hangs too.

I need to touch the thread for wearing a counter in the main program.

The question is: Is there a different way I play the audio? Or I
I'm doing something wrong in the thread so as not to run in windows?

thanks

Moises



More information about the Qt-interest-old mailing list