www.pudn.com > media_player_sample.zip > CMediaBookmarker.h
// CMediaBookmarker.h : Declaration of the CMediaBookmarker class // // Copyright (c) Microsoft Corporation. All rights reserved. THIS CODE IS MADE AVAILABLE AS // IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE // OF THIS CODE REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OUR // WITHOUT MODICATION, IS HEREBY PERMITTED. // #include "resource.h" #include#include "PlayerOCX.h" #include "events_dispid.h" #define IDC_PLAYER 1000 #define IDB_PLAY 1001 #define IDB_PAUSE 1002 #define IDB_STOP 1003 #define IDB_FASTREVERSE 1004 #define IDB_FASTFORWARD 1005 #define IDB_MARK 1006 #define IDB_CLEARMARKS 1007 #define IDB_PLAYMARK 1008 #define IDL_BOOKMARKS 1009 #define MAX_MARKLENGTH 256 #define MAX_BOOKMARKS 100 #define MAX_PLAYER_HEIGHT 198 #define STATUS_BAR_HEIGHT 14 #define IDB_ABOUT 1010 #define IDB_TXT_ADDRESS 1011 #define IDB_GO 1012 ///////////////////////////////////////////////////////////////////////////// // CMediaBookmarker class CMediaBookmarker : public CWindowImpl >, public CComObjectRootEx , public _IWMPEvents { CAxWindow m_wndView; // The window that hosts the Windows Media Player control CComPtr m_spWMPPlayer; // A pointer to the Windows Media Player control interface CComPtr m_spConnectionPoint; // The connection point through which events are handled DWORD m_dwAdviseCookie; // A cookie used by the connection point to cease event notifications DWORD m_nFilterIndex; // An index to the current file name filter int m_cMarkCount; // The bookmark count TCHAR* m_szCurrentFile; // The name of the current file (without path information) BSTR m_bstrFileName[MAX_BOOKMARKS]; // An array that stores bookmarked file names double m_dMarkPosition[MAX_BOOKMARKS]; // An array that stores bookmarked file positions public: BEGIN_COM_MAP(CMediaBookmarker) COM_INTERFACE_ENTRY_IID(__uuidof(_IWMPEvents), _IWMPEvents) COM_INTERFACE_ENTRY(IDispatch) END_COM_MAP() DECLARE_WND_CLASS(NULL) BEGIN_MSG_MAP(CMediaBookmarker) MESSAGE_HANDLER( WM_CREATE, OnCreate) MESSAGE_HANDLER( WM_DESTROY, OnDestroy) COMMAND_ID_HANDLER( IDOK, OnOK) COMMAND_ID_HANDLER( ID_FILE_OPEN1, OnFileOpen) COMMAND_ID_HANDLER( ID_OPEN_URL, OnOpenURL) COMMAND_ID_HANDLER( ID_FILE_EXIT1, OnFileExit) COMMAND_ID_HANDLER( IDB_MARK, OnMark) COMMAND_ID_HANDLER( IDB_CLEARMARKS, OnClearMarks) COMMAND_ID_HANDLER( IDB_PLAYMARK, OnPlayMark) COMMAND_ID_HANDLER( IDB_PLAY, OnPlay) COMMAND_ID_HANDLER( IDB_PAUSE, OnPause) COMMAND_ID_HANDLER( IDB_STOP, OnStop) COMMAND_ID_HANDLER( IDB_FASTFORWARD, OnFastForward) COMMAND_ID_HANDLER( IDB_FASTREVERSE, OnFastReverse) COMMAND_ID_HANDLER( IDB_ABOUT, OnAbout) COMMAND_ID_HANDLER( ID_MNU_PROPERTIES, OnProperties) COMMAND_ID_HANDLER( IDB_GO, OnGoURL) END_MSG_MAP() // CMediaBookmarker methods: CMediaBookmarker(); ~CMediaBookmarker(); BOOL Bookmark(TCHAR *szBookmarkText); BOOL PlayMedia(TCHAR *szFile, double dPosition); // Window methods: LRESULT OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // User-interface methods: LRESULT OnOK( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnFileOpen( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnFileExit( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnMark( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnClearMarks( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnPlayMark( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnPlay( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnPause( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnStop( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnFastForward( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnFastReverse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnAbout( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnOpenURL( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnProperties( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnGoURL( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // IDispatch methods: STDMETHOD(GetIDsOfNames)( REFIID riid, OLECHAR FAR *FAR *rgszNames, unsigned int cNames, LCID lcid, DISPID FAR *rgDispId ) { return( E_NOTIMPL ); }; STDMETHOD(GetTypeInfo)( unsigned int iTInfo, LCID lcid, ITypeInfo FAR *FAR *ppTInfo ) { return( E_NOTIMPL ); }; STDMETHOD(GetTypeInfoCount)(unsigned int FAR *pctinfo ) { return( E_NOTIMPL ); }; STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pDispParams, VARIANT FAR *pVarResult, EXCEPINFO FAR *pExcepInfo, unsigned int FAR *puArgErr ); // Windows Media Player Control event methods: void OnPlayStateChange(long NewState); HWND h_editURL; HWND h_btnAbout; }; typedef CComObject CComMediaBookmarker;