WMP doesn't play a media on a thread



Hi,
I've been experiencing a weired situation with WMP interfaces.

I made a simple function which plays a media(Beep.mp3).
It sounds well when it is called from a class, but it doesn't sound when
called from a thread which is created by the class on init function of the
class.

Is there anyone who can tell the difference between a class, which maybe it
runs on a process, and a thread, which is created from the class?

IS there a way to run the MAWMPControl on a thread so that it can play media
files?


Thank you in advance with any comment
HRESULT MAWMPControl()
{
IWMPPlayer4 *pWP;
IWMPSettings *pWPSet;
IWMPControls *pWPCtrl;

CoInitializeEx(NULL,COINIT_MULTITHREADED);
HRESULT hr = S_OK;
CComBSTR bstrVersionInfo;
BSTR bstr_path, bstr_playmode;
hr = CoCreateInstance( __uuidof(WindowsMediaPlayer), NULL,
CLSCTX_INPROC_SERVER, __uuidof (IWMPPlayer4),(void **)&pWP);
hr = pWP->QueryInterface(__uuidof(IWMPSettings), (void **)&pWPSet);
hr = pWP->QueryInterface(__uuidof(IWMPControls), (void **)&pWPCtrl);
bstr_path = SysAllocString(L"\\Program Files\\CMA16\\Beep.mp3");
bstr_playmode=SysAllocString(L"loop");
hr = pWP->openPlayer(mybstr);
hr = pWPSet->setMode(bstr_playmode,TRUE);
hr = pWPSet->put_autoStart(TRUE);
//hr = pWPSet->put_playCount(100);
hr = pWPSet->put_volume(100);
hr = pWP->put_URL(bstr_path);
CoUninitialize();

return hr;
}
.


Loading