Home > Software engineering >  Based on the MFC_ music player, to music, to play under the relevant code
Based on the MFC_ music player, to music, to play under the relevant code

Time:09-30

 
Void CMFCmusicDlg: : OnBnClickedPleyer ()
{
//TODO: add the control notification handler code
If (aa=="")
{
OnBnClickedOpen ();
}
The else
{
If (m_flag & amp; & Aa!="")
{
M_flag=false;
The MCI_OPEN_PARMS McIopenparms;//open the file
MCI_VD_PLAY_PARMS McIplayparms;//play
/* cstrings aa; */
McIopenparms. LpstrElementName=aa;//play path
McIopenparms. LpstrDeviceType=NULL;//file type


//that the operating system to send commands to the MCI news broadcast
McISendCommand (0, MCI_OPEN, MCI_DEVTYPE_WAVEFORM_AUDIO, (DWORD) (LPVOID) & amp; McIopenparms);
M_count=McIopenparms. WDeviceID;//statistical device ID
McIplayparms. DwCallback=(DWORD) GetSafeHwnd ();
Cdlen=getinfo (MCI_STATUS_LENGTH);//get the length of the song
Cdto=MCI_MAKE_HMS (MCI_HMS_HOUR (cdlen), MCI_HMS_MINUTE (cdlen), MCI_HMS_SECOND (cdlen));
McIplayparms. DwFrom=cdfrom;
McIplayparms. DwTo=cdto;


The McISendCommand (m_count MCI_PLAY, MCI_TO | MCI_FROM, (DWORD) (LPVOID) & amp; McIplayparms);
M_sl. SetRange (0, cdlen);
The SetTimer (0, 1000, NULL);
The UpdateData (false);
}
The else
{
M_flag=true;
KillTimer (0);
DWORD DWSF=getinfo (MCI_STATUS_POSITION);
Cdfrom=MCI_MAKE_MSF (MCI_MSF_MINUTE (DWSF), MCI_MSF_SECOND (DWSF), MCI_MSF_FRAME (DWSF));
McISendCommand (m_count MCI_CLOSE, 0, NULL);
M_count=0;

}
}
}



CodePudding user response:

Please check the return values of each function call
GetLastError
  • Related