By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,367 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,367 IT Pros & Developers. It's quick & easy.

Audio Playback

P: 79
I am trying to play a wave file in an MFC application and get the current position while it plays. Iím skeptical about going with DirectSound because I understand that MS has made changes to the DirectX layout in version 10 and Iím not sure how easily it will be to have this functionality work in XP and Vista. Iíve tried the simplified sndPlaySound function, but there doesnít seem to be a way to ask for position status when playing asynchronously. Iíve also tried using MCI:



Expand|Select|Wrap|Line Numbers
  1. mciOpenParms.lpstrDeviceType = "waveaudio";
  2.  
  3. mciOpenParms.lpstrElementName = audioFile;
  4.  
  5. dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID) &mciOpenParms));
  6.  
  7.  
  8.  
  9. waveDeviceID = mciOpenParms.wDeviceID;


Then while it plays,

Expand|Select|Wrap|Line Numbers
  1. MCI_STATUS_PARMS params;
  2.  
  3. params.dwItem = MCI_STATUS_POSITION;
  4.  
  5. params.dwCallback = NULL;
  6.  
  7. params.dwReturn = NULL;
  8.  
  9. params.dwTrack = NULL;
  10.  
  11. sprintf(comm, "status %d position", waveDeviceID);
  12.  
  13. mciSendCommand(waveDeviceID, MCI_STATUS, MCI_STATUS_POSITION , (DWORD)(LPVOID) &params);


But there is no position information in the returned params.



What API should I use and how should I use it to play a wave file and track the play position.
Jun 22 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.