Version: 2.9.4
Public Member Functions | Static Public Member Functions
wxSound Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/sound.h>

Inheritance diagram for wxSound:

Detailed Description

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 or Simple DirectMedia Layer).

Library:  wxAdvanced
Category:  Multimedia
bool Play (unsigned flags=wxSOUND_ASYNC) const
 Plays the sound file.
static bool Play (const wxString &filename, unsigned flags=wxSOUND_ASYNC)
 Plays the sound file.

Public Member Functions

 wxSound ()
 Default ctor.
 wxSound (const wxString &fileName, bool isResource=false)
 Constructs a wave object from a file or, under Windows, from a Windows resource.
 wxSound (size_t size, const void *data)
 Constructs a wave object from in-memory data.
virtual ~wxSound ()
 Destroys the wxSound object.
bool Create (const wxString &fileName, bool isResource=false)
 Constructs a wave object from a file or resource.
bool Create (size_t size, const void *data)
 Constructs a wave object from in-memory data.
bool IsOk () const
 Returns true if the object contains a successfully loaded file or resource, false otherwise.

Static Public Member Functions

static bool IsPlaying ()
 Returns true if a sound is played at the moment.
static void Stop ()
 If a sound is played, this function stops it.

List of all members.


Constructor & Destructor Documentation

wxSound::wxSound ( )

Default ctor.

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

Constructs a wave object from a file or, under Windows, from a Windows resource.

Call IsOk() to determine whether this succeeded.

Parameters:
fileNameThe filename or Windows resource.
isResourcetrue if fileName is a resource, false if it is a filename.
wxSound::wxSound ( size_t  size,
const void *  data 
)

Constructs a wave object from in-memory data.

Parameters:
sizeSize of the buffer pointer to by data.
dataThe buffer containing the sound data in WAV format.
virtual wxSound::~wxSound ( ) [virtual]

Destroys the wxSound object.


Member Function Documentation

bool wxSound::Create ( const wxString fileName,
bool  isResource = false 
)

Constructs a wave object from a file or resource.

Parameters:
fileNameThe filename or Windows resource.
isResourcetrue if fileName is a resource, false if it is a filename.
Returns:
true if the call was successful, false otherwise.
bool wxSound::Create ( size_t  size,
const void *  data 
)

Constructs a wave object from in-memory data.

Parameters:
sizeSize of the buffer pointer to by data.
dataThe buffer containing the sound data in WAV format.
bool wxSound::IsOk ( ) const

Returns true if the object contains a successfully loaded file or resource, false otherwise.

static bool wxSound::IsPlaying ( ) [static]

Returns true if a sound is played at the moment.

This method is currently not available under Windows and may not be always implemented in Unix ports depending on the compilation options used (in this case it just always returns false).

Availability:  only available for the wxGTK, wxOSX ports.
bool wxSound::Play ( unsigned  flags = wxSOUND_ASYNC) const

Plays the sound file.

If another sound is playing, it will be interrupted.

Returns true on success, false otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn't work under Windows for sound objects loaded from memory data.

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, Stop() is called or the program terminates.

The static form is shorthand for this code:

        wxSound(filename).Play(flags);
static bool wxSound::Play ( const wxString filename,
unsigned  flags = wxSOUND_ASYNC 
) [static]

Plays the sound file.

If another sound is playing, it will be interrupted.

Returns true on success, false otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn't work under Windows for sound objects loaded from memory data.

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, Stop() is called or the program terminates.

The static form is shorthand for this code:

        wxSound(filename).Play(flags);
static void wxSound::Stop ( ) [static]

If a sound is played, this function stops it.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines