QT C++-如何在播放列表处于活动状态的情况下打开Windows Media Player



我有一个项目,要求打开带有播放列表的windows媒体播放器。播放列表是根据选定的文件构建的。

从我发现的文档来看,打开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;
}

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

相关内容

最新更新