mciSendString的问题 mciSendString播放本地MP3我知道怎样做,但是要播放网络上的MP3又该怎样做呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 查msdn,记得里面有个详细的例子~网络上的怕是要先载到当地再播放吧~ MCI_OPEN_PARMS mciOpen;MCIERROR mciError;UINT DeviceID;void CMainFrame::PlayMusic(){ //use mciSendCommand m_bMusic = TRUE; mciOpen.lpstrDeviceType = _T("mpegvideo"); mciOpen.lpstrElementName = _T("c:\\a.mp3"); mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen); if(mciError) { // AfxMessageBox(_T("音频有问题,可能无法播放背景音乐!")); return; } DeviceID = mciOpen.wDeviceID ; MCI_PLAY_PARMS mciPlay; // mciError = mciSendCommand(DeviceID,MCI_PLAY,MCI_WAIT | MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay); mciError = mciSendCommand(DeviceID,MCI_PLAY, MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay); if(mciError) { // AfxMessageBox(_T("音频有问题,可能无法播放背景音乐!")); return; }}代码,你把c盘下面放一个a.mp3,然后调用这个函数~ mediaplay的播放都有个缓存,不知道这个过程是不是就是在下载到本地呢,但是没下完能不能播放呢 不用mciSendCommand,直接用一些控件呢,MediaPlayer,看有没有设置url什么的函数~ 或者试试,把url直接当地址赋给它,看能不能播~ 就是不想用MediaPlayer,想做自己的网络播放器 void CPlayBoxDlg::OnButton1() { // TODO: Add your control notification handler code here CFileDialog dlg(TRUE); dlg.DoModal(); m_pathname = dlg.GetPathName(); CString ppss(m_pathname.GetBuffer(m_pathname.GetLength())); char *pr=ppss.GetBuffer(ppss.GetLength()); int num = m_pathname.GetLength(); while (num--) { pr++; } while (1) { pr--; if (*pr=='.') { *pr = '\0'; } if (*(pr-1)=='\\') { break; } } CString Song; Song.Format("歌曲:%s",pr); GetDlgItem(IDC_SONG)->SetWindowText(Song); UpdateData(FALSE);}void CPlayBoxDlg::OnPlay() { // TODO: Add your control notification handler code here// char buf[65335]; char buff[65335];// CString str;// str.Format("open %s",m_pathname.GetBuffer(m_pathname.GetLength()));// mciGetErrorString(mciSendString(str,buf,65335,NULL),buff,65335);// MessageBox(buff);// mciGetErrorString(mciSendString("play "+m_pathname,buf,65335,NULL),buff,65335);// MessageBox(buff); //use mciSendCommand MCI_OPEN_PARMS mciOpen; MCIERROR mciError; UINT DeviceID; //m_bMusic = TRUE; mciOpen.lpstrDeviceType = _T("mpegvideo"); mciOpen.lpstrElementName = m_pathname.GetBuffer(m_pathname.GetLength()); mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen); mciGetErrorString(mciError,buff,1000); MessageBox(buff); DeviceID = mciOpen.wDeviceID ; MCI_PLAY_PARMS mciPlay; // mciError = mciSendCommand(DeviceID,MCI_PLAY,MCI_WAIT | MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay); mciError = mciSendCommand(DeviceID,MCI_PLAY, 0,(DWORD)&mciPlay); mciGetErrorString(mciError,buff,1000); MessageBox(buff); } 显示AVI文件某一帧的BMP图片,内存使用增加 关于FXP的问题,知道的来看下!!! socket沾包! 有什么好办法解决? 姚明可以刮胡子了,散分^_^ 请问如何在VC中制作Release版本的程序? 如何把普通的HTML文件生成/编码成.mht格式的文件? 2000分大送,挑战高手 用VC开发photoshop插件(急 :'() 如何得到树的指针,高手帮帮我 请教各位高手,谢谢 请教在xp系统上蓝牙连接 编译出错,求解..
MCIERROR mciError;
UINT DeviceID;
void CMainFrame::PlayMusic()
{
//use mciSendCommand
m_bMusic = TRUE;
mciOpen.lpstrDeviceType = _T("mpegvideo");
mciOpen.lpstrElementName = _T("c:\\a.mp3"); mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
if(mciError)
{
// AfxMessageBox(_T("音频有问题,可能无法播放背景音乐!"));
return;
} DeviceID = mciOpen.wDeviceID ;
MCI_PLAY_PARMS mciPlay; // mciError = mciSendCommand(DeviceID,MCI_PLAY,MCI_WAIT | MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay);
mciError = mciSendCommand(DeviceID,MCI_PLAY, MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay); if(mciError)
{
// AfxMessageBox(_T("音频有问题,可能无法播放背景音乐!"));
return;
}}
代码,你把c盘下面放一个a.mp3,然后调用这个函数~
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE);
dlg.DoModal();
m_pathname = dlg.GetPathName();
CString ppss(m_pathname.GetBuffer(m_pathname.GetLength()));
char *pr=ppss.GetBuffer(ppss.GetLength());
int num = m_pathname.GetLength();
while (num--)
{
pr++;
}
while (1)
{
pr--;
if (*pr=='.')
{
*pr = '\0';
}
if (*(pr-1)=='\\')
{
break;
}
}
CString Song;
Song.Format("歌曲:%s",pr);
GetDlgItem(IDC_SONG)->SetWindowText(Song);
UpdateData(FALSE);
}void CPlayBoxDlg::OnPlay()
{
// TODO: Add your control notification handler code here
// char buf[65335];
char buff[65335];
// CString str;
// str.Format("open %s",m_pathname.GetBuffer(m_pathname.GetLength()));
// mciGetErrorString(mciSendString(str,buf,65335,NULL),buff,65335);
// MessageBox(buff);
// mciGetErrorString(mciSendString("play "+m_pathname,buf,65335,NULL),buff,65335);
// MessageBox(buff);
//use mciSendCommand
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
UINT DeviceID;
//m_bMusic = TRUE;
mciOpen.lpstrDeviceType = _T("mpegvideo");
mciOpen.lpstrElementName = m_pathname.GetBuffer(m_pathname.GetLength());
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
mciGetErrorString(mciError,buff,1000);
MessageBox(buff);
DeviceID = mciOpen.wDeviceID ;
MCI_PLAY_PARMS mciPlay;
// mciError = mciSendCommand(DeviceID,MCI_PLAY,MCI_WAIT | MCI_DGV_PLAY_REPEAT ,(DWORD)&mciPlay);
mciError = mciSendCommand(DeviceID,MCI_PLAY, 0,(DWORD)&mciPlay);
mciGetErrorString(mciError,buff,1000);
MessageBox(buff);
}