Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished with a single call:
A second API is provided in which a QSound object is created from a sound file and is played later:
.PP
.nf
.br
QSound bells("mysounds/bells.wav");
.br
.br
bells.play();
.br
.fi
.PP
Sounds played using the second model may use more memory but play more immediately than sounds played using the first model, depending on the underlying platform audio facilities.
.PP
On Microsoft Windows the underlying multimedia system is used; only WAVE format sound files are supported.
.PP
On X11 the Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files.
.PP
On Macintosh, ironically, we use QT (QuickTime) for sound, this means all QuickTime formats are supported by Qt/Mac.
.PP
The availability of sound can be tested with QSound::isAvailable().
Returns TRUE if sound facilities exist on the platform; otherwise returns FALSE. An application may choose either to notify the user if sound is crucial to the application or to operate silently without bothering the user.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Starts the sound playing. The function returns immediately. Depending on the platform audio facilities, other sounds may stop or may be mixed with the new sound.
.PP
The sound can be played again at any time, possibly mixing or replacing previous plays of the sound.
.SH "void QSound::setLoops ( int l )"
Sets the sound to repeat \fIl\fR times when it is played. Passing the value -1 will cause the sound to loop indefinitely.
.PP
See also loops().
.SH "void QSound::stop ()\fC [slot]\fR"
Stops the sound playing.
.PP
On Windows the current loop will finish if a sound is played in a loop.