]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sound.h
Regenerate to add the new file toucan.png.
[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
f53b1c1e
VS
27// NB: We can't use enum because there would be ambiguity between the
28// two Play() prototypes when called without explicit parameters
29// if WXWIN_COMPATIBILITY_2_4.
30// We can't use enum with some compilers either, because they
31// keep reporting nonexistent ambiguities between
32// Play(unsigned) and static Play(const wxString&, unsigned).
33#define wxSOUND_SYNC ((unsigned)0)
34#define wxSOUND_ASYNC ((unsigned)1)
35#define wxSOUND_LOOP ((unsigned)2)
e9e23cb5 36
cad1a197 37// Base class for wxSound implementations
65cf3a4b 38class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
e9e23cb5
VS
39{
40public:
41 // Play the sound:
cad1a197 42 bool Play(unsigned flags = wxSOUND_ASYNC) const
e9e23cb5 43 {
cad1a197
VS
44 wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
45 (flags & wxSOUND_ASYNC) != 0,
46 _T("sound can only be looped asynchronously") );
e9e23cb5
VS
47 return DoPlay(flags);
48 }
49#if WXWIN_COMPATIBILITY_2_4
cad1a197 50 wxDEPRECATED( bool Play(bool async, bool looped = false) const );
e9e23cb5
VS
51#endif
52
cad1a197
VS
53 // Plays sound from filename:
54 static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
d775fa82 55
e9e23cb5 56protected:
cad1a197 57 virtual bool DoPlay(unsigned flags) const = 0;
e9e23cb5 58};
e9e23cb5
VS
59
60// ----------------------------------------------------------------------------
61// wxSound class implementation
62// ----------------------------------------------------------------------------
63
64#if defined(__WXMSW__)
cad1a197 65 #include "wx/msw/sound.h"
0c0be4a3
RN
66#elif defined(__WXCOCOA__)
67 #include "wx/cocoa/sound.h"
e9e23cb5 68#elif defined(__WXMAC__)
cad1a197 69 #include "wx/mac/sound.h"
e9e23cb5 70#elif defined(__WXPM__)
cad1a197 71 #include "wx/os2/sound.h"
00f6001f
VS
72#elif defined(__UNIX__)
73 #include "wx/unix/sound.h"
e9e23cb5
VS
74#endif
75
cad1a197
VS
76// ----------------------------------------------------------------------------
77// wxSoundBase methods
78// ----------------------------------------------------------------------------
79
80inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
81{
82 wxSound snd(filename);
83 return snd.IsOk() ? snd.Play(flags) : false;
84}
85
86#if WXWIN_COMPATIBILITY_2_4
87inline bool wxSoundBase::Play(bool async, bool looped) const
88{
89 unsigned flags = 0;
90 if (async) flags |= wxSOUND_ASYNC;
91 if (looped) flags |= wxSOUND_LOOP | wxSOUND_ASYNC;
92 return DoPlay(flags);
93}
e9e23cb5
VS
94#endif
95
cad1a197
VS
96#endif // wxUSE_SOUND
97
e9e23cb5 98#endif // _WX_SOUND_H_BASE_