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