]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/sound.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSound
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define wxSOUND_SYNC 0
11 #define wxSOUND_ASYNC 1
12 #define wxSOUND_LOOP 2
18 This class represents a short sound (loaded from Windows WAV file), that
19 can be stored in memory and played.
21 Currently this class is implemented on Windows and Unix (and uses either
22 Open Sound System or Simple DirectMedia Layer).
27 class wxSound
: public wxObject
36 Constructs a wave object from a file or, under Windows, from a Windows
37 resource. Call IsOk() to determine whether this succeeded.
40 The filename or Windows resource.
42 @true if fileName is a resource, @false if it is a filename.
44 wxSound(const wxString
& fileName
, bool isResource
= false);
47 Constructs a wave object from in-memory data.
50 Size of the buffer pointer to by @a data.
52 The buffer containing the sound data in WAV format.
54 wxSound(size_t size
, const void* data
);
57 Destroys the wxSound object.
62 Constructs a wave object from a file or resource.
65 The filename or Windows resource.
67 @true if fileName is a resource, @false if it is a filename.
69 @return @true if the call was successful, @false otherwise.
71 bool Create(const wxString
& fileName
, bool isResource
= false);
74 Constructs a wave object from in-memory data.
77 Size of the buffer pointer to by @a data.
79 The buffer containing the sound data in WAV format.
81 bool Create(size_t size
, const void* data
);
84 Returns @true if the object contains a successfully loaded file or resource,
90 Returns @true if a sound is played at the moment.
92 This method is currently not available under Windows and may not be
93 always implemented in Unix ports depending on the compilation options
94 used (in this case it just always returns @false).
98 static bool IsPlaying();
102 Plays the sound file. If another sound is playing, it will be interrupted.
104 Returns @true on success, @false otherwise. Note that in general it is
105 possible to delete the object which is being asynchronously played any time
106 after calling this function and the sound would continue playing, however this
107 currently doesn't work under Windows for sound objects loaded from memory data.
109 The possible values for @a flags are:
110 - wxSOUND_SYNC: @c Play will block and wait until the sound is replayed.
111 - wxSOUND_ASYNC: Sound is played asynchronously, @c Play returns immediately.
112 - wxSOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops
113 until another sound is played, Stop() is
114 called or the program terminates.
116 The static form is shorthand for this code:
118 wxSound(filename).Play(flags);
121 bool Play(unsigned flags
= wxSOUND_ASYNC
) const;
122 static bool Play(const wxString
& filename
,
123 unsigned flags
= wxSOUND_ASYNC
);
127 If a sound is played, this function stops it.