home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / audio_sdk / include / AudioLib / CDPlayer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-27  |  2.2 KB  |  103 lines

  1. /***********************************************************\
  2. Copyright (C) James Boer, 2002. 
  3. All rights reserved worldwide.
  4.  
  5. This software is provided "as is" without express or implied
  6. warranties. You may freely copy and compile this source into
  7. applications you distribute provided that the copyright text
  8. below is included in the resulting source code, for example:
  9. "Portions Copyright (C) James Boer, 2002"
  10. \***********************************************************/
  11.  
  12.  
  13. /*
  14. Notes:
  15.  
  16. In the window's message handler, you should check for the case 
  17. MM_MCINOTIFY, and call the OnMCINotify() function in response.
  18.  
  19. This is an example of what a typical Win32 program's message 
  20. handler might look like:
  21.  
  22. long WINAPI _export WindowProc(HWND window, UINT message,
  23.     UINT wParam, LONG lParam)
  24. {
  25.     switch (message)
  26.     {
  27.  
  28.     .
  29.     .
  30.     .
  31.  
  32.     case MM_MCINOTIFY:
  33.  
  34.         CDPlayer()->OnMCINotify(wParam, lParam);
  35.         break;
  36.     }
  37.  
  38. */
  39.  
  40.  
  41. #ifndef __CDPLAYER_H
  42. #define __CDPLAYER_H
  43.  
  44. namespace Audio
  45. {
  46.  
  47. class CDPlay
  48. {
  49. private:
  50.  
  51. enum CD_STATUS_TYPE
  52. {
  53.     CDSTATUS_STOPPED,
  54.     CDSTATUS_PAUSED,
  55.     CDSTATUS_PLAY,
  56. };
  57.  
  58.  
  59. public:
  60.     CDPlay();
  61.     virtual ~CDPlay();
  62.  
  63.     void Clear();
  64.  
  65.     bool Init(HWND hWindow, const char* pDrive = NULL);
  66.     void Term();
  67.  
  68.     bool Play();
  69.     bool Pause();
  70.     bool Stop();
  71.  
  72.     bool OnMCINotify(WPARAM wParam, LPARAM lParam);
  73.  
  74.     void SetLooping(bool loop)            {  m_bLoop = loop;  }
  75.     UINT GetCurrentTrack()                {  return m_nCurrentTrack;  }
  76.     void SetCurrentTrack(UINT track)    {  m_nCurrentTrack = track;  }
  77.     bool IsPlaying()                    {  return (m_Status == CDSTATUS_PLAY) ? true : false;  }
  78.     bool IsPaused()                        {  return (m_Status == CDSTATUS_PAUSED) ? true : false;  }
  79.  
  80. private:
  81.     // Window handle is required for the callback function
  82.     HWND m_hWindow;
  83.     // The MCI function requires this device ID
  84.     MCIDEVICEID m_iDeviceID;
  85.     // The currently playing or selected track
  86.     uint32 m_nCurrentTrack;
  87.     // Indicates whether the CD Player should loop the tracks
  88.     bool m_bLoop;
  89.     // Current status of the CD Player
  90.     CD_STATUS_TYPE m_Status;
  91.     // CD player is initialized
  92.     bool m_bInitialized;
  93. };
  94.  
  95. static CDPlay* CDPlayer()
  96. {  static CDPlay cdplyr;  return &cdplyr;  }
  97.  
  98.  
  99. }; // namespace Audio
  100.  
  101.  
  102.  
  103. #endif // __CDPLAYER_H