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:-
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?
(At start of playback, do a SetTimer(hwnd, 0x1234, 1000, NULL). At the end, KillTimer.)
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);