sound.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/sound.h
  3. // Purpose: wxSound class (loads and plays short Windows .wav files).
  4. // Optional on non-Windows platforms.
  5. // Authors: David Elliott, Ryan Norton
  6. // Modified by:
  7. // Created: 2004-10-02
  8. // Copyright: (c) 2004 David Elliott, Ryan Norton
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_COCOA_SOUND_H_
  12. #define _WX_COCOA_SOUND_H_
  13. #include "wx/object.h"
  14. #include "wx/cocoa/ObjcRef.h"
  15. class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
  16. {
  17. public:
  18. wxSound()
  19. : m_cocoaNSSound(NULL)
  20. {}
  21. wxSound(const wxString& fileName, bool isResource = false)
  22. : m_cocoaNSSound(NULL)
  23. { Create(fileName, isResource); }
  24. wxSound(size_t size, const void* data)
  25. : m_cocoaNSSound(NULL)
  26. { LoadWAV(data,size,true); }
  27. wxSound(const wxSound& sound); // why not?
  28. virtual ~wxSound();
  29. public:
  30. bool Create(const wxString& fileName, bool isResource = false);
  31. bool IsOk() const
  32. { return m_cocoaNSSound; }
  33. static void Stop();
  34. static bool IsPlaying();
  35. void SetNSSound(WX_NSSound cocoaNSSound);
  36. inline WX_NSSound GetNSSound()
  37. { return m_cocoaNSSound; }
  38. protected:
  39. bool DoPlay(unsigned flags) const;
  40. bool LoadWAV(const void* data, size_t length, bool copyData);
  41. private:
  42. WX_NSSound m_cocoaNSSound;
  43. static const wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaDelegate;
  44. };
  45. #endif //ndef _WX_COCOA_SOUND_H_