Click here to Skip to main content
Click here to Skip to main content

A very simple MP3 Player

By , 13 Jun 2001
Rate this:
Please Sign up or sign in to vote.
<!-- Download Links --> <!-- Main HTML starts here -->

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. Smile | :)

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
My name is BLaZe and I have 15 years old

Comments and Discussions

 
Generalexecute me PinmemberNeverGrief27-Nov-02 4:57 
GeneralGood and Simple PinsussAnonymous31-Aug-02 6:45 
GeneralRe: Good and Simple Pinmemberfanncy11-Sep-06 22:43 
QuestionHow to loop continously?? PinmemberRamees28-Aug-02 2:57 
AnswerRe: How to loop continously?? PinsussAnonymous20-Oct-02 17:20 
GeneralRe: How to loop continously?? Pinsussoqnet19-Apr-05 15:01 
GeneralGreat Program Pinsusssk-i-za7-Aug-02 7:38 
GeneralHolds on to previous file Pinmembercodermallu1-Aug-02 3:58 
Good program! Some problems though Smile | :) I could not play
a new file without exiting the program since it seems to
hold on to the last file. Browsing a new file does not
seem to change the loaded file.
 
Otherwise cool utility. Good Work!!
 
Regards
 
Anand
GeneralRe: Holds on to previous file Pinsussoqnet19-Apr-05 14:29 
GeneralCodecs required PinmemberArmen Hakobyan22-Jul-02 16:40 
Generalplay avi files in .net environment Pinmemberlinus lee20-May-02 22:16 
GeneralChanging soundcards. PinmemberLargie2-Mar-02 0:51 
GeneralRe: Changing soundcards. PinmemberBLaZiNiX2-Mar-02 6:04 
GeneralRe: Changing soundcards. PinmemberLargie3-Mar-02 21:04 
GeneralRe: Changing soundcards. PinmemberGuitool30-Jul-02 0:22 
GeneralGood for beginner PinmemberLIK27-Feb-02 6:17 
GeneralCant compile it :( Pinmemberantivoid4-Jan-03 23:37 
GeneralI like it:) PinmemberMazdak20-Feb-02 3:52 
Generalto handle mci_stop message PinmemberJaggu13-Dec-01 11:11 
GeneralMp3 player PinmemberJarek Gibek7-Sep-01 2:18 
GeneralRe: Mp3 player PinmemberAnonymous10-Mar-02 14:38 
GeneralBook PinmemberBrian Hart15-Jun-01 5:07 
GeneralRe: Book PinmemberAnonymous19-Jun-01 6:04 
GeneralNot an MP3 player PinmemberAnonymous14-Jun-01 6:20 
GeneralRe: Not an MP3 player PinmemberLOXmith21-Jun-01 21:25 

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.

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