Click here to Skip to main content
Licence 
First Posted 13 Jun 2001
Views 415,851
Bookmarked 120 times

A very simple MP3 Player

By | 13 Jun 2001 | Article
A simple MP3/AVI player using the VFW32 library

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



United States United States

Member

My name is BLaZe and I have 15 years old

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 Pinmembermarkfilan5:38 8 Jan '11  
GeneralMy vote of 2 PinmemberKarstenK22:29 26 Aug '10  
GeneralSplitting a video file PinmemberVedavyasaachar0:19 19 Aug '09  
Generaldownloading code Pinmembermohammadarshad2719:11 9 Apr '08  
GeneralPlaying the file through buffer Pinmembernitin_pro23:21 30 Oct '07  
QuestionPlaying the MP3 file through buffer Pinmembernitin_pro1:39 22 Oct '07  
Generalit is just cool [modified] Pinmemberjacej5:40 27 Jul '07  
GeneralThis cool! Pinmemberearth_cg6:54 8 Mar '07  
QuestionCan not play AVI Pinmemberpsamir20:59 9 Oct '06  
GeneralMCI Error Pinmembernaraimha2:58 4 Oct '06  
Hi,
When i am using this application in windows 2000 i am getting small error message --MCI Error, and same application when i am using windowsXP i am not getting any error.Confused | :confused:
QuestionCan this program play WAV? PinmemberAki Wang23:55 2 Aug '06  
AnswerRe: Can this program play WAV? PinmemberAki Wang0:29 3 Aug '06  
GeneralAL Pinmembervnsr4:00 8 Jun '06  
QuestionProblems Pinmembernepobunceno13:42 18 Apr '06  
Questionhow to play the mp3 song in the required output device, is there any function to specify the output device id for mp3 PinmemberFarooq kotwal1:05 22 Jun '05  
GeneralResolving Building Errors PinmemberRobertOls19746:15 6 May '05  
GeneralRe: Resolving Building Errors PinsussAnonymous4:36 30 Jun '05  
GeneralImplementing the progressbar Pinmemberretgrr34t2:57 15 Apr '05  
GeneralAdding a volume button PinmemberSaraMalkaW15:05 9 Jan '05  
GeneralRe: Adding a volume button PinsussAnonymous4:19 30 Jun '05  
GeneralHide Slider Control Pinmemberjun___20:56 2 Dec '04  
GeneralRe: Hide Slider Control Pinmembersilufear15:51 15 Jun '07  
Generalm_Path Pinmemberloudawgg6:06 28 Apr '04  
Questionhow can i modify this to play in linux Pinmembermaheshkk19:54 6 Apr '04  
GeneralMMSYSTEM 296 ERROR while play mp3 file Pinmemberchuit10:28 5 Jan '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120529.1 | Last Updated 14 Jun 2001
Article Copyright 2001 by BLaZe
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid