Thread: It's a funny old MCI...

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273

    Question 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?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    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).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems loading mp3s with MCI
    By elmutt in forum Windows Programming
    Replies: 8
    Last Post: 07-31-2007, 10:43 PM
  2. funny things
    By Benzakhar in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2004, 11:06 AM
  3. Object Oriented - Funny story
    By MethodMan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-26-2002, 02:21 PM
  4. Funny Programming Website
    By MethodMan in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-13-2002, 10:59 PM
  5. Funny
    By Imperito in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-21-2002, 05:41 PM