There should rarely be a need for playing a sound. Sounds should be used only in games, and they should never be required for the use of your program unless, of course, your program's purpose is to play sound. Do not play sounds in the event of an error; that is the purpose of KNotify, which will be discussed shortly.
Playing sound is a simple command:
You can also use this in a slot:
In this example, the file $KDEDIR/share/sounds/foo.wav is played whenever button is clicked.
You can also send absolute filenames, in which case it will ignore the KDEDIR/share/sounds path.
This is not a superbly fast class, because it plays sounds via DCOP. For true real-time sound, you should use MCOP. For more information on multimedia, see Chapter 14, "Multimedia."