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
.
Collapse
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 !