www.pudn.com > MCI.rar > Mp3Player.cpp


// Mp3Player.cpp: implementation of the CMp3Player class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "AVI Player.h" 
#include "Mp3Player.h" 
#include "vfw.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CMp3Player::CMp3Player() 
{ 
	m_hVideo = NULL; 
} 
 
CMp3Player::~CMp3Player() 
{ 
	if(m_hVideo !=NULL) 
	{ 
		MCIWndDestroy(m_hVideo); 
	} 
} 
 
BOOL CMp3Player::Play(CString &strPath) 
{ 
	m_hVideo = NULL; 
	if(m_hVideo == NULL) 
	{ 
		m_hVideo = MCIWndCreate(AfxGetMainWnd()->GetSafeHwnd(), 
		  AfxGetInstanceHandle(), 
		   WS_CHILD |MCIWNDF_NOMENU,strPath); 
		 
	} 
	else 
	{ 
		MCIWndHome(m_hVideo); 
	} 
	MCIWndPlay(m_hVideo); 
	m_bPause = FALSE; 
	return TRUE; 
} 
 
BOOL CMp3Player::Pause() 
{ 
	if(m_bPause) 
	{ 
		//m_Pause.SetWindowText("Pause"); 
		MCIWndResume(m_hVideo); 
		m_bPause = FALSE; 
	} 
	else 
	{ 
		//m_Pause.SetWindowText("UnPause"); 
		MCIWndPause(m_hVideo); 
		m_bPause = TRUE; 
	} 
 
	return m_bPause; 
} 
 
BOOL CMp3Player::Stop() 
{ 
	MCIWndStop(m_hVideo); 
	if(m_hVideo !=NULL) 
	{ 
		MCIWndDestroy(m_hVideo); 
	 
	} 
 
	return TRUE; 
}