// WMPConsole.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <atlwin.h>
#include "wmp.h"
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
HRESULT hr = S_OK;
CComBSTR bstrVersionInfo;
CComPtr<IWMPPlayer4> spPlayer;
hr = spPlayer.CoCreateInstance(__uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER);
if(SUCCEEDED(hr)){
hr = spPlayer->get_versionInfo(&bstrVersionInfo);
}
if(SUCCEEDED(hr)){
COLE2T pStr(bstrVersionInfo);
MessageBox(NULL, (LPCSTR)pStr, _T("Windows Media Player Version"),MB_OK);
}
BSTR bstrURL = A2BSTR(_T("//1.mp3"));
hr = spPlayer->put_URL(bstrURL);
IWMPControls *controls;
hr = spPlayer->get_controls(&controls);
hr = controls->play();
char c;
std::cin >> c;
spPlayer.Release();
CoUninitialize();
return 0;
}
copy wmp.h from include directory of sdk installed. I'm not sure it is right but it works.
this example create instance of Com WindowsMedisPlayer. And it use smart point of Com with 'CComPtr<IWMPPlayer> spPlayer;'.
but this code does not work now. it can't play the song