2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: sound.h
|
|
|
|
// Purpose: documentation for wxSound class
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxSound
|
|
|
|
@wxheader{sound.h}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a short sound (loaded from Windows WAV file), that
|
|
|
|
can be stored in memory and played. Currently this class is implemented
|
2008-03-08 09:43:31 -05:00
|
|
|
on Windows and Unix (and uses either
|
|
|
|
Open Sound System or
|
2008-03-08 08:52:38 -05:00
|
|
|
Simple DirectMedia Layer).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxadv}
|
|
|
|
@category{FIXME}
|
|
|
|
*/
|
|
|
|
class wxSound : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructs a wave object from a file or, under Windows, from a Windows
|
|
|
|
resource. Call IsOk() to determine whether this
|
|
|
|
succeeded.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param fileName
|
2008-03-09 08:33:59 -04:00
|
|
|
The filename or Windows resource.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param isResource
|
2008-03-09 08:33:59 -04:00
|
|
|
@true if fileName is a resource, @false if it is a filename.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxSound();
|
2008-03-09 08:33:59 -04:00
|
|
|
wxSound(const wxString& fileName, bool isResource = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxSound object.
|
|
|
|
*/
|
|
|
|
~wxSound();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructs a wave object from a file or resource.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param fileName
|
2008-03-09 08:33:59 -04:00
|
|
|
The filename or Windows resource.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param isResource
|
2008-03-09 08:33:59 -04:00
|
|
|
@true if fileName is a resource, @false if it is a filename.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
@returns @true if the call was successful, @false otherwise.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(const wxString& fileName, bool isResource = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the object contains a successfully loaded file or resource,
|
|
|
|
@false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if a sound is played at the moment.
|
|
|
|
This method is currently not implemented under Windows.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
static bool IsPlaying() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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.
|
2008-03-09 08:33:59 -04:00
|
|
|
The possible values for @a flags are:
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
wxSOUND_SYNC
|
|
|
|
|
|
|
|
@c Play will block and wait until the sound is
|
|
|
|
replayed.
|
|
|
|
|
|
|
|
wxSOUND_ASYNC
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
Sound is played asynchronously,
|
2008-03-08 08:52:38 -05:00
|
|
|
@c Play returns immediately
|
|
|
|
|
|
|
|
wxSOUND_ASYNC | wxSOUND_LOOP
|
|
|
|
|
|
|
|
Sound is played asynchronously
|
2008-03-08 09:43:31 -05:00
|
|
|
and loops until another sound is played,
|
2008-03-08 08:52:38 -05:00
|
|
|
Stop() is called or the program terminates.
|
|
|
|
|
|
|
|
The static form is shorthand for this code:
|
|
|
|
*/
|
|
|
|
bool Play(unsigned flags = wxSOUND_ASYNC);
|
2008-03-09 12:24:26 -04:00
|
|
|
const static bool Play(const wxString& filename,
|
|
|
|
unsigned flags = wxSOUND_ASYNC);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
If a sound is played, this function stops it.
|
|
|
|
*/
|
|
|
|
static void Stop();
|
|
|
|
};
|