]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/sound.h
Add wxDataViewCtrl::GetCurrentColumn().
[wxWidgets.git] / interface / wx / sound.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: sound.h
3 // Purpose: interface of wxSound
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxSound
11
12 This class represents a short sound (loaded from Windows WAV file), that
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).
17
18 @library{wxadv}
19 @category{media}
20 */
21 class wxSound : public wxObject
22 {
23 public:
24 /**
25 Default ctor.
26 */
27 wxSound();
28
29 /**
30 Constructs a wave object from a file or, under Windows, from a Windows
31 resource. Call IsOk() to determine whether this succeeded.
32
33 @param fileName
34 The filename or Windows resource.
35 @param isResource
36 @true if fileName is a resource, @false if it is a filename.
37 */
38 wxSound(const wxString& fileName, bool isResource = false);
39
40 /**
41 Constructs a wave object from in-memory data.
42
43 @param size
44 Size of the buffer pointer to by @a data.
45 @param data
46 The buffer containing the sound data in WAV format.
47 */
48 wxSound(size_t size, const void* data);
49
50 /**
51 Destroys the wxSound object.
52 */
53 virtual ~wxSound();
54
55 /**
56 Constructs a wave object from a file or resource.
57
58 @param fileName
59 The filename or Windows resource.
60 @param isResource
61 @true if fileName is a resource, @false if it is a filename.
62
63 @return @true if the call was successful, @false otherwise.
64 */
65 bool Create(const wxString& fileName, bool isResource = false);
66
67 /**
68 Returns @true if the object contains a successfully loaded file or resource,
69 @false otherwise.
70 */
71 bool IsOk() const;
72
73 /**
74 Returns @true if a sound is played at the moment.
75 This method is currently not implemented under Windows.
76 */
77 static bool IsPlaying();
78
79 //@{
80 /**
81 Plays the sound file. If another sound is playing, it will be interrupted.
82
83 Returns @true on success, @false otherwise. Note that in general it is
84 possible to delete the object which is being asynchronously played any time
85 after calling this function and the sound would continue playing, however this
86 currently doesn't work under Windows for sound objects loaded from memory data.
87
88 The possible values for @a flags are:
89 - wxSOUND_SYNC: @c Play will block and wait until the sound is replayed.
90 - wxSOUND_ASYNC: Sound is played asynchronously, @c Play returns immediately.
91 - wxSOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops
92 until another sound is played, Stop() is
93 called or the program terminates.
94
95 The static form is shorthand for this code:
96 @code
97 wxSound(filename).Play(flags);
98 @endcode
99 */
100 bool Play(unsigned flags = wxSOUND_ASYNC) const;
101 static bool Play(const wxString& filename,
102 unsigned flags = wxSOUND_ASYNC);
103 //@}
104
105 /**
106 If a sound is played, this function stops it.
107 */
108 static void Stop();
109 };
110