This topic describes how to insertThe RealPlay control implements media file playback. The code runs as follows:
The following describes the specific implementation steps:
1. Create a dialog box-based program
2. Add ActiveX control of RealPlayer G2 control in the dialog box
(Project-> Add project-> compontent and controls-> registed ActiveX controls ).
3. In the dialog box, add the buttons and static text shown in the source program to control the open playback and other controls, and display the song information. Its ID number is shown in the source program.
4. Map Button messages with MFC
Void CSunapplerealplayerDlg: OnOpen ()
{
Char szFileFilter [] =
"RM File (*. rm) | *. rm |"
"Mp3 File (*. mp3) | *. mp3 |"
"MPEG File (*. mpeg) | *. mpeg |"
"Media File (*. asf) | *. asf |"
"Video File (*. dat) | *. dat |"
"MPGA File (*. mpga) | *. mpga |"
"Wave File (*. wav) | *. wav |"
"AVI File (*. avi) | *. avi |"
"Movie File (*. mov) | *. mov |"
"Mid File (*. mid; *, rmi) | *. mid; *. rmi |"
"Wma File (*. wma) | *. wma |"
"All File (*. *) | *. * | ";
CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY, szFileFilter );
If (dlg. DoModal () = IDOK ){
CString PathName = dlg. GetPathName ();
PathName. MakeUpper ();
M_player-> SetSource (PathName );
M_player-> DoPlay ();
SetDlgItemText (ID