-
It's a funny old MCI...
Hello,
Today I decided to facilitate my need for a media player that maintains a playlist (I won't go near Windows Media Player as it's too bloated now, and Winamp's overkill), using the MCI. It seems to work (i.e. It plays), but the mechanism I'm using to display the current time of the track seems to be a smidge inaccurate:-
Code:
(At start of playback, do a SetTimer(hwnd, 0x1234, 1000, NULL). At the end, KillTimer.)
(In WindowProc)
case WM_TIMER:
{
char szTitle[256];
MCI_STATUS_PARMS sp;
ZeroMemory(&sp, sizeof(MCI_STATUS_PARMS));
sp.dwItem = MCI_STATUS_POSITION;
mciSendCommand(wDeviceID, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (DWORD)&sp);
wsprintf(szTitle, "%s - [%02u:%02u]", playlist[iCurrentSong].szTitle, (sp.dwReturn / 60000) % 60, (sp.dwReturn / 1000) % 60);
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)szTitle);
break;
}
Now, I've tried printing the raw value of sp.dwReturn and as the values it returns aren't clean seconds (e.g. 1023 after 1 second) it wouldnever keep time properly (It skips seconds sometimes). I was hoping there was a notification mechanism for this as it would be more accurate. Ideas?
-
I use
Code:
KillTimer(hWnd,uSoundTimer);
MMTime.wType=TIME_BYTES;
waveOutGetPosition( hWaveOut, &MMTime, sizeof(MMTIME));
//use the info
uSoundTimer= SetTimer( hWnd, (SOUNDPOS), SOUND_SLIDER, NULL);//reset the timer (used some defines)
-
Does that work for non-wave devices? I'm using MCI to play Ogg Vorbis files, with the device type set to "MPEGVideo" (So it'll go through DirectShow).