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
On Qt/Embedded, a built-in mixing sound server is used, which accesses \fC/dev/dsp\fR directly. Only the WAVE format is supported.
.PP
The availability of sound can be tested with QSound::isAvailable().
This may use more memory than the static \fCplay\fR function.
.PP
The \fIparent\fR and \fIname\fR arguments (default 0) are passed on to the QObject constructor.
.SH "QSound::~QSound ()"
Destroys the sound object. If the sound is not finished playing stop() is called on it.
.PP
See also stop() and isFinished().
.SH "bool QSound::available ()\fC [static]\fR"
Returns TRUE if sound support is available; otherwise returns FALSE.
.SH "QString QSound::fileName () const"
Returns the filename associated with the sound.
.SH "bool QSound::isAvailable ()\fC [static]\fR"
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.