小組已經(jīng)決定開發(fā)對于內(nèi)部網(wǎng)適用的網(wǎng)絡(luò)電視,這兩天一直就在查找使用Windows Media Player ActiveX控件開發(fā)播放功能的方法。在網(wǎng)上找了好些書,也到MSDN上找過了,并安裝了Windows Media Player SDK工具包。無奈都找不到有講解在VC++2005下的文章,VC++2003也好啊。是否這兩個平臺都還沒出說明文檔,只是找到了VC6.0下的幫助。SDK Sample里還是有源代碼和SDK幫助文檔里也談了一些。可惜全是E文來的(痛苦)。
一開始對著SDK幫助文檔,在2005下操作。雖然我知道文檔寫的是6.0下的情況,但是我想應(yīng)該不會相差太大的。依葫蘆畫瓢的東西就不說了。將WMP控件添加到窗體,給它添加成控件變量。然后想在菜單中添加一個項目,點擊的時候就可以播放特點的URL。就在這一步,問題來了。調(diào)用控件變量時,發(fā)現(xiàn)并沒有多少成員函數(shù)可以給我調(diào)用,文檔里顯示有的函數(shù),2005的智能感應(yīng)也沒法顯示出來。到底是哪里的問題。
無奈,使用VC6.0照著多做一次,終于發(fā)現(xiàn)區(qū)別了。6.0里添加變量之后,VC自動生成了很多類。看一下這些頭文件就知道了。
#include?
"
wmpplayer4.h
"
//
?Dispatch?interfaces?referenced?by?this?interface
#include?
"
wmpcontrols.h
"
#include?
"
WMPSettings.h
"
#include?
"
wmpmedia.h
"
#include?
"
wmpmediacollection.h
"
#include?
"
wmpplaylistcollection.h
"
#include?
"
wmpnetwork.h
"
#include?
"
wmpplaylist.h
"
#include?
"
wmpcdromcollection.h
"
#include?
"
wmpclosedcaption.h
"
#include?
"
WMPError.h
"
#include?
"
wmpdvd.h
"
#include?
"
WMPPlayerApplication.h
"
每個頭文件都對應(yīng)了一個類。而在2005下,僅是簡簡單單了生成了一個類似于CWMPPlayer4的類。而且類中的內(nèi)容也縮水了。6.0下生成的CWMPPlayer4已經(jīng)可以提供很多功能了如:
public
:
????
void
?close();
????CString?GetUrl();
????
void
?SetUrl(LPCTSTR?lpszNewValue);
????
long
?GetOpenState();
????
long
?GetPlayState();
????CWMPControls?GetControls();
????CWMPSettings?GetSettings();
????CWMPMedia?GetCurrentMedia();
????
void
?SetCurrentMedia(LPDISPATCH?newValue);
????CWMPMediaCollection?GetMediaCollection();
????CWMPPlaylistCollection?GetPlaylistCollection();
????CString?GetVersionInfo();
????
void
?launchURL(LPCTSTR?bstrURL);
????CWMPNetwork?GetNetwork();
????CWMPPlaylist?GetCurrentPlaylist();
????
void
?SetCurrentPlaylist(LPDISPATCH?newValue);
????CWMPCdromCollection?GetCdromCollection();
????CWMPClosedCaption?GetClosedCaption();
????BOOL?GetIsOnline();
????CWMPError?GetError();
????CString?GetStatus();
????CWMPDVD?GetDvd();
????CWMPPlaylist?newPlaylist(LPCTSTR?bstrName,?LPCTSTR?bstrURL);
????CWMPMedia?newMedia(LPCTSTR?bstrURL);
????BOOL?GetEnabled();
????
void
?SetEnabled(BOOL?bNewValue);
????BOOL?GetFullScreen();
????
void
?SetFullScreen(BOOL?bNewValue);
????BOOL?GetEnableContextMenu();
????
void
?SetEnableContextMenu(BOOL?bNewValue);
????
void
?SetUiMode(LPCTSTR?lpszNewValue);
????CString?GetUiMode();
????BOOL?GetStretchToFit();
????
void
?SetStretchToFit(BOOL?bNewValue);
????BOOL?GetWindowlessVideo();
????
void
?SetWindowlessVideo(BOOL?bNewValue);
????BOOL?GetIsRemote();
????CWMPPlayerApplication?GetPlayerApplication();
????
void
?openPlayer(LPCTSTR?bstrURL);
相反在2005下的生成的類一點成相應(yīng)的成員函數(shù)都沒有提供。(郁悶)
照著6.0下的源碼給2005添加相應(yīng)的成員函數(shù),bingo正常工作了。
難道我以后的工程都要在6.0下先生成代碼,然后再COPY到2005下。(天啊,折磨人啊)
到底是2005比6.0退步了,還是我不會用2005?怎么回事?
?


