]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/sound.h
Add wxRTTI for the wxFileSystemWatcherEvent class
[wxWidgets.git] / interface / wx / sound.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: sound.h
e54c96f1 3// Purpose: interface of wxSound
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
e4476836
RD
9
10#define wxSOUND_SYNC 0
11#define wxSOUND_ASYNC 1
12#define wxSOUND_LOOP 2
13
14
23324ae1
FM
15/**
16 @class wxSound
7c913512 17
23324ae1 18 This class represents a short sound (loaded from Windows WAV file), that
e725ba4f
FM
19 can be stored in memory and played.
20
21 Currently this class is implemented on Windows and Unix (and uses either
22 Open Sound System or Simple DirectMedia Layer).
7c913512 23
23324ae1 24 @library{wxadv}
3c99e2fd 25 @category{media}
23324ae1
FM
26*/
27class wxSound : public wxObject
28{
29public:
e725ba4f
FM
30 /**
31 Default ctor.
32 */
33 wxSound();
34
23324ae1
FM
35 /**
36 Constructs a wave object from a file or, under Windows, from a Windows
e725ba4f 37 resource. Call IsOk() to determine whether this succeeded.
3c4f71cc 38
7c913512 39 @param fileName
4cc4bfaf 40 The filename or Windows resource.
7c913512 41 @param isResource
4cc4bfaf 42 @true if fileName is a resource, @false if it is a filename.
23324ae1 43 */
4cc4bfaf 44 wxSound(const wxString& fileName, bool isResource = false);
23324ae1
FM
45
46 /**
c559c4b3
VZ
47 Constructs a wave object from in-memory data.
48
49 @param size
50 Size of the buffer pointer to by @a data.
51 @param data
52 The buffer containing the sound data in WAV format.
53 */
54 wxSound(size_t size, const void* data);
55
56 /**
23324ae1
FM
57 Destroys the wxSound object.
58 */
adaaa686 59 virtual ~wxSound();
23324ae1
FM
60
61 /**
62 Constructs a wave object from a file or resource.
3c4f71cc 63
7c913512 64 @param fileName
4cc4bfaf 65 The filename or Windows resource.
7c913512 66 @param isResource
4cc4bfaf 67 @true if fileName is a resource, @false if it is a filename.
3c4f71cc 68
d29a9a8a 69 @return @true if the call was successful, @false otherwise.
23324ae1 70 */
4cc4bfaf 71 bool Create(const wxString& fileName, bool isResource = false);
23324ae1 72
e4476836
RD
73 /**
74 Constructs a wave object from in-memory data.
75
76 @param size
77 Size of the buffer pointer to by @a data.
78 @param data
79 The buffer containing the sound data in WAV format.
80 */
81 bool Create(size_t size, const void* data);
82
23324ae1
FM
83 /**
84 Returns @true if the object contains a successfully loaded file or resource,
85 @false otherwise.
86 */
328f5751 87 bool IsOk() const;
23324ae1
FM
88
89 /**
90 Returns @true if a sound is played at the moment.
f85d2074
VZ
91
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).
95
96 @onlyfor{wxgtk,wxosx}
23324ae1 97 */
57bf907d 98 static bool IsPlaying();
23324ae1
FM
99
100 //@{
101 /**
102 Plays the sound file. If another sound is playing, it will be interrupted.
e725ba4f 103
23324ae1 104 Returns @true on success, @false otherwise. Note that in general it is
e725ba4f
FM
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
23324ae1 107 currently doesn't work under Windows for sound objects loaded from memory data.
3c4f71cc 108
e725ba4f
FM
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.
3c4f71cc 115
23324ae1 116 The static form is shorthand for this code:
e725ba4f
FM
117 @code
118 wxSound(filename).Play(flags);
119 @endcode
23324ae1 120 */
e725ba4f
FM
121 bool Play(unsigned flags = wxSOUND_ASYNC) const;
122 static bool Play(const wxString& filename,
123 unsigned flags = wxSOUND_ASYNC);
23324ae1
FM
124 //@}
125
126 /**
127 If a sound is played, this function stops it.
128 */
129 static void Stop();
130};
e54c96f1 131