2004-02-01 13:27:25 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/sound.h
|
|
|
|
// Purpose: wxSoundBase class
|
|
|
|
// Author: Vaclav Slavik
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2004/02/01
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 2004, Vaclav Slavik
|
2004-09-22 10:38:52 -04:00
|
|
|
// Licence: wxWindows licence
|
2004-02-01 13:27:25 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SOUND_H_BASE_
|
|
|
|
#define _WX_SOUND_H_BASE_
|
|
|
|
|
2004-02-02 08:16:31 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_SOUND
|
|
|
|
|
2004-02-01 13:27:25 -05:00
|
|
|
#include "wx/object.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSoundBase: common wxSound code and interface
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Flags for wxSound::Play
|
2004-09-22 10:38:52 -04:00
|
|
|
|
2007-03-07 06:48:53 -05:00
|
|
|
// NB: We can't use enum with some compilers, because they keep reporting
|
|
|
|
// nonexistent ambiguities between Play(unsigned) and static Play(const
|
|
|
|
// wxString&, unsigned).
|
2004-07-22 03:49:29 -04:00
|
|
|
#define wxSOUND_SYNC ((unsigned)0)
|
|
|
|
#define wxSOUND_ASYNC ((unsigned)1)
|
|
|
|
#define wxSOUND_LOOP ((unsigned)2)
|
2004-02-01 13:27:25 -05:00
|
|
|
|
2004-02-02 08:16:31 -05:00
|
|
|
// Base class for wxSound implementations
|
2004-02-02 22:43:49 -05:00
|
|
|
class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
|
2004-02-01 13:27:25 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Play the sound:
|
2004-02-02 08:16:31 -05:00
|
|
|
bool Play(unsigned flags = wxSOUND_ASYNC) const
|
2004-02-01 13:27:25 -05:00
|
|
|
{
|
2004-02-02 08:16:31 -05:00
|
|
|
wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
|
|
|
|
(flags & wxSOUND_ASYNC) != 0,
|
2009-07-23 16:30:22 -04:00
|
|
|
wxT("sound can only be looped asynchronously") );
|
2004-02-01 13:27:25 -05:00
|
|
|
return DoPlay(flags);
|
|
|
|
}
|
|
|
|
|
2004-02-02 08:16:31 -05:00
|
|
|
// Plays sound from filename:
|
|
|
|
static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
|
2004-09-22 10:38:52 -04:00
|
|
|
|
2004-02-01 13:27:25 -05:00
|
|
|
protected:
|
2004-02-02 08:16:31 -05:00
|
|
|
virtual bool DoPlay(unsigned flags) const = 0;
|
2004-02-01 13:27:25 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSound class implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if defined(__WXMSW__)
|
2004-02-02 08:16:31 -05:00
|
|
|
#include "wx/msw/sound.h"
|
2004-10-07 20:47:47 -04:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/sound.h"
|
2004-02-01 13:27:25 -05:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 15:17:41 -04:00
|
|
|
#include "wx/osx/sound.h"
|
2004-02-01 13:27:25 -05:00
|
|
|
#elif defined(__WXPM__)
|
2004-02-02 08:16:31 -05:00
|
|
|
#include "wx/os2/sound.h"
|
2004-02-04 04:40:17 -05:00
|
|
|
#elif defined(__UNIX__)
|
|
|
|
#include "wx/unix/sound.h"
|
2004-02-01 13:27:25 -05:00
|
|
|
#endif
|
|
|
|
|
2004-02-02 08:16:31 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSoundBase methods
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline bool wxSoundBase::Play(const wxString& filename, unsigned flags)
|
|
|
|
{
|
|
|
|
wxSound snd(filename);
|
|
|
|
return snd.IsOk() ? snd.Play(flags) : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // wxUSE_SOUND
|
|
|
|
|
2004-02-01 13:27:25 -05:00
|
|
|
#endif // _WX_SOUND_H_BASE_
|