现在的位置: 首页 > 综合 > 正文

使用MCI播放媒体文件

2013年10月11日 ⁄ 综合 ⁄ 共 689字 ⁄ 字号 评论关闭

#include<stdio.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")

bool MCI_Play(LPCTSTR file)
{
//use mciSendCommand
  MCI_OPEN_PARMS mciOpen = {0};
  mciOpen.lpstrElementName = file;
  MCIERROR mciError = mciSendCommand(0,MCI_OPEN, MCI_OPEN_ELEMENT ,(DWORD)&mciOpen);
  if(mciError)
  {
    char buf[128];
    mciGetErrorString(mciError,buf,128);
    CString mess_str;
    mess_str.Format("send MCI_OPEN command failed:%s/n",buf);
    AfxMessageBox(mess_str);
    return(false);
  }
 
  MCI_PLAY_PARMS mciPlay;
  mciError = mciSendCommand(mciOpen.wDeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
  if(mciError)
  {
    mciSendCommand(mciOpen.wDeviceID, MCI_CLOSE, 0, NULL);
    AfxMessageBox("send MCI_PLAY command failed/n");
    return(false);
  }

  return(true);
}

 

 

抱歉!评论已关闭.