wxSound

This class represents a short sound (loaded from Windows WAV file), that can be stored in memory and played. Currently this class is implemented on Windows and Unix (and uses either Open Sound System (#2) or Simple DirectMedia Layer (#2)).

Derived from

wxObject

Include files

<wx/sound.h>



wxSound::wxSound



wxSound(void)

Default constructor.



wxSound(const wxString& fileName, bool isResource = false)

Constructs a wave object from a file or resource. Call wxSound::IsOk to determine whether this succeeded.

Parameters

fileName
The filename or Windows resource.

isResource
TRUEif fileName is a resource, FALSEif it is a filename.



wxSound::~wxSound



~wxSound(void)

Destroys the wxSound object.



wxSound::Create



bool Create(const wxString& fileName, bool isResource = FALSE)

Constructs a wave object from a file or resource.

Parameters

fileName
The filename or Windows resource.

isResource
TRUEif fileName is a resource, FALSEif it is a filename.

Return value

TRUEif the call was successful, FALSEotherwise.



wxSound::IsOk

bool IsOk(void) const

Returns TRUEif the object contains a successfully loaded file or resource, FALSEotherwise.



wxSound::IsPlaying

static bool IsPlaying(void) const

Returns TRUEif a sound is played at the moment.



wxSound::Play

bool Play(unsigned flags = wxSOUND_ASYNC) const



static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC)

Plays the sound file. If another sound is playing, it will be interrupted. Returns TRUEon success, FALSEotherwise.

The possible values for flags are:

wxSOUND_SYNC Play will block and wait until the sound is replayed.
wxSOUND_ASYNC Sound is played asynchronously, Play returns immediately
wxSOUND_ASYNC | wxSOUND_LOOP Sound is played asynchronously and loops until another sound is played, wxSound::Stop is called or the program terminates.

The static form is shorthand for this code:

wxSound(filename).Play(flags);



wxSound::Stop



static void Stop(void)

If a sound is played, this function stops it.

ymasuda 平成17年11月19日