This class encapsulates a sound file.
More...
#include "gsound.h"
Public Member Functions | |
GSound(string filename) | |
Creates a Sound object by reading in the contents of the specified file or URL. More... | |
~GSound() | |
Frees the memory associated with the sound. More... | |
void | play() |
Starts playing the sound. More... | |
Static Public Member Functions | |
static long | getDuration() |
Returns the duration of the sound clip that is currently playing. More... | |
static int | getVolume() |
Returns the overall audio volume from 0 (silence) to 100 (full volume). More... | |
static void | pause() |
Pauses playing the sound, if it is playing. More... | |
static void | playSound(string filename) |
Starts playing the sound if not playing, or unpauses if paused. More... | |
static void | setVolume(int volume) |
Sets the overall audio volume from 0 (silence) to 100 (full volume). More... | |
static void | stop() |
Stops playing the sound, if it is playing. More... | |
This class encapsulates a sound file.
The sound file is specified in the constructor and must be a file in either the current directory or a subdirectory named sounds
.
The following code, for example, plays the sound file ringtone.wav
:
GSound ringtone("ringtone.wav"); ringtone.play(); *
You can also use the static playSound
method:
GSound::playSound("ringtone.wav"); *
GSound | ( | string | filename | ) |
Creates a Sound
object by reading in the contents of the specified file or URL.
|
virtual |
Frees the memory associated with the sound.
|
static |
Returns the duration of the sound clip that is currently playing.
If no clip is playing, returns 0.
|
static |
Returns the overall audio volume from 0 (silence) to 100 (full volume).
The default volume is 100.
|
static |
Pauses playing the sound, if it is playing.
If paused, calling play() again will unpause.
void play | ( | ) |
Starts playing the sound.
This call returns immediately without waiting for the sound to finish.
|
static |
Starts playing the sound if not playing, or unpauses if paused.
This call returns immediately without waiting for the sound to finish.
|
static |
Sets the overall audio volume from 0 (silence) to 100 (full volume).
The default volume is 100.
|
static |
Stops playing the sound, if it is playing.