X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12f5e1e78fe906050ff2fee9529476db332633f0..7344108e8a129a3f9b4df5ab0f98a1713db03b89:/interface/wx/sound.h diff --git a/interface/wx/sound.h b/interface/wx/sound.h index 58ae0848d3..7fa63ded52 100644 --- a/interface/wx/sound.h +++ b/interface/wx/sound.h @@ -3,43 +3,60 @@ // Purpose: interface of wxSound // Author: wxWidgets team // RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + +#define wxSOUND_SYNC 0 +#define wxSOUND_ASYNC 1 +#define wxSOUND_LOOP 2 + + /** @class 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 or - Simple DirectMedia Layer). + 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{wxadv} - @category{FIXME} + @category{media} */ class wxSound : public wxObject { public: - //@{ + /** + Default ctor. + */ + wxSound(); + /** Constructs a wave object from a file or, under Windows, from a Windows - resource. Call IsOk() to determine whether this - succeeded. + resource. Call IsOk() to determine whether this succeeded. @param fileName The filename or Windows resource. @param isResource @true if fileName is a resource, @false if it is a filename. */ - wxSound(); wxSound(const wxString& fileName, bool isResource = false); - //@} + + /** + Constructs a wave object from in-memory data. + + @param size + Size of the buffer pointer to by @a data. + @param data + The buffer containing the sound data in WAV format. + */ + wxSound(size_t size, const void* data); /** Destroys the wxSound object. */ - ~wxSound(); + virtual ~wxSound(); /** Constructs a wave object from a file or resource. @@ -53,6 +70,16 @@ public: */ bool Create(const wxString& fileName, bool isResource = false); + /** + Constructs a wave object from in-memory data. + + @param size + Size of the buffer pointer to by @a data. + @param data + The buffer containing the sound data in WAV format. + */ + bool Create(size_t size, const void* data); + /** Returns @true if the object contains a successfully loaded file or resource, @false otherwise. @@ -61,41 +88,39 @@ public: /** Returns @true if a sound is played at the moment. - This method is currently not implemented under Windows. + + 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). + + @onlyfor{wxgtk,wxosx} */ - static bool IsPlaying() const; + static bool IsPlaying(); //@{ /** 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 + 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 @a flags are: - wxSOUND_SYNC - - @c Play will block and wait until the sound is - replayed. - - wxSOUND_ASYNC - - Sound is played asynchronously, - @c 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 possible values for @a flags are: + - wxSOUND_SYNC: @c Play will block and wait until the sound is replayed. + - wxSOUND_ASYNC: Sound is played asynchronously, @c 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: + @code + wxSound(filename).Play(flags); + @endcode */ - bool Play(unsigned flags = wxSOUND_ASYNC); - const static bool Play(const wxString& filename, - unsigned flags = wxSOUND_ASYNC); + bool Play(unsigned flags = wxSOUND_ASYNC) const; + static bool Play(const wxString& filename, + unsigned flags = wxSOUND_ASYNC); //@} /**