Click here to Skip to main content
Licence 
First Posted 13 Jun 2001
Views 406,879
Downloads 6,885
Bookmarked 116 times

A very simple MP3 Player

By BLaZe | 13 Jun 2001
A simple MP3/AVI player using the VFW32 library
2 votes, 4.0%
1
1 vote, 2.0%
2
2 votes, 4.0%
3
15 votes, 30.0%
4
30 votes, 60.0%
5
4.60/5 - 68 votes
3 removed
μ 4.29, σa 1.71 [?]

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 Pinmembermarkfilan6:38 8 Jan '11  
GeneralMy vote of 2 PinmemberKarstenK23:29 26 Aug '10  
GeneralSplitting a video file PinmemberVedavyasaachar1:19 19 Aug '09  
How can i split a video file and store it.?Please help me .
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  
QuestionCan not play AVI Pinmemberpsamir21:59 9 Oct '06  
GeneralMCI Error Pinmembernaraimha3:58 4 Oct '06  
QuestionCan this program play WAV? PinmemberAki Wang0:55 3 Aug '06  
AnswerRe: Can this program play WAV? PinmemberAki Wang1:29 3 Aug '06  
GeneralAL Pinmembervnsr5:00 8 Jun '06  
QuestionProblems Pinmembernepobunceno14: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 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  
Questionhow 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  

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
Web01 | 2.5.120210.1 | Last Updated 14 Jun 2001
Article Copyright 2001 by BLaZe
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid