Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use DirectShow to play midi and mp3 files

9 views
Skip to first unread message

PengTao

unread,
Jul 27, 2005, 6:56:06 AM7/27/05
to
Hi everyone:
I have wrote a simple program for Magneto emulator to play midi,mp3 files
use DirectShow. here is my code :

int _tmain(int argc, _TCHAR* argv[])
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;

// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return -1;
}

// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return -1;
}

hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

// Build the graph. IMPORTANT: Change this string to a file on your
system.
//hr = pGraph->RenderFile(L"\\1.mp3", NULL);
//hr = pGraph->RenderFile(L"\\bell.wav", NULL);
hr = pGraph->RenderFile(L"\\a001.mid", NULL);
if (SUCCEEDED(hr))
{
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);

// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
}

pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}

The problem is:
it can play only wave file not midi or mp3 files, what's strange is that
this code can work well on pc and also DirectShow support all of these media
type,right?
some body could tell me why?
thanks

Alex Feinman [MVP]

unread,
Jul 27, 2005, 1:20:11 PM7/27/05
to
What is the HRESULT returned by RenderFile?

--
Alex Feinman
---
Visit http://www.opennetcf.org
"PengTao" <Pen...@discussions.microsoft.com> wrote in message
news:BA978A49-661A-4EA3...@microsoft.com...

PengTao

unread,
Jul 27, 2005, 9:49:01 PM7/27/05
to
Both Mp3 and Midil return VFW_E_CANNOT_RENDER(0x80040218). it means "no
combination of filters could be found to render the stream".
but i think DIrectShow can support these types. so is there some uncommon
way to play mp3, midi files on Magneto smartphone?
Thanks

Xiaoma

unread,
Aug 15, 2005, 4:53:07 AM8/15/05
to
Of cource not! Smartphone 5.0 doesn't support midi format type 1 and mp3. For
audio format, only wav,wma,and midi format type 0 are supported on the SP 5.
That's why I asked the question for writing filters for midi format.
0 new messages