1. Generally, video players can be developed based on FFMPEG, and their relationships with most players can be the relationship between universal engines and automobiles. The VLC player codec library is FFMPEG. Using the existing SDK of VLC, you can quickly and easily develop video players that meet your needs. This article demonstrates how to develop a simple video player.
2. Environment:
OS: Windows 7 32-bit flagship Edition
IDE: vs2005
Lib: vlc0.99 SDK
3. Related information:
Vlc0.99 source code: http://download.videolan.org/pub/videolan/vlc/0.9.9/
Vlc0.99 compiled installation package:
Sourceforge.net/projects/vlc/files/0.9.9/win32/vlc-0.9.9-win32.zip
Note:
Because VLC is a cross-platform library, in windows, If You Want To compile the library from the source code, you need mingw + mysys or cygwin environment. The setup environment and compilation steps are cumbersome, so it is highly efficient to directly use the ready-to-use binary library.
4. Create a project
1) create a dialog box-based project under vs2005. Add a control. After the control is created, it is similar:
2) required settings:
Decompress the vlc-0.9.9-win32.zip file and copy the include and Lib directories under the SDK directory to the project directory. Set the directory .. \ include, linker/set the additional library directory .. \ Lib; copy the Plugins directory decompressed by vlc to the working debug directory.
3) sample code:
class CvlcTestDlg : public CDialog{public:CvlcTestDlg(CWnd* pParent = NULL);~CvlcTestDlg();enum { IDD = IDD_VLCTEST_DIALOG };protected:virtual void DoDataExchange(CDataExchange* pDX);protected:HICON m_hIcon;virtual BOOL OnInitDialog();afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();DECLARE_MESSAGE_MAP()private:CStringstrVPath;HWNDm_hWndVideo;boolm_bNew;libvlc_exception_tm_vlcEx;libvlc_instance_t*m_vlcInst;libvlc_media_player_t*m_vlcMplay;libvlc_media_t*m_vlcMedia;private:afx_msg void OnBnClickedBtnPlay();afx_msg void OnBnClickedBtnStop();afx_msg void OnBnClickedBtnPause();afx_msg void OnBnClickedBtnDir();};
Related Events:
Void cvlctestdlg: onbnclickedbtnplay () {// todo: add the control notification handler code trace ("START player! \ N "); getdlgitemtext (idc_edit1, strvpath); If (m_bnew = true) {m_bnew = false; m_vlcmedia = libvlc_media_new (m_vlcinst, strvpath. getbuffer (0), & m_vlcex); m_vlcmplay = Merge (m_vlcmedia, & m_vlcex); libvlc_media_release (m_vlcmedia); merge (m_vlcmplay, (partial) m_hwndvideo, & m_vlcex );} libvlc_media_player_play (m_vlcmplay, & m_vlcex); tra Ce ("playing video! \ N ");}
Void cvlctestdlg: onbnclickedbtnstop () {// todo: add the control notification handler code libvlc_media_player_stop (m_vlcmplay, & m_vlcex); m_bnew = true ;}
5. Running result:
Note: Chinese paths are not supported.
6. Download the test code:
Http://download.csdn.net/detail/byd123/4586653