]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sound.h
Use wxGetTranslation() instead of _() in the public headers.
[wxWidgets.git] / include / wx / sound.h
CommitLineData
e9e23cb5
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/sound.h
3// Purpose: wxSoundBase class
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 2004/02/01
e9e23cb5 7// Copyright: (c) 2004, Vaclav Slavik
d775fa82 8// Licence: wxWindows licence
e9e23cb5
VS
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_SOUND_H_BASE_
12#define _WX_SOUND_H_BASE_
13
cad1a197
VS
14#include "wx/defs.h"
15
16#if wxUSE_SOUND
17
e9e23cb5
VS
18#include "wx/object.h"
19
20// ----------------------------------------------------------------------------
21// wxSoundBase: common wxSound code and interface
22// ----------------------------------------------------------------------------
23
24// Flags for wxSound::Play
d775fa82 25
39b61aa3
VZ
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).
f53b1c1e
VS
29#define wxSOUND_SYNC ((unsigned)0)
30#define wxSOUND_ASYNC ((unsigned)1)
31#define wxSOUND_LOOP ((unsigned)2)
e9e23cb5 32
cad1a197 33// Base class for wxSound implementations
65cf3a4b 34class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
e9e23cb5
VS
35{
36public:
37 // Play the sound:
cad1a197 38 bool Play(unsigned flags = wxSOUND_ASYNC) const
e9e23cb5 39 {
cad1a197
VS
40 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
41 (flags & wxSOUND_ASYNC) != 0,
9a83f860 42 wxT("sound can only be looped asynchronously") );
e9e23cb5
VS
43 return DoPlay(flags);
44 }
e9e23cb5 45
cad1a197
VS
46 // Plays sound from filename:
47 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
d775fa82 48
e9e23cb5 49protected:
cad1a197 50 virtual bool DoPlay(unsigned flags) const = 0;
e9e23cb5 51};
e9e23cb5
VS
52
53// ----------------------------------------------------------------------------
54// wxSound class implementation
55// ----------------------------------------------------------------------------
56
d98a58c5 57#if defined(__WINDOWS__)
cad1a197 58 #include "wx/msw/sound.h"
0c0be4a3
RN
59#elif defined(__WXCOCOA__)
60 #include "wx/cocoa/sound.h"
e9e23cb5 61#elif defined(__WXMAC__)
ef0e9220 62 #include "wx/osx/sound.h"
e9e23cb5 63#elif defined(__WXPM__)
cad1a197 64 #include "wx/os2/sound.h"
00f6001f
VS
65#elif defined(__UNIX__)
66 #include "wx/unix/sound.h"
e9e23cb5
VS
67#endif
68
cad1a197
VS
69// ----------------------------------------------------------------------------
70// wxSoundBase methods
71// ----------------------------------------------------------------------------
72
73inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
74{
75 wxSound snd(filename);
76 return snd.IsOk() ? snd.Play(flags) : false;
77}
78
cad1a197
VS
79#endif // wxUSE_SOUND
80
e9e23cb5 81#endif // _WX_SOUND_H_BASE_