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_
19 #include "wx/object.h"
21 // ----------------------------------------------------------------------------
22 // wxSoundBase: common wxSound code and interface
23 // ----------------------------------------------------------------------------
25 // Flags for wxSound::Play
27 // NB: We can't use enum with some compilers, because they keep reporting
28 // nonexistent ambiguities between Play(unsigned) and static Play(const
29 // wxString&, unsigned).
30 #define wxSOUND_SYNC ((unsigned)0)
31 #define wxSOUND_ASYNC ((unsigned)1)
32 #define wxSOUND_LOOP ((unsigned)2)
34 // Base class for wxSound implementations
35 class WXDLLIMPEXP_ADV wxSoundBase
: public wxObject
39 bool Play(unsigned flags
= wxSOUND_ASYNC
) const
41 wxASSERT_MSG( (flags
& wxSOUND_LOOP
) == 0 ||
42 (flags
& wxSOUND_ASYNC
) != 0,
43 _T("sound can only be looped asynchronously") );
47 // Plays sound from filename:
48 static bool Play(const wxString
& filename
, unsigned flags
= wxSOUND_ASYNC
);
51 virtual bool DoPlay(unsigned flags
) const = 0;
54 // ----------------------------------------------------------------------------
55 // wxSound class implementation
56 // ----------------------------------------------------------------------------
58 #if defined(__WXMSW__)
59 #include "wx/msw/sound.h"
60 #elif defined(__WXCOCOA__)
61 #include "wx/cocoa/sound.h"
62 #elif defined(__WXMAC__)
63 #include "wx/osx/sound.h"
64 #elif defined(__WXPM__)
65 #include "wx/os2/sound.h"
66 #elif defined(__UNIX__)
67 #include "wx/unix/sound.h"
70 // ----------------------------------------------------------------------------
71 // wxSoundBase methods
72 // ----------------------------------------------------------------------------
74 inline bool wxSoundBase::Play(const wxString
& filename
, unsigned flags
)
76 wxSound
snd(filename
);
77 return snd
.IsOk() ? snd
.Play(flags
) : false;
82 #endif // _WX_SOUND_H_BASE_