VC++ API 播放MP3
#ifndef _M_PLAYER_H_
#define _M_PLAYER_H_
#include "StdAfx.h"
#include <vfw.h>
class CMPlayer
{
public:
CMPlayer(HWND hParent):m_hWnd(0)
{
m_hWnd=MCIWndCreate(hParent, NULL, MCIWNDF_NOMENU ¦MCIWNDF_NOERRORDLG ¦MCIWNDF_NOTIFYMODE, NULL);
}
~CMPlayer(){
if(m_hWnd) MCIWndClose(m_hWnd);
}
int Open(const char* filename)
{
int rt=0;
if(m_hWnd) rt=(MCIWndOpen(m_hWnd, filename, NULL)==0);
return rt;
}
int Play()
{
int rt=0;
if(m_hWnd) rt=(MCIWndPlay(m_hWnd)==0);
return rt;
}
int Stop()
{
int rt=0;
if(m_hWnd) MCIWndStop(m_hWnd);
return rt;
}
private:
HWND m_hWnd;
};
#endif//_M_PLAYER_H_
#define _M_PLAYER_H_
#include "StdAfx.h"
#include <vfw.h>
class CMPlayer
{
public:
CMPlayer(HWND hParent):m_hWnd(0)
{
m_hWnd=MCIWndCreate(hParent, NULL, MCIWNDF_NOMENU ¦MCIWNDF_NOERRORDLG ¦MCIWNDF_NOTIFYMODE, NULL);
}
~CMPlayer(){
if(m_hWnd) MCIWndClose(m_hWnd);
}
int Open(const char* filename)
{
int rt=0;
if(m_hWnd) rt=(MCIWndOpen(m_hWnd, filename, NULL)==0);
return rt;
}
int Play()
{
int rt=0;
if(m_hWnd) rt=(MCIWndPlay(m_hWnd)==0);
return rt;
}
int Stop()
{
int rt=0;
if(m_hWnd) MCIWndStop(m_hWnd);
return rt;
}
private:
HWND m_hWnd;
};
#endif//_M_PLAYER_H_
浙公网安备 33010602011771号