5,696,038 members and growing! (10,588 online)
Email Password   helpLost your password?
Multimedia » Audio and Video » Audio     Intermediate

A very simple MP3 Player

By BLaZe

A simple MP3/AVI player using the VFW32 library
VC6, C++Windows, NT4, Win2K, MFC, VS6, Visual Studio, Dev

Posted: 13 Jun 2001
Updated: 13 Jun 2001
Views: 287,022
Bookmarked: 92 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
59 votes for this Article.
Popularity: 7.67 Rating: 4.33 out of 5
2 votes, 4.9%
1
0 votes, 0.0%
2
2 votes, 4.9%
3
9 votes, 22.0%
4
28 votes, 68.3%
5

Introduction

I made a little sample program that enables you to play MP3 files without needing the AUDIOX library. I used the Windows Library VFW32.Lib

Just put the VFW32.lib in the Linker's space (Alt +F7) and add

#include "vfw.h"

to your principal file.

Once you've done this, you just need to use the MCI commands:

Steps :

  • Create a private variable HWND m_Video and BOOL Pause;

  • in the OnInitDialog set m_Video = NULL;

  • Put almost the Play button and add this source code on

Here are the functions I use in my dialog class to play/pause/resume and stop video playback.

m_Play is the 'Play' button control, m_Pause is the pause/resume button, Pause is a boolean value, and m_Video is a HWND.

void CAVIPlayerDlg::OnPlay() 
{
	m_Video = NULL;
	
	if(m_Video == NULL)
	{
		m_Video = MCIWndCreate(this->GetSafeHwnd(),
			AfxGetInstanceHandle(),
			WS_CHILD | WS_VISIBLE|MCIWNDF_NOMENU,m_Path);
		
	}
	else
	{
		MCIWndHome(m_Video);
	}
	
	MCIWndPlay(m_Video);
	Pause = FALSE;
	m_Play.EnableWindow(FALSE);
	
}

void CAVIPlayerDlg::OnPause() 
{
	if(Pause)
	{
		m_Pause.SetWindowText("Pause");
		MCIWndResume(m_Video);
		Pause = FALSE;
	}
	else
	{
		m_Pause.SetWindowText("Resume");
		MCIWndPause(m_Video);
		Pause = TRUE;
	}
}

void CAVIPlayerDlg::OnCancel() 
{
	if(m_Video !=NULL)
	{
		MCIWndDestroy(m_Video);
		OnOK();
	}
	CDialog::OnCancel();
}

void CAVIPlayerDlg::OnStop() 
{
	// TODO: Add your control notification handler code here

	MCIWndStop(m_Video);
	if(m_Video !=NULL)
	{
		MCIWndDestroy(m_Video);
	}
	m_Play.EnableWindow(TRUE);
}

I Suggest you to refer to the MCI Reference on the net at http://msdn.microsoft.com/library/psdk/multimed/mciwnd_3stv.htm

I also include an AVI player in this program. :-)

That's all for this !

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

BLaZe


My name is BLaZe and I have 15 years old
Location: United States United States

Other popular Audio and Video articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 72 (Total in Forum: 72) (Refresh)FirstPrevNext
Generaldownloading codemembermohammadarshad2720:11 9 Apr '08  
GeneralPlaying the file through buffermembernitin_pro0:21 31 Oct '07  
QuestionPlaying the MP3 file through buffermembernitin_pro2:39 22 Oct '07  
Generalit is just cool [modified]memberjacej6:40 27 Jul '07  
GeneralThis cool!memberearth_cg7:54 8 Mar '07  
GeneralCan not play AVImemberpsamir21:59 9 Oct '06  
GeneralMCI Errormembernaraimha3:58 4 Oct '06  
GeneralCan this program play WAV?memberAki Wang0:55 3 Aug '06  
GeneralRe: Can this program play WAV?memberAki Wang1:29 3 Aug '06  
GeneralALmembervnsr5:00 8 Jun '06  
QuestionProblemsmembernepobunceno14:42 18 Apr '06  
Generalhow to play the mp3 song in the required output device, is there any function to specify the output device id for mp3memberFarooq kotwal2:05 22 Jun '05  
GeneralResolving Building ErrorsmemberRobertOls19747:15 6 May '05  
GeneralRe: Resolving Building ErrorssussAnonymous5:36 30 Jun '05  
GeneralImplementing the progressbarmemberretgrr34t3:57 15 Apr '05  
GeneralAdding a volume buttonmemberSaraMalkaW16:05 9 Jan '05  
GeneralRe: Adding a volume buttonsussAnonymous5:19 30 Jun '05  
GeneralHide Slider Controlmemberjun___21:56 2 Dec '04  
GeneralRe: Hide Slider Controlmembersilufear16:51 15 Jun '07  
Generalm_Pathmemberloudawgg7:06 28 Apr '04  
Generalhow can i modify this to play in linuxmembermaheshkk20:54 6 Apr '04  
GeneralMMSYSTEM 296 ERROR while play mp3 filememberchuit11:28 5 Jan '04  
GeneralCan this Mp3player run on a DSP chipset ?memberJiangcr8116:49 17 Nov '03  
GeneralGood but want more ;-)memberBoscoW6:48 14 Jun '03  
GeneralRe: Good but want more ;-)memberelectriac6:22 17 Nov '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 13 Jun 2001
Editor: Chris Maunder
Copyright 2001 by BLaZe
Everything else Copyright © CodeProject, 1999-2008
Web11 | Advertise on the Code Project