PDA

View Full Version : QSound Unavailable



superutsav
29th January 2006, 05:01
Hi

I'm trying to use sounds in my application... However, QSound::isAvailable returns a FALSE. QApplication::beep() doesn't work either.
Why is this?? is there any way i can still play sounds?? I am working on a Mandrake 10 machine.

Thanks
superutsav

wysota
29th January 2006, 10:02
You have to have Qt compiled with NAS support (and of course have all NAS dependencies installed).

chombium
3rd February 2006, 16:38
If you don't want to install NAS and recompile QT with nas support you
can use QProcess and start external app that will play the sound file

Example (QT3.x):


the cration of the process


QProcess *AlarmProcess;
AlarmProcess = new QProcess (this);
AlarmProcess->setArguments("playwave"); // the player
AlarmProcess->addArgument("alarm.wav"); // the file


playing


AlarmProcess->start();


stopping


AlarmProcess->tryTerminate(); // it actualy waits for the process to finish
// then it terminates


you can also use:


AlarmProcess->Terminate();

but it terminates the process immediately, and the memory used might not be cleaned completely.

If you need to play the sound repeatedly you should connect the processExited() signal


connect( AlarmProcess, SIGNAL(processExited()),
this, SLOT(exitedSlot()) );


and to implement the signal hendler


void FormMain::exitedSlot()
{
if (AlmSound) // flag - should the sound be played again
AlarmProcess->start();
}


Cheers, chombium