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