2004-02-01 18:27:25 +00: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 14:38:52 +00:00
|
|
|
// Licence: wxWindows licence
|
2004-02-01 18:27:25 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SOUND_H_BASE_
|
|
|
|
#define _WX_SOUND_H_BASE_
|
|
|
|
|
2004-02-02 13:16:31 +00:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_SOUND
|
|
|
|
|
2004-02-01 18:27:25 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSoundBase: common wxSound code and interface
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Flags for wxSound::Play
|
2004-09-22 14:38:52 +00:00
|
|
|
|
2007-03-07 11:48:53 +00: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 07:49:29 +00:00
|
|
|
#define wxSOUND_SYNC ((unsigned)0)
|
|
|
|
#define wxSOUND_ASYNC ((unsigned)1)
|
|
|
|
#define wxSOUND_LOOP ((unsigned)2)
|
2004-02-01 18:27:25 +00:00
|
|
|
|
2004-02-02 13:16:31 +00:00
|
|
|
// Base class for wxSound implementations
|
2004-02-03 03:43:49 +00:00
|
|
|
class WXDLLIMPEXP_ADV wxSoundBase : public wxObject
|
2004-02-01 18:27:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Play the sound:
|
2004-02-02 13:16:31 +00:00
|
|
|
bool Play(unsigned flags = wxSOUND_ASYNC) const
|
2004-02-01 18:27:25 +00:00
|
|
|
{
|
2004-02-02 13:16:31 +00:00
|
|
|
wxASSERT_MSG( (flags & wxSOUND_LOOP) == 0 ||
|
|
|
|
(flags & wxSOUND_ASYNC) != 0,
|
|
|
|
_T("sound can only be looped asynchronously") );
|
2004-02-01 18:27:25 +00:00
|
|
|
return DoPlay(flags);
|
|
|
|
}
|
|
|
|
|
2004-02-02 13:16:31 +00:00
|
|
|
// Plays sound from filename:
|
|
|
|
static bool Play(const wxString& filename, unsigned flags = wxSOUND_ASYNC);
|
2004-09-22 14:38:52 +00:00
|
|
|
|
2004-02-01 18:27:25 +00:00
|
|
|
protected:
|
2004-02-02 13:16:31 +00:00
|
|
|
virtual bool DoPlay(unsigned flags) const = 0;
|
2004-02-01 18:27:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSound class implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if defined(__WXMSW__)
|
2004-02-02 13:16:31 +00:00
|
|
|
#include "wx/msw/sound.h"
|
2004-10-08 00:47:47 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/sound.h"
|
2004-02-01 18:27:25 +00:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 19:17:41 +00:00
|
|
|
#include "wx/osx/sound.h"
|
2004-02-01 18:27:25 +00:00
|
|
|
#elif defined(__WXPM__)
|
2004-02-02 13:16:31 +00:00
|
|
|
#include "wx/os2/sound.h"
|
2004-02-04 09:40:17 +00:00
|
|
|
#elif defined(__UNIX__)
|
|
|
|
#include "wx/unix/sound.h"
|
2004-02-01 18:27:25 +00:00
|
|
|
#endif
|
|
|
|
|
2004-02-02 13:16:31 +00: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 18:27:25 +00:00
|
|
|
#endif // _WX_SOUND_H_BASE_
|