home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / AudioTest / CDAudio.cpp < prev    next >
C/C++ Source or Header  |  2002-05-27  |  4KB  |  144 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. #include "stdafx.h"
  13. #include "audiotest.h"
  14. #include "CDAudio.h"
  15. #include "Audio.h"
  16.  
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. using namespace Audio;
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CCDAudio property page
  27.  
  28. IMPLEMENT_DYNCREATE(CCDAudio, CPropertyPage)
  29.  
  30. CCDAudio::CCDAudio() : CPropertyPage(CCDAudio::IDD)
  31. {
  32.     //{{AFX_DATA_INIT(CCDAudio)
  33.         // NOTE: the ClassWizard will add member initialization here
  34.     //}}AFX_DATA_INIT
  35.     m_bInit = false;
  36. }
  37.  
  38. CCDAudio::~CCDAudio()
  39. {
  40. }
  41.  
  42. void CCDAudio::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CPropertyPage::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CCDAudio)
  46.     DDX_Control(pDX, IDC_CHECK_CD_LOOPING, m_Looping);
  47.     DDX_Control(pDX, IDC_SPIN_TRACK, m_TrackNumber);
  48.     DDX_Control(pDX, IDC_STOP_CD, m_Stop);
  49.     DDX_Control(pDX, IDC_PAUSE_CD, m_Pause);
  50.     DDX_Control(pDX, IDC_PLAY_CD, m_Play);
  51.     //}}AFX_DATA_MAP
  52. }
  53.  
  54.  
  55. BEGIN_MESSAGE_MAP(CCDAudio, CPropertyPage)
  56.     //{{AFX_MSG_MAP(CCDAudio)
  57.     ON_WM_DESTROY()
  58.     ON_BN_CLICKED(IDC_INIT_PLAYER, OnInitPlayer)
  59.     ON_BN_CLICKED(IDC_TERM_PLAYER, OnTermPlayer)
  60.     ON_BN_CLICKED(IDC_PLAY_CD, OnPlayCD)
  61.     ON_BN_CLICKED(IDC_PAUSE_CD, OnPauseCD)
  62.     ON_BN_CLICKED(IDC_STOP_CD, OnStopCD)
  63.     ON_BN_CLICKED(IDC_CHECK_CD_LOOPING, OnCheckCdLooping)
  64.     //}}AFX_MSG_MAP
  65. END_MESSAGE_MAP()
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CCDAudio message handlers
  69.  
  70. BOOL CCDAudio::OnInitDialog() 
  71. {
  72.     CPropertyPage::OnInitDialog();
  73.     
  74.     // Load the play button icons
  75.     m_hPlayIcon = LoadIcon(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_PLAY));
  76.     m_hPauseIcon = LoadIcon(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_PAUSE));
  77.     m_hStopIcon = LoadIcon(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_STOP));
  78.  
  79.     // Set the master play control buttons
  80.     m_Play.SetIcon(m_hPlayIcon);
  81.     m_Pause.SetIcon(m_hPauseIcon);
  82.     m_Stop.SetIcon(m_hStopIcon);
  83.  
  84.     // Set the track spinner range and default position
  85.     m_TrackNumber.SetRange(1, 99);
  86.     m_TrackNumber.SetPos(1);
  87.  
  88.     m_bInit = true;
  89.     
  90.     return TRUE;  // return TRUE unless you set the focus to a control
  91.                   // EXCEPTION: OCX Property Pages should return FALSE
  92. }
  93.  
  94. void CCDAudio::OnDestroy() 
  95. {
  96.     CPropertyPage::OnDestroy();
  97.     
  98.     // TODO: Add your message handler code here
  99.     
  100. }
  101.  
  102. void CCDAudio::OnInitPlayer() 
  103. {
  104.     CDPlayer()->Init(GetSafeHwnd());
  105.     CDPlayer()->Play();
  106.  
  107.  
  108. }
  109.  
  110. void CCDAudio::OnTermPlayer() 
  111. {
  112.     CDPlayer()->Term();
  113. }
  114.  
  115. void CCDAudio::OnPlayCD() 
  116. {
  117.     CDPlayer()->SetCurrentTrack(m_TrackNumber.GetPos());
  118.     CDPlayer()->Play();
  119. }
  120.  
  121. void CCDAudio::OnPauseCD() 
  122. {
  123.     CDPlayer()->Pause();
  124. }
  125.  
  126. void CCDAudio::OnStopCD() 
  127. {
  128.     CDPlayer()->Stop();
  129. }
  130.  
  131. void CCDAudio::OnCheckCdLooping() 
  132. {
  133.     CDPlayer()->SetLooping((m_Looping.GetCheck()) ? true : false);
  134. }
  135.  
  136.  
  137. LRESULT CCDAudio::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  138. {
  139.     if(message == MM_MCINOTIFY)
  140.         CDPlayer()->OnMCINotify(wParam, lParam);
  141.     
  142.     return CPropertyPage::WindowProc(message, wParam, lParam);
  143. }
  144.