Пример #1
0
void CMidi::MciStop()
{
  DWORD dwReturn;
  MCI_GENERIC_PARMS  mciGenParms;
  MCI_STATUS_PARMS   mciStatParms;

  // Error message mechanism
  char mciErrorString[MCI_ERROR_LENGTH];
  UINT mciErrorLen;
  BOOL KnownError = FALSE;

  // Check if MIDI was intialized at all
  if (!m_bMidiInitialized)
	return;

  memset(&mciStatParms,0,sizeof(mciStatParms));
  mciStatParms.dwItem = MCI_STATUS_MODE;

  if ( (dwReturn = mciSendCommand(m_uMCIDeviceID, MCI_STATUS,
        MCI_STATUS_ITEM, (DWORD) (LPMCI_STATUS_PARMS) &mciStatParms)) != 0)
  {

      mciErrorLen = MCI_ERROR_LENGTH;
      KnownError = mciGetErrorString(dwReturn, mciErrorString, mciErrorLen);
      TRACE("Couldn't Get Midi status in MidiStop\n");
      if (KnownError)
       TRACE("MCI ERROR : %s\n", mciErrorString);
      else
       TRACE("MCI ERROR : Unknown Error (%x)!!!!! \n",dwReturn);
  }

  // Check if midi is being played at all
  if (mciStatParms.dwReturn != MCI_MODE_PLAY)
    return;

  mciGenParms.dwCallback=0;

  if ( (dwReturn = mciSendCommand(m_uMCIDeviceID, MCI_PAUSE, 0L,
                (DWORD)(LPMCI_GENERIC_PARMS) &mciGenParms)) != 0)
  {

      mciErrorLen = MCI_ERROR_LENGTH;
      KnownError = mciGetErrorString(dwReturn, mciErrorString, mciErrorLen);
      TRACE("Couldn't PAUSE Midi seq. in MidiStop\n");
      if (KnownError)
       TRACE("MCI ERROR : %s\n", mciErrorString);
      else
       TRACE("MCI ERROR : Unknown Error (%x)!!!!! \n",dwReturn);

      // Failed. Close Device and return error.
      //mciSendCommand(m_uMCIDeviceID, MCI_CLOSE, 0, NULL);
      //m_uMCIDeviceID = 0;
      //m_bMidiInitialized = FALSE;
      //return FALSE;
  }

  m_bMidiIsPlaying = FALSE;
  return;
}
Пример #2
0
void MciPlayer::open(const string& fileName)
{
	if( fileName.empty() ) return;

	string fullPath = magician::RES_PATH;
	fullPath += fileName;
	//WCHAR* fileNameWideChar = str2wchar( fullPath );

	MCI_OPEN_PARMS mciOpen = { 0 };
	mciOpen.lpstrElementName = fullPath.c_str();
	s_mciError = mciSendCommand(0, MCI_OPEN,
			MCI_OPEN_ELEMENT, (DWORD_PTR)&mciOpen);

	if( s_mciError ) 
	{
		cout<<"Error: BGM load fail!\n";
		char buf[200];
		mciGetErrorString(s_mciError, buf, sizeof(buf));
		cout<<buf<<endl;
	}

	device = mciOpen.wDeviceID;
	//delete[] fileNameWideChar;

	MCI_STATUS_PARMS mciStatus;
    mciStatus.dwItem = MCI_STATUS_LENGTH;
	mciSendCommand(device, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
    miliLength = mciStatus.dwReturn; 
}
Пример #3
0
BOOL PSMMRewindWave( USHORT usDevID )
{
    MCI_SEEK_PARMS      mseekp;
    MCI_GENERIC_PARMS   mgenp;
    ULONG               ulRC;
    char                pszErrBuf[ 128 ];

    if( !usDevID )
    {
        return( FALSE );
    }

    memset( &mseekp, 0, sizeof( mseekp ) );
    memset( &mgenp, 0, sizeof( mgenp ) );

    ulRC = mciSendCommand(  usDevID,
                            MCI_ACQUIREDEVICE,
                            MCI_WAIT,
                            &mgenp,
                            0 );

    ulRC = mciSendCommand(  usDevID,
                            MCI_SEEK,
                            MCI_WAIT | MCI_TO_START,
                            &mseekp,
                            0 );

    if( LOUSHORT( ulRC ) != MCIERR_SUCCESS )
    {
        mciGetErrorString( ulRC, pszErrBuf, sizeof( pszErrBuf ) );
        return( FALSE );
    }

    return( TRUE );
}
Пример #4
0
void SND_LogMCI_Error(char* commmand,int cmdResult)
{
	wchar_t errorMessage[128];

	mciGetErrorString(cmdResult,errorMessage,sizeof(errorMessage));

	Log_Printf("MCI Error '%ls' reason: '%s'\n",errorMessage,commmand);
}
Пример #5
0
//This function cannot play same file simutaneously, but not for different file.
void SystemClass::PlaySoundFile(std::string fileName)
{
	std::string playCmd = "play mp3" + fileName +" from 0";
	auto msg = mciSendStringA(playCmd.c_str(), NULL, 0, 0);
	WCHAR tmp[128];
	mciGetErrorString(msg, tmp, 128);

}
Пример #6
0
static int mcierr (TCHAR *str, DWORD err)
{
	TCHAR es[1000];
	if (err == MMSYSERR_NOERROR)
		return MMSYSERR_NOERROR;
	if (mciGetErrorString (err, es, sizeof es))
		write_log (_T("MCIErr: %s: %d = '%s'\n"), str, err, es);
	return err;
}
Пример #7
0
void ShowError (HWND hwnd, DWORD dwError)
{
     TCHAR szErrorStr [1024] ;
     
     mciGetErrorString (dwError, szErrorStr, 
                        sizeof (szErrorStr) / sizeof (TCHAR)) ;
     MessageBeep (MB_ICONEXCLAMATION) ;
     MessageBox (hwnd, szErrorStr, szAppName, MB_OK | MB_ICONEXCLAMATION) ;
}
Пример #8
0
void SystemClass::PreLoadSoundFile(std::string fileName)
{
	std::string openCmd = "open " + fileName + " type mpegvideo alias mp3"+fileName;
	WCHAR tmp[128];

	auto msg = mciSendStringA(openCmd.c_str(), NULL, 128, 0);
	mciGetErrorString(msg, tmp, 128);

}
Пример #9
0
			//////////////////////////////////////
			// Wave Function
			//////////////////////////////////////
DllExport LPTSTR CDAudio(UINT msg, DWORD TrackNumber)
{
	mciSendCommand(PlayCDId, MCI_CLOSE, 0, 0);

	MCIERROR MciError;
	MCI_OPEN_PARMS Open;
	memset(&Open, 0, sizeof(MCI_OPEN_PARMS));
	Open.lpstrDeviceType = MAKEINTRESOURCE(MCI_DEVTYPE_CD_AUDIO); 
	DWORD style = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID;
	MciError = mciSendCommand(0, MCI_OPEN, style, DWORD(&Open));   
	PlayCDId = Open.wDeviceID;
//	Setting format to play Track
	if(!MciError)
			{
			MCI_SET_PARMS InfoSet;
			memset(&InfoSet, 0, sizeof(MCI_SET_PARMS));
			InfoSet.dwTimeFormat	= MCI_FORMAT_TMSF;
			MciError = mciSendCommand(PlayCDId, MCI_SET, MCI_SET_TIME_FORMAT, DWORD(&InfoSet));
			}
	switch(msg)
		{
			case PLAY:
				{
// Playing CD
				if(!MciError)
					{
						MCI_PLAY_PARMS InfoPlay;
						memset(&InfoPlay, 0, sizeof(MCI_PLAY_PARMS));
						InfoPlay.dwFrom	= MCI_MAKE_TMSF(TrackNumber,0,0,0);
						MciError = mciSendCommand(PlayCDId, MCI_PLAY, MCI_FROM | MCI_NOTIFY, DWORD(&InfoPlay));
					}
				}	break;
			case STOP:
				{
					MCI_GENERIC_PARMS GenInfo;
					memset(&GenInfo, 0, sizeof(MCI_GENERIC_PARMS));
					GenInfo.dwCallback = 0;
					mciSendCommand(PlayCDId, MCI_STOP, MCI_NOTIFY, DWORD(&GenInfo));
				}	break;
			case SEEK:
				{
					MCI_SEEK_PARMS InfoSeek;
					memset(&InfoSeek, 0, sizeof(MCI_SEEK_PARMS));
					InfoSeek.dwTo	= MCI_MAKE_TMSF(TrackNumber,0,0,0);
					MciError = mciSendCommand(PlayCDId, MCI_SEEK, MCI_TO, DWORD(&InfoSeek));
				}
			case PAUSE:
				{
					MCI_GENERIC_PARMS GenInfo;
					memset(&GenInfo, 0, sizeof(MCI_GENERIC_PARMS));
					mciSendCommand(PlayCDId, MCI_PAUSE, 0, DWORD(&GenInfo));
				}
		}
mciGetErrorString(MciError, error, sizeof(error));
return error;
}
Пример #10
0
void MusicBox::resume(int id)
{
	MCIERROR mciErr=mciSendCommand(m_ID[id],MCI_RESUME,0,(DWORD)&mciPlay);
	if(mciErr)
	{
		char str[128];
		mciGetErrorString(mciErr,str,128);
		MessageBox(NULL,str,"提示",0);
	}
}
Пример #11
0
/* General ioctl() CD-ROM command function */
bool CDROM_Interface_Ioctl::mci_CDioctl(UINT msg, DWORD flags, void *arg) {
	MCIERROR mci_error = mciSendCommand(mci_devid, msg, flags, (DWORD_PTR)arg);
	if (mci_error!=MMSYSERR_NOERROR) {
		char error[256];
		mciGetErrorString(mci_error, error, 256);
		LOG_MSG("mciSendCommand() error: %s", error);
		return true;
	}
	return false;
}
Пример #12
0
bool DART::SetError (APIRET rc)
{
  if (rc)
  {
    mciGetErrorString (rc, (PSZ) ErrorCode, sizeof (ErrorCode));
    return true;
  }
  ErrorCode [0] = 0;
  return false;
}
Пример #13
0
bool AudioPlayer::SendString(const char* value) {
	DWORD result = mciSendString(value,NULL,0,hwnd); // returns zero on success...
	if(!result) {
		return true;
	} else {
		if(mciGetErrorString(result,errorbuffer,BUFFERSIZE)) {
			char caption[256];
			snprintf(caption,256,"Error sending command \"%s\"",commandbuffer);
			MessageBox(hwnd,errorbuffer,caption,MB_OK);
		}
		return false;
	}
}
Пример #14
0
/* General ioctl() CD-ROM command function */
static int SDL_SYS_CDioctl(int id, UINT msg, DWORD flags, void *arg)
{
	MCIERROR mci_error;

	mci_error = mciSendCommand(SDL_mciID[id], msg, flags, (DWORD_PTR)arg);
	if ( mci_error ) {
		char error[256];

		mciGetErrorString(mci_error, error, 256);
		SDL_SetError("mciSendCommand() error: %s", error);
	}
	return(!mci_error ? 0 : -1);
}
Пример #15
0
static int mci_send_string(const char* cmd_str)
{
	mci_err = mciSendString(cmd_str, ret_str, sizeof(ret_str), hwndApp);
	if (mci_err) {
		if (mciGetErrorString(mci_err, err_str, sizeof(err_str)))
		Print("Error (%s): '%s'\n", cmd_str, err_str);
		else
		Print("Error (%s): %d - UNKNOWN\n", cmd_str, mci_err);
		return 0;   
	}

	return 1;
}
Пример #16
0
/* General ioctl() CD-ROM command function */
static bool
_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
{
  MCIERROR mci_error;

  mci_error = mciSendCommand(id, msg, flags, (DWORD_PTR)arg);
  if ( mci_error ) {
    char error[256];

    mciGetErrorString(mci_error, error, 256);
    cdio_warn("mciSendCommand() error: %s", error);
  }
  return(mci_error == 0);
}
Пример #17
0
//=============================================================================
// handle MCI errors
//=============================================================================
void CCDAudio::MCIError( MCIERROR m_nErrorCode )
{
	TCHAR szBuff[128];
	memset(szBuff, 0, sizeof(szBuff));

	if( !mciGetErrorString( m_nErrorCode, szBuff, sizeof(szBuff) ) )
	{
        lstrcpy( szBuff, _T("Unknown error") );
	}

	::MessageBox( NULL, szBuff, _T("MCI Error"), MB_OK | MB_ICONERROR );

	m_nErrorCode = 0;
}
Пример #18
0
void MciPlayer::startPlay()
{
    MCI_PLAY_PARMS mciPlay = { 0 };
	s_mciError = mciSendCommand(device, MCI_PLAY,
			MCI_DGV_PLAY_REPEAT, (DWORD_PTR)&mciPlay);

	if( s_mciError ) 
	{
		cout<<"Error: BGM play fail!\n";
		char buf[200];
		mciGetErrorString(s_mciError, buf, sizeof(buf));
		cout<<buf<<endl;
	}
}
Пример #19
0
void MusicBox::del(int id)  //删除一个音乐设备
{
	MCIERROR mciErr=mciSendCommand(m_ID[id],MCI_CLOSE,0,(DWORD)&mciPlay);
	if(mciErr)
	{
		char str[128];
		mciGetErrorString(mciErr,str,128);
		MessageBox(NULL,str,"提示",0);
	}
	for(int i=id;i<m_nID;i++)
	{
		m_ID[i]=m_ID[i+1];
	}
}
Пример #20
0
static void MciError(ULONG ulError)
{
	unsigned char buffer[128];
	ULONG rc;
	
	rc = mciGetErrorString(ulError, buffer, sizeof(buffer));
	
	if (rc == MCIERR_SUCCESS)
		sprintf(mmerror,"MCI Error %d: %s",ULONG_LOWD(ulError),buffer);
	else
		sprintf(mmerror,"MCI Error %d: Cannot query error message.",ULONG_LOWD(rc));
	
	error1("%s",mmerror);
}
Пример #21
0
BOOL mciExecute(LPCTSTR szCommand) {
     MCIERROR error ;
     TCHAR    szErrorStr[1024] ;

     if (error = mciSendString(szCommand, NULL, 0, NULL)) {
         log_to_text("Something wroing with MCI\n");
         mciGetErrorString(error, szErrorStr,
             sizeof(szErrorStr) / sizeof(TCHAR)) ;
         MessageBeep(MB_ICONEXCLAMATION);
         MessageBox(NULL, szErrorStr, TEXT("MCI Error"), 
             MB_OK | MB_ICONEXCLAMATION);
     }
     return error == 0;
}
Пример #22
0
			//////////////////////////////////////
			// Midi Function
			//////////////////////////////////////
DllExport LPTSTR MIDI(UINT msg, HWNDdll hwnd)
{
	mciSendCommand(MidiId, MCI_CLOSE, 0, 0);

	MCIERROR MciError;
	MCI_OPEN_PARMS Open;
	memset(&Open, 0, sizeof(MCI_OPEN_PARMS));
	Open.lpstrElementName = File;
	DWORD style = MCI_OPEN_ELEMENT;
	MciError = mciSendCommand(0, MCI_OPEN, style, DWORD(&Open));    
	MidiId = Open.wDeviceID;
	if(!MciError)
		{
			MCI_SET_PARMS InfoSet;
			memset(&InfoSet, 0, sizeof(MCI_SET_PARMS));
			InfoSet.dwTimeFormat	= MCI_FORMAT_MILLISECONDS;
			MciError = mciSendCommand(MidiId, MCI_SET, MCI_SET_TIME_FORMAT, DWORD(&InfoSet));
		}

switch(msg)
	{
	case PLAY:
		if(!MciError)
			{
				MCI_STATUS_PARMS InfoStat;
				memset(&InfoStat, 0, sizeof(MCI_STATUS_PARMS));
				InfoStat.dwCallback = 0;
				InfoStat.dwItem			= MCI_STATUS_LENGTH;
				InfoStat.dwTrack		= 0;
				MciError = mciSendCommand(MidiId, MCI_STATUS, MCI_STATUS_ITEM, DWORD(&InfoStat));

				MCI_PLAY_PARMS InfoPlay;
				memset(&InfoPlay, 0, sizeof(MCI_PLAY_PARMS));
				InfoPlay.dwCallback = (DWORD)hwnd;
				InfoPlay.dwFrom	= (DWORD)(sec * 1000);
				MciError = mciSendCommand(MidiId, MCI_PLAY, MCI_FROM | MCI_NOTIFY, DWORD(&InfoPlay));

				MTimeRate = (InfoStat.dwReturn) - (sec * 1000);
				SetTimer(hwnd, ID_MTIMER, MTimeRate, NULL);
			}
		break;
	case STOP:
		mciSendCommand(MidiId, MCI_STOP, 0, 0);
		break;
	}

	mciGetErrorString(MciError, error, sizeof(error));
	return error;
}
Пример #23
0
// Takes an MCIERROR (these are returned from calls to mciSendCommand())
// and prints out the error if one exists
void CAudioCD::dispError(MCIERROR error_code)
{
	if(error_code) // Make sure we have an error_code
	{
		char error_str[1024] = {0};

		// This function will fill "error_str" with the error message
		mciGetErrorString(error_code,error_str,1024);

		// Display a message box with the error
		MessageBox(win_hwnd,error_str,"Error",MB_OK | MB_ICONERROR);

	}

}
Пример #24
0
static int command(char *fmt, ...)
{
    char buf[256];
    va_list ap;
    DWORD err;
    
    va_start(ap, fmt);
    vsprintf(buf, fmt, ap);
    va_end(ap);

    err = mciSendString(buf, ret, sizeof ret, 0);
    if (err) 
	mciGetErrorString(err, _cd_error, sizeof _cd_error);
    return err ? -1 : 0;
}
Пример #25
0
void CMyDlg::OnPlay() 
{
//mciSendCommand(NULL,MCI_OPEN,MCI_WAIT|MCI_OPEN_TYPE,(DWORD)&openParms);
//mciID=mciGetDeviceID( openParms.lpstrDeviceType );
//mciSendCommand(mciID,MCI_SET,MCI_WAIT|MCI_SET_DOOR_OPEN,NULL);
//mciSendCommand(mciID,MCI_SET,MCI_WAIT|MCI_SET_DOOR_CLOSED,NULL);

CString str;
	char str1[100];
	int nItem;
	POSITION pos=m_list.GetFirstSelectedItemPosition(); 
if(pos!=NULL)
{
	nItem=m_list.GetNextSelectedItem(pos);
index=nItem;
   str=m_list.GetItemText(nItem,3);
}
if(open.wDeviceID)
{
  mciSendCommand(open.wDeviceID,MCI_CLOSE,0,0);
}

open.lpstrElementName=str;//"F:\\音乐\\11\\陈楚生  有没有人告诉你.mp3";//"C:\\oo.mp3";
open.lpstrDeviceType="mpegvideo";
err=mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE|MCI_OPEN_ELEMENT|MCI_WAIT,(DWORD)(LPVOID)&open);
if(err==0)
{
MCI_PLAY_PARMS play;
//play.dwFrom=0;
//play.dwCallback=(UINT)this->m_hWnd;
mciSendCommand(open.wDeviceID,MCI_PLAY,0,(DWORD)&play);
::Sleep(1000);
::CreateThread(NULL,0,setprocess,GetDlgItem(IDC_STA1)->m_hWnd,0,NULL);

//char wStr[256]={0};
//ReadProcessMemory(::GetCurrentProcess(),LPVOID(npos),&wStr,sizeof(npos),0);
}
else
{

	mciGetErrorString(err,(LPSTR)str1,100);
	MessageBox(str1);
}
 GetDlgItem(IDC_STOP)->SetWindowText("停止");
}
Пример #26
0
long Tmainwin::executesoundcommand(UINT ui, long ln)
{
	StrChar rt[2000],errstr[2000];
	QString error;
	MCIERROR err;
	soundcommanderror=_qstr("");
	err=mciSendString(soundcommand,rt,999,NULL);
	if (err!=0)
	{
		mciGetErrorString(err,errstr,1999);
		error=errstr;
		error+=_qstr(" (");
		error+=soundcommand;
		error+=_qstr(")");
		soundcommanderror=error;
	}
	soundcommandexecuted=true;
	return 0;
}
Пример #27
0
int MusicBox::addMusic(CString name)
{
	m_nID++;
	if(m_nID==MAX_MUSIC)
	{
		MessageBox(NULL,"音乐播放数量超过游戏引擎承载能力","提示",0);
		return -1;
	}

	mciOpen.lpstrElementName=name;
	MCIERROR mciErr;
	mciErr=mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
	if(mciErr)
	{
		char str[128];
		mciGetErrorString(mciErr,str,128);
		MessageBox(NULL,str,"提示",0);
		return -1;
	}
	m_ID[m_nID]=mciOpen.wDeviceID;
	return m_nID;
}
Пример #28
0
bool DART::Play ()
{
  Stopped = WaitStreamEnd = false;
  BytesPlayed = 0;
  int buffcount;
  for (buffcount = 0; buffcount < BufferCount; buffcount++)
    if (!FillBuffer (&MixBuffers [buffcount]))
      break;

  if (buffcount == 0)
    Stopped = WaitStreamEnd = true;
  else
  {
    APIRET rc = MixSetupParms.pmixWrite (MixSetupParms.ulMixHandle,
      &MixBuffers [0], buffcount);
    if (rc)
    {
      mciGetErrorString (rc, (PSZ) ErrorCode, sizeof (ErrorCode));
      return FALSE;
    }
  }
  return TRUE;
}
Пример #29
0
int main() {
    for (;;) {
        char* line = readline("mci: ");
        if (!line) {
            break;
        }

        const int resultSize = 4096;
        char result[resultSize + 1] = {0};
        MCIERROR error = mciSendString(line, result, resultSize, NULL);
        if (error) {
            char str[resultSize + 1] = {0};
            if (!mciGetErrorString(error, str, resultSize)) {
                strcpy(str, "Unknown Error");
            }
            printf("Error: code %d -- %s\n", error, str);
        } else if (result[0]) {
            printf("Result: %s\n", result);
        }

        free(line);
    }
}
Пример #30
0
void CMidi::MciPlay()
{
  DWORD dwReturn;
  MCI_PLAY_PARMS     mciPlayParms;
  DWORD dwFlags = MCI_FROM | MCI_NOTIFY;

  // Error message mechanism
  char mciErrorString[MCI_ERROR_LENGTH];
  UINT mciErrorLen;
  BOOL KnownError = FALSE;

  if (!m_uMCIDeviceID || m_bMute) return;

  memset(&mciPlayParms, 0, sizeof(MCI_PLAY_PARMS));

  mciPlayParms.dwCallback=MAKELONG(m_hwndToNotify,0);

  if (dwReturn = mciSendCommand(m_uMCIDeviceID, MCI_PLAY, dwFlags,
                               (DWORD)(LPVOID) &mciPlayParms))
  {
      mciErrorLen = MCI_ERROR_LENGTH;
      KnownError = mciGetErrorString(dwReturn, mciErrorString, mciErrorLen);
      TRACE("Couldn't Play Midi seq. in PlaySequence\n");
      if (KnownError)
       TRACE("MCI ERROR : %s\n", mciErrorString);
      else
       TRACE("MCI ERROR : Unknown Error (%x)!!!!! \n",dwReturn);

      // Failed. Close Device and return error.
      mciSendCommand(m_uMCIDeviceID, MCI_CLOSE, 0, NULL);
      m_uMCIDeviceID = 0;
      m_bMidiInitialized = FALSE;
      return;
  }

  m_bMidiIsPlaying = TRUE;
}