I´m using following code:
===============================================================================
bool SoundPlayer::realize()
{
// Cleaning GraphFilter
if(pGraph != NULL)
{
return true;
}
// Initializing the COM library on the current thread.
HRESULT hr;
hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library.\n");
return false;
}
// Creating an instance of the Filter Graph Manager.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.\n");
return false;
}
// Asking to Graph for interfaces.
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
if (FAILED(hr))
{
printf("ERROR - Could not retrieve pointer to IMediaControl interface.\n");
return false;
}
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
if (FAILED(hr))
{
printf("ERROR - Could not retrieve pointer to IMediaEvent interface.\n");
return false;
}
hr = pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pSeeking);
if (FAILED(hr))
{
printf("ERROR - Could not retrieve pointer to IMediaSeeking interface.\n");
return false;
}
hr = pGraph->QueryInterface(IID_IBasicAudio, (void **)&pAudio);
if (FAILED(hr))
{
printf("ERROR - Could not retrieve pointer to IBasicAudio interface.\n");
return false;
}
// Constructing a filter graph that will play the specified file.
hr = pGraph->RenderFile(soundFileNameW, NULL);
if (FAILED(hr))
{
printf("ERROR - Could not construct a filter graph that will play the specified file.");
return false;
}
}
bool SoundPlayer::start()
{
if(!realize())
{
return false;
}
// Switching the entire filter graph to running state.
HRESULT hr;
hr = pControl->Run();
if (FAILED(hr))
{
printf("ERROR - Could not switch filter graph to running state.\n");
return false;
}
return true;
}
bool SoundPlayer::stop()
{
// Switching the entire filter graph to stopped state.
HRESULT hr;
hr = pControl->Stop();
if (FAILED(hr))
{
printf("ERROR - Could not switch filter graph to stopped state.\n");
return false;
}
return true;
}
void SoundPlayer::close()
{
// Releasing graph and COM.
pAudio->Release();
pAudio = NULL;
pSeeking->Release();
pSeeking = NULL;
pEvent->Release();
pEvent = NULL;
pControl->Release();
pControl = NULL;
pGraph->Release();
pGraph = NULL;
CoUninitialize();
}
===============================================================================
Does anyone has encountered this problem?
best regards...