Self-made multimedia player under VC6.0

Source: Internet
Author: User

VC6.0 is Microsoft's trump card product, it is a powerful function and won the vast number of programmers love. With VC AppWizard, ClassWizard and a variety of controls can easily build applications. This article describes the use of VC6.0 with an ActiveX control----Activemoviecontrol Object, to build their own multimedia player. This multimedia has the general playback function, can play *.mp3,*.wma,*.mdi,*.wav,*.avi,*.dat and so on file, but also has the repeat function.

Specific steps:

1. Open VC6.0, select MFC AppWizard (EXE) under Projects, and name MediaPlayer, then set up the application based on dialog box (Dialog Based).

2. Open Resource View, select the dialog box, open the main dialog box, remove the "OK" button on the dialog, leave "Cancel" and change the caption to "Exit". Then add nine buttons to the above, ID and caption are respectively

Idc_open,open;

Idc_play,play;

Idc_pause,pause;

Idc_stop,stop;

Idc_close,close;

idc_lower,<<=;

idc_upper,=>>;

Idc_fullscreen,full;

Idc_repeat,repeat;

Add two static text controls, respectively, to Idc_static,volume;idc_static2,status:normal.

3. Then open the Projects->add to Project->components and controls->registered ActiveX Controls dialog box, Select the Activemoviecontrol object, Insert,ok, you will find that your control panel on a more than a Activemoviecontrol object, select it, put it directly on your dialog box on the line. Press Ctrl+w to open ClassWizard to add a variable CActiveMovie3 m_activemovie to it. The layout of each control is shown in figure:

4. Next, you add a message handler function for your program. Open ClassWizard and add a message handler function for each button. In the MediaPlayerDlg.cpp file, add code for each message handler function, the following code:void Cmediaplayerdlg::onclose ()
{
M_activemovie.closewindow ()//Close window
}
void Cmediaplayerdlg::onopen ()
{
Char szfilefilter[]=
"Mp3 File (*.mp3) |*.mp3|"
"Wma File (*.wma) |*.wma|"
"Video File (*.dat) |*.dat|"
"Wave File (*.wav) |*.wav|"
"AVI File (*.avi) |*.avi|"
"Movie File (*.mov) |*.mov|"
"Media File (*.mmm) |*.mmm|"
"Mid File (*.mid;*,rmi) |*.mid;*.rmi|"
"MPEG File (*.mpeg) |*.mpeg|"
"All File (*.*) |*.*| |"; /File type filtering
CFileDialog Dlg (True,null,null,ofn_hidereadonly,szfilefilter);
if (dlg. DoModal () ==idok) {
CString Pathname=dlg. GetPathName ();
Pathname.makeupper ();
M_activemovie.setfilename (PathName);
}
}
void Cmediaplayerdlg::onplay ()
{
M_activemovie.run ()//Play File
SetTimer (0,20,null);/Set Timer
}
void Cmediaplayerdlg::onstop ()
{
M_activemovie.stop ()//stop playing the file
KillTimer (0);//Turn off the timer
}
void Cmediaplayerdlg::onpause ()
{
M_activemovie.pause ();
}
void Cmediaplayerdlg::onupper ()
{
Long Volume=m_activemovie.getvolume ();
M_activemovie.pause ();
M_activemovie.setvolume (volume+100);
M_activemovie.run ();
}
void Cmediaplayerdlg::onlower ()
{
Long Volume=m_activemovie.getvolume ();
M_activemovie.pause ();
M_activemovie.setvolume (Volume-100);
M_activemovie.run ();
}
void Cmediaplayerdlg::onrepeat ()
{
if (!isrepeat) {
Isrepeat=true;
Setdlgitemtext (Idc_static2, "status:repeat");
}
else{
Isrepeat=false;
Setdlgitemtext (Idc_static2, "status:normal");
}
}
void Cmediaplayerdlg::onfulscreeen ()
{
M_activemovie.pause ();
M_activemovie.setfullscreenmode (TRUE);
M_activemovie.setmoviewindowsize (sw_showmaximized);
M_activemovie.run ();
}

(Note: function OnTimer () need to be added through ClassWizard (ctrl+w), not copied directly)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.