]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/osx/sound.h | |
3 | // Purpose: wxSound class (loads and plays short Windows .wav files). | |
4 | // Optional on non-Windows platforms. | |
5 | // Author: Ryan Norton, Stefan Csomor | |
6 | // Modified by: | |
7 | // Created: 1998-01-01 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Ryan Norton, Stefan Csomor | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_SOUND_H_ | |
14 | #define _WX_SOUND_H_ | |
15 | ||
16 | #if wxUSE_SOUND | |
17 | ||
18 | #include "wx/object.h" | |
19 | ||
20 | class WXDLLIMPEXP_FWD_ADV wxSoundTimer; | |
21 | ||
22 | class WXDLLIMPEXP_ADV wxSoundData | |
23 | { | |
24 | public : | |
25 | wxSoundData(); | |
26 | virtual ~wxSoundData(); | |
27 | ||
28 | virtual bool Play(unsigned int flags) = 0; | |
29 | // stops the sound and deletes the optional timer | |
30 | virtual void Stop(); | |
31 | // can be called by a timer for repeated tasks during playback | |
32 | virtual void SoundTask(); | |
33 | // mark this to be deleted | |
34 | virtual void MarkForDeletion(); | |
35 | virtual bool IsMarkedForDeletion() const { return m_markedForDeletion; } | |
36 | ||
37 | // does the true work of stopping and cleaning up | |
38 | virtual void DoStop() = 0; | |
39 | protected : | |
40 | void CreateAndStartTimer(); | |
41 | ||
42 | unsigned int m_flags; | |
43 | wxSoundTimer* m_pTimer; | |
44 | bool m_markedForDeletion; | |
45 | } ; | |
46 | ||
47 | class WXDLLIMPEXP_ADV wxSound : public wxSoundBase | |
48 | { | |
49 | public: | |
50 | wxSound(); | |
51 | wxSound(const wxString& fileName, bool isResource = false); | |
52 | wxSound(int size, const wxByte* data); | |
53 | virtual ~wxSound(); | |
54 | ||
55 | // Create from resource or file | |
56 | bool Create(const wxString& fileName, bool isResource = false); | |
57 | // Create from data | |
58 | bool Create(int size, const wxByte* data); | |
59 | ||
60 | bool IsOk() const { return m_data != NULL; } | |
61 | ||
62 | // Stop playing any sound | |
63 | static void Stop(); | |
64 | ||
65 | // Returns true if a sound is being played | |
66 | static bool IsPlaying(); | |
67 | ||
68 | // Notification when a sound has stopped | |
69 | static void SoundStopped(const wxSoundData* data); | |
70 | ||
71 | protected: | |
72 | bool DoPlay(unsigned flags) const; | |
73 | void Init(); | |
74 | ||
75 | private: | |
76 | // data of this object | |
77 | class wxSoundData *m_data; | |
78 | ||
79 | wxDECLARE_NO_COPY_CLASS(wxSound); | |
80 | }; | |
81 | ||
82 | #endif | |
83 | #endif | |
84 | // _WX_SOUND_H_ |