|  | Home · Overviews · Examples |

# QSound Class Reference
[com.trolltech.qt.gui module]

The `QSound` class provides access to the platform audio facilities. More...

Inherits `QObject`.

## Detailed Description

The `QSound` class provides access to the platform audio facilities.

Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static `play` function:

        QSound::play("mysounds/bells.wav");

Alternatively, create a `QSound` object from the sound file first and then call the `play` slot:

        QSound bells("mysounds/bells.wav");
        bells.play();

Once created a `QSound` object can be queried for its `fileName` and total number of `loops` (i.e. the number of times the sound will play). The number of repetitions can be altered using the `setLoops` function. While playing the sound, the `loopsRemaining` function returns the remaining number of repetitions. Use the `isFinished` function to determine whether the sound has finished playing.

Sounds played using a `QSound` object may use more memory than the static `play` function, but it may also play more immediately (depending on the underlying platform audio facilities). Use the static `isAvailable` function to determine whether sound facilities exist on the platform. Which facilities that are actually used varies:

Platform | Audio Facility
--- | ---
Microsoft Windows | The underlying multimedia system is used; only WAVE format sound files are supported.
X11 | The Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files.
Mac OS X | NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt/Mac.
Qtopia Core | A built-in mixing sound server is used, accessing `/dev/dsp` directly. Only the WAVE format is supported.

Note that `QSound` does not support resources. This might be fixed in a future Qt version.