我有一个项目,要求打开带播放列表的Windows Media Player。播放列表是根据选定的文件构建的。
从我发现的documentation开始,打开WMP实例似乎很容易。但是,我不确定如何构建播放列表或将其插入WMP启动。有什么想法?
#include "atlbase.h"
#include "atlwin.h"
#include "wmp.h"
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
HRESULT hr = S_OK;
CComBSTR bstrVersionInfo; // Contains the version string.
CComPtr<IWMPPlayer> spPlayer; // Smart pointer to IWMPPlayer interface.
hr = spPlayer.CoCreateInstance( __uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER );
if(SUCCEEDED(hr))
{
hr = spPlayer->get_versionInfo(&bstrVersionInfo);
}
if(SUCCEEDED(hr))
{
// Show the version in a message box.
COLE2T pStr(bstrVersionInfo);
MessageBox( NULL, (LPCSTR)pStr, _T("Windows Media Player Version"), MB_OK );
}
// Clean up.
spPlayer.Release();
CoUninitialize();
return 0;
}
答案 0 :(得分:1)
http://msdn.microsoft.com/en-us/library/windows/desktop/dd562624(v=vs.85).aspx
页面中间列出:
/Playlist PlaylistName
打开播放器并播放指定的播放列表。
使用QProcess
启动程序并指定参数。
http://qt-project.org/doc/qt-4.8/qprocess.html
希望有所帮助。
编辑:如果您仍想使用WMP API,可以查看:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd563405(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd563242(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd563547(v=vs.85).aspx