mciSendString播放本地MP3我知道怎样做,但是要播放网络上的MP3又该怎样做呢?

解决方案 »

  1.   

    查msdn,记得里面有个详细的例子~网络上的怕是要先载到当地再播放吧~
      

  2.   

    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,然后调用这个函数~
      

  3.   

    mediaplay的播放都有个缓存,不知道这个过程是不是就是在下载到本地呢,但是没下完能不能播放呢
      

  4.   

    不用mciSendCommand,直接用一些控件呢,MediaPlayer,看有没有设置url什么的函数~
      

  5.   

    或者试试,把url直接当地址赋给它,看能不能播~
      

  6.   

    就是不想用MediaPlayer,想做自己的网络播放器
      

  7.   

    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);
    }