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 || defined(__BORLANDC__)
31 // NB: We can't use enum because there would be ambiguity between the
32 // two Play() prototypes when called without explicit parameters.
33 // We can't use enum with Borland's compiler either, because it's
34 // broken and keeps reporting nonexistent ambiguities between
35 // Play(unsigned) and static Play(const wxString&, unsigned).
36 #define wxSOUND_SYNC ((unsigned)0)
37 #define wxSOUND_ASYNC ((unsigned)1)
38 #define wxSOUND_LOOP ((unsigned)2)
48 // Base class for wxSound implementations
49 class WXDLLIMPEXP_ADV wxSoundBase
: public wxObject
53 bool Play(unsigned flags
= wxSOUND_ASYNC
) const
55 wxASSERT_MSG( (flags
& wxSOUND_LOOP
) == 0 ||
56 (flags
& wxSOUND_ASYNC
) != 0,
57 _T("sound can only be looped asynchronously") );
60 #if WXWIN_COMPATIBILITY_2_4
61 wxDEPRECATED( bool Play(bool async
, bool looped
= false) const );
64 // Plays sound from filename:
65 static bool Play(const wxString
& filename
, unsigned flags
= wxSOUND_ASYNC
);
68 virtual bool DoPlay(unsigned flags
) const = 0;
71 // ----------------------------------------------------------------------------
72 // wxSound class implementation
73 // ----------------------------------------------------------------------------
75 #if defined(__WXMSW__)
76 #include "wx/msw/sound.h"
77 #elif defined(__WXMAC__)
78 #include "wx/mac/sound.h"
79 #elif defined(__WXPM__)
80 #include "wx/os2/sound.h"
81 #elif defined(__UNIX__)
82 #include "wx/unix/sound.h"
85 // ----------------------------------------------------------------------------
86 // wxSoundBase methods
87 // ----------------------------------------------------------------------------
89 inline bool wxSoundBase::Play(const wxString
& filename
, unsigned flags
)
91 wxSound
snd(filename
);
92 return snd
.IsOk() ? snd
.Play(flags
) : false;
95 #if WXWIN_COMPATIBILITY_2_4
96 inline bool wxSoundBase::Play(bool async
, bool looped
) const
99 if (async
) flags
|= wxSOUND_ASYNC
;
100 if (looped
) flags
|= wxSOUND_LOOP
| wxSOUND_ASYNC
;
101 return DoPlay(flags
);
105 #endif // wxUSE_SOUND
107 #endif // _WX_SOUND_H_BASE_