1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSoundBase class
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2004, Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_SOUND_H_BASE_
12 #define _WX_SOUND_H_BASE_
18 #include "wx/object.h"
20 // ----------------------------------------------------------------------------
21 // wxSoundBase: common wxSound code and interface
22 // ----------------------------------------------------------------------------
24 // Flags for wxSound::Play
26 // NB: We can't use enum with some compilers, because they keep reporting
27 // nonexistent ambiguities between Play(unsigned) and static Play(const
28 // wxString&, unsigned).
29 #define wxSOUND_SYNC ((unsigned)0)
30 #define wxSOUND_ASYNC ((unsigned)1)
31 #define wxSOUND_LOOP ((unsigned)2)
33 // Base class for wxSound implementations
34 class WXDLLIMPEXP_ADV wxSoundBase
: public wxObject
38 bool Play(unsigned flags
= wxSOUND_ASYNC
) const
40 wxASSERT_MSG( (flags
& wxSOUND_LOOP
) == 0 ||
41 (flags
& wxSOUND_ASYNC
) != 0,
42 wxT("sound can only be looped asynchronously") );
46 // Plays sound from filename:
47 static bool Play(const wxString
& filename
, unsigned flags
= wxSOUND_ASYNC
);
50 virtual bool DoPlay(unsigned flags
) const = 0;
53 // ----------------------------------------------------------------------------
54 // wxSound class implementation
55 // ----------------------------------------------------------------------------
57 #if defined(__WINDOWS__)
58 #include "wx/msw/sound.h"
59 #elif defined(__WXCOCOA__)
60 #include "wx/cocoa/sound.h"
61 #elif defined(__WXMAC__)
62 #include "wx/osx/sound.h"
63 #elif defined(__WXPM__)
64 #include "wx/os2/sound.h"
65 #elif defined(__UNIX__)
66 #include "wx/unix/sound.h"
69 // ----------------------------------------------------------------------------
70 // wxSoundBase methods
71 // ----------------------------------------------------------------------------
73 inline bool wxSoundBase::Play(const wxString
& filename
, unsigned flags
)
75 wxSound
snd(filename
);
76 return snd
.IsOk() ? snd
.Play(flags
) : false;
81 #endif // _WX_SOUND_H_BASE_