]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/sound.h
add WX_CLEAR_ARRAY test
[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$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxSound
7c913512 11
23324ae1 12 This class represents a short sound (loaded from Windows WAV file), that
e725ba4f
FM
13 can be stored in memory and played.
14
15 Currently this class is implemented on Windows and Unix (and uses either
16 Open Sound System or Simple DirectMedia Layer).
7c913512 17
23324ae1 18 @library{wxadv}
e725ba4f 19 @category{misc}
23324ae1
FM
20*/
21class wxSound : public wxObject
22{
23public:
e725ba4f
FM
24 /**
25 Default ctor.
26 */
27 wxSound();
28
23324ae1
FM
29 /**
30 Constructs a wave object from a file or, under Windows, from a Windows
e725ba4f 31 resource. Call IsOk() to determine whether this succeeded.
3c4f71cc 32
7c913512 33 @param fileName
4cc4bfaf 34 The filename or Windows resource.
7c913512 35 @param isResource
4cc4bfaf 36 @true if fileName is a resource, @false if it is a filename.
23324ae1 37 */
4cc4bfaf 38 wxSound(const wxString& fileName, bool isResource = false);
23324ae1
FM
39
40 /**
41 Destroys the wxSound object.
42 */
adaaa686 43 virtual ~wxSound();
23324ae1
FM
44
45 /**
46 Constructs a wave object from a file or resource.
3c4f71cc 47
7c913512 48 @param fileName
4cc4bfaf 49 The filename or Windows resource.
7c913512 50 @param isResource
4cc4bfaf 51 @true if fileName is a resource, @false if it is a filename.
3c4f71cc 52
d29a9a8a 53 @return @true if the call was successful, @false otherwise.
23324ae1 54 */
4cc4bfaf 55 bool Create(const wxString& fileName, bool isResource = false);
23324ae1
FM
56
57 /**
58 Returns @true if the object contains a successfully loaded file or resource,
59 @false otherwise.
60 */
328f5751 61 bool IsOk() const;
23324ae1
FM
62
63 /**
64 Returns @true if a sound is played at the moment.
23324ae1
FM
65 This method is currently not implemented under Windows.
66 */
328f5751 67 static bool IsPlaying() const;
23324ae1
FM
68
69 //@{
70 /**
71 Plays the sound file. If another sound is playing, it will be interrupted.
e725ba4f 72
23324ae1 73 Returns @true on success, @false otherwise. Note that in general it is
e725ba4f
FM
74 possible to delete the object which is being asynchronously played any time
75 after calling this function and the sound would continue playing, however this
23324ae1 76 currently doesn't work under Windows for sound objects loaded from memory data.
3c4f71cc 77
e725ba4f
FM
78 The possible values for @a flags are:
79 - wxSOUND_SYNC: @c Play will block and wait until the sound is replayed.
80 - wxSOUND_ASYNC: Sound is played asynchronously, @c Play returns immediately.
81 - wxSOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops
82 until another sound is played, Stop() is
83 called or the program terminates.
3c4f71cc 84
23324ae1 85 The static form is shorthand for this code:
e725ba4f
FM
86 @code
87 wxSound(filename).Play(flags);
88 @endcode
23324ae1 89 */
e725ba4f
FM
90 bool Play(unsigned flags = wxSOUND_ASYNC) const;
91 static bool Play(const wxString& filename,
92 unsigned flags = wxSOUND_ASYNC);
23324ae1
FM
93 //@}
94
95 /**
96 If a sound is played, this function stops it.
97 */
98 static void Stop();
99};
e54c96f1 100