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
AlarmProcess->setArguments("playwave"); // the player
AlarmProcess->addArgument("alarm.wav"); // the file
QProcess *AlarmProcess;
AlarmProcess = new QProcess (this);
AlarmProcess->setArguments("playwave"); // the player
AlarmProcess->addArgument("alarm.wav"); // the file
To copy to clipboard, switch view to plain text mode
playing
AlarmProcess->start();
AlarmProcess->start();
To copy to clipboard, switch view to plain text mode
stopping
AlarmProcess->tryTerminate(); // it actualy waits for the process to finish
// then it terminates
AlarmProcess->tryTerminate(); // it actualy waits for the process to finish
// then it terminates
To copy to clipboard, switch view to plain text mode
you can also use:
AlarmProcess->Terminate();
AlarmProcess->Terminate();
To copy to clipboard, switch view to plain text mode
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()) );
connect( AlarmProcess, SIGNAL(processExited()),
this, SLOT(exitedSlot()) );
To copy to clipboard, switch view to plain text mode
and to implement the signal hendler
void FormMain::exitedSlot()
{
if (AlmSound) // flag - should the sound be played again
AlarmProcess->start();
}
void FormMain::exitedSlot()
{
if (AlmSound) // flag - should the sound be played again
AlarmProcess->start();
}
To copy to clipboard, switch view to plain text mode
Cheers, chombium
Bookmarks