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 defined(__BORLANDC__) || \
32 defined(__VISUALC__) || \
34 // NB: We can't use enum because there would be ambiguity between the
35 // two Play() prototypes when called without explicit parameters.
36 // We can't use enum with some compilers either, because they
37 // keep reporting nonexistent ambiguities between
38 // Play(unsigned) and static Play(const wxString&, unsigned).
39 #define wxSOUND_SYNC ((unsigned)0)
40 #define wxSOUND_ASYNC ((unsigned)1)
41 #define wxSOUND_LOOP ((unsigned)2)
51 // Base class for wxSound implementations
52 class WXDLLIMPEXP_ADV wxSoundBase
: public wxObject
56 bool Play(unsigned flags
= wxSOUND_ASYNC
) const
58 wxASSERT_MSG( (flags
& wxSOUND_LOOP
) == 0 ||
59 (flags
& wxSOUND_ASYNC
) != 0,
60 _T("sound can only be looped asynchronously") );
63 #if WXWIN_COMPATIBILITY_2_4
64 wxDEPRECATED( bool Play(bool async
, bool looped
= false) const );
67 // Plays sound from filename:
68 static bool Play(const wxString
& filename
, unsigned flags
= wxSOUND_ASYNC
);
71 virtual bool DoPlay(unsigned flags
) const = 0;
74 // ----------------------------------------------------------------------------
75 // wxSound class implementation
76 // ----------------------------------------------------------------------------
78 #if defined(__WXMSW__)
79 #include "wx/msw/sound.h"
80 #elif defined(__WXMAC__)
81 #include "wx/mac/sound.h"
82 #elif defined(__WXPM__)
83 #include "wx/os2/sound.h"
84 #elif defined(__UNIX__)
85 #include "wx/unix/sound.h"
88 // ----------------------------------------------------------------------------
89 // wxSoundBase methods
90 // ----------------------------------------------------------------------------
92 inline bool wxSoundBase::Play(const wxString
& filename
, unsigned flags
)
94 wxSound
snd(filename
);
95 return snd
.IsOk() ? snd
.Play(flags
) : false;
98 #if WXWIN_COMPATIBILITY_2_4
99 inline bool wxSoundBase::Play(bool async
, bool looped
) const
102 if (async
) flags
|= wxSOUND_ASYNC
;
103 if (looped
) flags
|= wxSOUND_LOOP
| wxSOUND_ASYNC
;
104 return DoPlay(flags
);
108 #endif // wxUSE_SOUND
110 #endif // _WX_SOUND_H_BASE_