Click here to Skip to main content
6,822,613 members and growing! (20,276 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
VC6Win2K, MFC, Dev
Posted:13 Jun 2001
Views:336,969
Bookmarked:111 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
62 votes for this article.
Popularity: 7.77 Rating: 4.33 out of 5
2 votes, 4.5%
1

2
2 votes, 4.5%
3
11 votes, 25.0%
4
29 votes, 65.9%
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


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

Other popular Audio and Video articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 73 (Total in Forum: 73) (Refresh)FirstPrevNext
GeneralSplitting a video file PinmemberVedavyasaachar1:19 19 Aug '09  
Generaldownloading code Pinmembermohammadarshad2720:11 9 Apr '08  
GeneralPlaying the file through buffer Pinmembernitin_pro0:21 31 Oct '07  
QuestionPlaying the MP3 file through buffer Pinmembernitin_pro2:39 22 Oct '07  
Generalit is just cool [modified] Pinmemberjacej6:40 27 Jul '07  
GeneralThis cool! Pinmemberearth_cg7:54 8 Mar '07  
GeneralCan not play AVI Pinmemberpsamir21:59 9 Oct '06  
GeneralMCI Error Pinmembernaraimha3:58 4 Oct '06  
GeneralCan this program play WAV? PinmemberAki Wang0:55 3 Aug '06  
GeneralRe: Can this program play WAV? PinmemberAki Wang1:29 3 Aug '06  
GeneralAL Pinmembervnsr5:00 8 Jun '06  
QuestionProblems Pinmembernepobunceno14: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 mp3 PinmemberFarooq kotwal2:05 22 Jun '05  
GeneralResolving Building Errors PinmemberRobertOls19747:15 6 May '05  
GeneralRe: Resolving Building Errors PinsussAnonymous5:36 30 Jun '05  
GeneralImplementing the progressbar Pinmemberretgrr34t3:57 15 Apr '05  
GeneralAdding a volume button PinmemberSaraMalkaW16:05 9 Jan '05  
GeneralRe: Adding a volume button PinsussAnonymous5:19 30 Jun '05  
GeneralHide Slider Control Pinmemberjun___21:56 2 Dec '04  
GeneralRe: Hide Slider Control Pinmembersilufear16:51 15 Jun '07  
Generalm_Path Pinmemberloudawgg7:06 28 Apr '04  
Generalhow can i modify this to play in linux Pinmembermaheshkk20:54 6 Apr '04  
GeneralMMSYSTEM 296 ERROR while play mp3 file Pinmemberchuit11:28 5 Jan '04  
GeneralCan this Mp3player run on a DSP chipset ? PinmemberJiangcr8116:49 17 Nov '03  
GeneralGood but want more ;-) PinmemberBoscoW6:48 14 Jun '03  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

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