sound.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/sound.h
  3. // Purpose: wxSound class (loads and plays short Windows .wav files).
  4. // Optional on non-Windows platforms.
  5. // Author: Ryan Norton, Stefan Csomor
  6. // Modified by:
  7. // Created: 1998-01-01
  8. // Copyright: (c) Ryan Norton, Stefan Csomor
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_SOUND_H_
  12. #define _WX_SOUND_H_
  13. #if wxUSE_SOUND
  14. #include "wx/object.h"
  15. class WXDLLIMPEXP_FWD_ADV wxSoundTimer;
  16. class WXDLLIMPEXP_ADV wxSoundData
  17. {
  18. public :
  19. wxSoundData();
  20. virtual ~wxSoundData();
  21. virtual bool Play(unsigned int flags) = 0;
  22. // stops the sound and deletes the optional timer
  23. virtual void Stop();
  24. // can be called by a timer for repeated tasks during playback
  25. virtual void SoundTask();
  26. // mark this to be deleted
  27. virtual void MarkForDeletion();
  28. virtual bool IsMarkedForDeletion() const { return m_markedForDeletion; }
  29. // does the true work of stopping and cleaning up
  30. virtual void DoStop() = 0;
  31. protected :
  32. void CreateAndStartTimer();
  33. unsigned int m_flags;
  34. wxSoundTimer* m_pTimer;
  35. bool m_markedForDeletion;
  36. } ;
  37. class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
  38. {
  39. public:
  40. wxSound();
  41. wxSound(const wxString& fileName, bool isResource = false);
  42. wxSound(size_t size, const void* data);
  43. virtual ~wxSound();
  44. // Create from resource or file
  45. bool Create(const wxString& fileName, bool isResource = false);
  46. // Create from data
  47. bool Create(size_t size, const void* data);
  48. bool IsOk() const { return m_data != NULL; }
  49. // Stop playing any sound
  50. static void Stop();
  51. // Returns true if a sound is being played
  52. static bool IsPlaying();
  53. // Notification when a sound has stopped
  54. static void SoundStopped(const wxSoundData* data);
  55. protected:
  56. bool DoPlay(unsigned flags) const;
  57. void Init();
  58. private:
  59. // data of this object
  60. class wxSoundData *m_data;
  61. wxDECLARE_NO_COPY_CLASS(wxSound);
  62. };
  63. #endif
  64. #endif
  65. // _WX_SOUND_H_