MciPlayer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _MCI_PLAYER_WIN32_H_
  2. #define _MCI_PLAYER_WIN32_H_
  3. #include "platform/CCStdC.h"
  4. #include <mmsystem.h>
  5. #include <string>
  6. using namespace std;
  7. namespace CocosDenshion {
  8. class MciPlayer
  9. {
  10. public:
  11. MciPlayer();
  12. ~MciPlayer();
  13. void Close();
  14. /**
  15. @brief Open audio file
  16. @param pFileName The file name which includes the file path.
  17. @param uId The audio ID
  18. */
  19. void Open(const char* pFileName, UINT uId);
  20. /**
  21. @brief Play audio file
  22. @param nTimes The repeat times, its default value is 1 which means only play once
  23. */
  24. void Play(UINT uTimes = 1);
  25. /**
  26. @brief Pause play
  27. */
  28. void Pause();
  29. /**
  30. @brief Resume play
  31. */
  32. void Resume();
  33. /**
  34. @brief Stop play
  35. */
  36. void Stop();
  37. /**
  38. @brief Replay
  39. */
  40. void Rewind();
  41. /**
  42. @brief Is Playing
  43. */
  44. bool IsPlaying();
  45. /**
  46. @brief Get playing sound's ID
  47. @return Sound's ID
  48. */
  49. UINT GetSoundID();
  50. private:
  51. friend LRESULT WINAPI _SoundPlayProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  52. void _SendGenericCommand(int nCommand, DWORD_PTR param1 = 0, DWORD_PTR parma2 = 0);
  53. HWND _wnd;
  54. MCIDEVICEID _dev;
  55. UINT _soundID;
  56. UINT _times;
  57. bool _playing;
  58. std::string strExt;
  59. };
  60. } // end of namespace CocosDenshion
  61. #endif