1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSoundBase class
4 // Author: Vaclav Slavik
8 // Copyright: (c) 2004, Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SOUND_H_BASE_
13 #define _WX_SOUND_H_BASE_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "soundbase.h"
23 #include "wx/object.h"
25 // ----------------------------------------------------------------------------
26 // wxSoundBase: common wxSound code and interface
27 // ----------------------------------------------------------------------------
29 // Flags for wxSound::Play
30 #if WXWIN_COMPATIBILITY_2_4
31 // NB: we can't use enum because there would be ambiguity between the
32 // two Play() prototypes when called without explicit parameters
33 #define wxSOUND_SYNC ((unsigned)0)
34 #define wxSOUND_ASYNC ((unsigned)1)
35 #define wxSOUND_LOOP ((unsigned)2)
45 // Base class for wxSound implementations
46 class WXDLLIMPEXP_ADV wxSoundBase
: public wxObject
50 bool Play(unsigned flags
= wxSOUND_ASYNC
) const
52 wxASSERT_MSG( (flags
& wxSOUND_LOOP
) == 0 ||
53 (flags
& wxSOUND_ASYNC
) != 0,
54 _T("sound can only be looped asynchronously") );
57 #if WXWIN_COMPATIBILITY_2_4
58 wxDEPRECATED( bool Play(bool async
, bool looped
= false) const );
61 // Plays sound from filename:
62 static bool Play(const wxString
& filename
, unsigned flags
= wxSOUND_ASYNC
);
65 virtual bool DoPlay(unsigned flags
) const = 0;
68 // ----------------------------------------------------------------------------
69 // wxSound class implementation
70 // ----------------------------------------------------------------------------
72 #if defined(__WXMSW__)
73 #include "wx/msw/sound.h"
74 #elif defined(__WXMAC__)
75 #include "wx/mac/sound.h"
76 #elif defined(__WXPM__)
77 #include "wx/os2/sound.h"
78 #elif defined(__UNIX__)
79 #include "wx/unix/sound.h"
82 // ----------------------------------------------------------------------------
83 // wxSoundBase methods
84 // ----------------------------------------------------------------------------
86 inline bool wxSoundBase::Play(const wxString
& filename
, unsigned flags
)
88 wxSound
snd(filename
);
89 return snd
.IsOk() ? snd
.Play(flags
) : false;
92 #if WXWIN_COMPATIBILITY_2_4
93 inline bool wxSoundBase::Play(bool async
, bool looped
) const
96 if (async
) flags
|= wxSOUND_ASYNC
;
97 if (looped
) flags
|= wxSOUND_LOOP
| wxSOUND_ASYNC
;
102 #endif // wxUSE_SOUND
104 #endif // _WX_SOUND_H_BASE_