Author Topic: mciSendCommand play MP3 files  (Read 6400 times)

Offline C++CarlosC++

  • Single posting newcomer
  • *
  • Posts: 2
mciSendCommand play MP3 files
« on: July 03, 2012, 08:21:59 am »
Hi.
Hello, I made a small program to listen to MP3

After listening to 3 or 4 MP3 program crashes, can not close the wDeviceID You know why?

Help

thanks

The Code is:

DWORD MMPlay::mciOpen(LPCSTR lpFileName)
{
     GetShortPathName(lpFileName, ShortFileName, 255);

    UINT wDeviceID;
    DWORD dwReturn;
    MCI_OPEN_PARMS mciOpenParms;
   MCI_SET_PARMS mciSetParms;
   MCI_STATUS_PARMS mciStatusParms;

    mciSetParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
    mciOpenParms.lpstrDeviceType = "mpegvideo";
   mciOpenParms.lpstrElementName = ShortFileName;
   //GetFileTitle(lpFileName, strAlias, 255);
   //mciOpenParms.lpstrAlias = strAlias;

   mciStatusParms.dwItem = MCI_STATUS_LENGTH;
    Sleep(300);
    mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, NULL);
    Sleep(300);
    if (dwReturn = (mciSendCommand(0, MCI_OPEN,
       MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
       (DWORD)(LPVOID) &mciOpenParms)))
    {
        mciError(dwReturn);
        return (0L);
    }

    wDeviceID = mciOpenParms.wDeviceID;

   if (dwReturn = (mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD)(LPVOID) &mciSetParms)))
   {
        mciError(dwReturn);
        return (0L);
    }


    if (dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM,
                                      (DWORD)(LPMCI_STATUS_PARMS) &mciStatusParms))
    {
        mciError(dwReturn);
        return (0L);
    }

    intTrackLenght = (int)mciStatusParms.dwReturn;
    ///////////////

   return wDeviceID;
}




[attachment deleted by admin]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: mciSendCommand play MP3 files
« Reply #1 on: July 03, 2012, 08:34:51 am »
Please respect the forum rules, you have accepted when registering here, and do not ask questions unrelated to Code::Blocks.

There ere several forums around the world, where such questions are allowed and can be answered.

Topic locked!