Click here to Skip to main content
12,630,940 members (31,052 online)
Click here to Skip to main content

Stats

207.1K views
11.2K downloads
105 bookmarked
Posted

A Basic Media Player

, 10 Jan 2013 GPL3
Using MCIWnd wrapper class to write a simple media player
// Player.cpp: implementation of the CPlayer class.
//
//////////////////////////////////////////////////////////////////////


#include "stdafx.h"
#include "Player.h"
#include "vfw.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPlayer::CPlayer(HWND hwParent)
{
	hwndParent=hwParent;

	m_sPath="";
	c_Player=NULL;
}

CPlayer::CPlayer()
{
	hwndParent=NULL;

	m_sPath="";
	c_Player=NULL;
}

CPlayer::~CPlayer()
{
	MCIWndDestroy(c_Player);
	c_Player=NULL;
	m_sPath="";
}

void CPlayer::SetPath(CString sPath)
{
	m_sPath.Format("%s",sPath);
}

CString CPlayer::GetPath()
{
	return m_sPath;
}

void CPlayer::Play()
{
	c_Player=MCIWndCreate(hwndParent,AfxGetInstanceHandle(),
		WS_CHILD | WS_VISIBLE| MCIWNDF_NOMENU,
		m_sPath);

	MCIWndPlay(c_Player);
}

void CPlayer::Stop()
{
	MCIWndStop(c_Player);
	MCIWndDestroy(c_Player);
}

void CPlayer::Pause()
{
	MCIWndPause(c_Player);
}

void CPlayer::Resume()
{
	MCIWndResume(c_Player);
}

CString CPlayer::GetMode()
{
	char* lp=new char[3];
	CString x;
	
	MCIWndGetMode(c_Player,lp,sizeof(lp));

	x=(char*) lp;
	delete [] lp;
	return x;
}

void CPlayer::Loop()
{
	CString x;
	c_Player=MCIWndCreate(hwndParent,AfxGetInstanceHandle(),
		WS_CHILD | WS_VISIBLE|MCIWNDF_NOMENU,
		m_sPath);

	MCIWndPlay(c_Player);
	while()
	{
		x=GetMode();
		if (x!="pla")
		{
			MCIWndDestroy(c_Player);
		}
	}
}

void CPlayer::Break()
{

}

void CPlayer::SetParent(HWND hParent)
{
	hwndParent=hParent;
}

HWND CPlayer::GetParent()
{
	return hwndParent;
}

void CPlayer::SetPath(CString sPath)
{
	m_sPath.Format("%s",sPath);
}

CString CPlayer::GetPath()
{
	return m_sPath;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

M. Bonvari
Other
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 10 Jan 2013
Article Copyright 2003 by M. Bonvari
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid