2009-01-17 05:43:43 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/osx/sound.h
|
2009-01-17 05:43:43 -05:00
|
|
|
// Purpose: wxSound class (loads and plays short Windows .wav files).
|
|
|
|
// Optional on non-Windows platforms.
|
|
|
|
// Author: Ryan Norton, Stefan Csomor
|
|
|
|
// Modified by:
|
|
|
|
// Created: 1998-01-01
|
|
|
|
// Copyright: (c) Ryan Norton, Stefan Csomor
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SOUND_H_
|
|
|
|
#define _WX_SOUND_H_
|
|
|
|
|
|
|
|
#if wxUSE_SOUND
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
|
2009-09-26 12:43:37 -04:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxSoundTimer;
|
2009-09-13 14:28:45 -04:00
|
|
|
|
|
|
|
class WXDLLIMPEXP_ADV wxSoundData
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
wxSoundData();
|
|
|
|
virtual ~wxSoundData();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
virtual bool Play(unsigned int flags) = 0;
|
|
|
|
// stops the sound and deletes the optional timer
|
|
|
|
virtual void Stop();
|
2009-12-30 12:41:29 -05:00
|
|
|
// mark this to be deleted
|
|
|
|
virtual void MarkForDeletion();
|
|
|
|
virtual bool IsMarkedForDeletion() const { return m_markedForDeletion; }
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
// does the true work of stopping and cleaning up
|
|
|
|
virtual void DoStop() = 0;
|
2014-04-12 18:56:17 -04:00
|
|
|
|
|
|
|
#if wxOSX_USE_CARBON
|
|
|
|
// can be called by a timer for repeated tasks during playback
|
|
|
|
virtual void SoundTask();
|
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
protected :
|
|
|
|
void CreateAndStartTimer();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
wxSoundTimer* m_pTimer;
|
2014-04-12 18:56:17 -04:00
|
|
|
#endif // wxOSX_USE_CARBON
|
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned int m_flags;
|
2009-12-30 12:41:29 -05:00
|
|
|
bool m_markedForDeletion;
|
2009-09-13 14:28:45 -04:00
|
|
|
} ;
|
|
|
|
|
2009-01-17 05:43:43 -05:00
|
|
|
class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
|
|
|
|
{
|
|
|
|
public:
|
2009-09-13 14:28:45 -04:00
|
|
|
wxSound();
|
2009-10-09 13:39:19 -04:00
|
|
|
wxSound(const wxString& fileName, bool isResource = false);
|
2011-09-21 11:08:02 -04:00
|
|
|
wxSound(size_t size, const void* data);
|
2009-09-13 14:28:45 -04:00
|
|
|
virtual ~wxSound();
|
2009-01-17 05:43:43 -05:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
// Create from resource or file
|
2009-10-09 13:39:19 -04:00
|
|
|
bool Create(const wxString& fileName, bool isResource = false);
|
2009-09-13 14:28:45 -04:00
|
|
|
// Create from data
|
2011-09-21 11:08:02 -04:00
|
|
|
bool Create(size_t size, const void* data);
|
2009-01-17 05:43:43 -05:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
bool IsOk() const { return m_data != NULL; }
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
// Stop playing any sound
|
|
|
|
static void Stop();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
// Returns true if a sound is being played
|
|
|
|
static bool IsPlaying();
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
// Notification when a sound has stopped
|
|
|
|
static void SoundStopped(const wxSoundData* data);
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-08-21 06:41:26 -04:00
|
|
|
protected:
|
2009-09-13 14:28:45 -04:00
|
|
|
bool DoPlay(unsigned flags) const;
|
|
|
|
void Init();
|
2009-01-17 05:43:43 -05:00
|
|
|
|
|
|
|
private:
|
2009-09-13 14:28:45 -04:00
|
|
|
// data of this object
|
|
|
|
class wxSoundData *m_data;
|
2010-09-30 07:44:45 -04:00
|
|
|
|
2009-09-13 14:28:45 -04:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxSound);
|
2009-01-17 05:43:43 -05:00
|
|
|
};
|
|
|
|
|
2008-06-11 12:30:48 -04:00
|
|
|
#endif
|
2009-01-17 05:43:43 -05:00
|
|
|
#endif
|
|
|
|
// _WX_SOUND_H_
|