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