1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSound class (loads and plays short Windows .wav files).
4 // Optional on non-Windows platforms.
5 // Author: Ryan Norton, Stefan Csomor
9 // Copyright: (c) Ryan Norton, Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
18 #include "wx/object.h"
20 class WXDLLIMPEXP_FWD_ADV wxSoundTimer
;
22 class WXDLLIMPEXP_ADV wxSoundData
26 virtual ~wxSoundData();
28 virtual bool Play(unsigned int flags
) = 0;
29 // stops the sound and deletes the optional timer
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
; }
37 // does the true work of stopping and cleaning up
38 virtual void DoStop() = 0;
40 void CreateAndStartTimer();
43 wxSoundTimer
* m_pTimer
;
44 bool m_markedForDeletion
;
47 class WXDLLIMPEXP_ADV wxSound
: public wxSoundBase
51 wxSound(const wxString
& fileName
, bool isResource
= false);
52 wxSound(int size
, const wxByte
* data
);
55 // Create from resource or file
56 bool Create(const wxString
& fileName
, bool isResource
= false);
58 bool Create(int size
, const wxByte
* data
);
60 bool IsOk() const { return m_data
!= NULL
; }
62 // Stop playing any sound
65 // Returns true if a sound is being played
66 static bool IsPlaying();
68 // Notification when a sound has stopped
69 static void SoundStopped(const wxSoundData
* data
);
72 bool DoPlay(unsigned flags
) const;
76 // data of this object
77 class wxSoundData
*m_data
;
79 wxDECLARE_NO_COPY_CLASS(wxSound
);