SDL, SDL_Mixer and SMPEG For mp3 Playback

Started by
20 comments, last by Crash 22 years, 3 months ago
Crash, in regards to your previous question about using MP3s in DirectX, you can do so very easily using DirectShow. However don't think it comes with DirectX 7, but it does come with DirectX 8.

Here's some sample code to show how easy it is to play an MP3 file using DirectShow:

    #include <dshow.h>void main(void){    IGraphBuilder *pGraph;    IMediaControl *pMediaControl;    IMediaEvent   *pEvent;    CoInitialize(NULL);        // Create the filter graph manager and query for interfaces.    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,                         IID_IGraphBuilder, (void **)&pGraph);    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);    pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);    // Build the graph. IMPORTANT: Change string to a file on your system.    pGraph->RenderFile(L"C:\\Example.mp3", NULL);    // Run the graph.    pMediaControl->Run();    // Wait for completion.     long evCode;    pEvent->WaitForCompletion(INFINITE, &evCode);    // Clean up.    pMediaControl->Release();    pEvent->Release();    pGraph->Release();    CoUninitialize();}  


DirectShow looks very duanting at first due to the sheer number of interfaces but you really need to concern yourself with IGraphBuilder, IMediaControl, IMediaEvent and IBasicAudio iterfaces.

You can also use it to play other audio file types like AU, AIFF, SND, etc.

- Kaijin

Edited by - Kaijin on January 2, 2002 2:08:31 PM
Advertisement
Thanks alot anonymous, Im going to look through those resources tommorow morn and hopefully finally getting this to work.

Thanks also to Kaijin, I had just discovered I could use DirectShow but that codes a big help as Im seriously considering reverting to my original idea to use DirectX as then I wont have to worry about distributing my code (which is already in quite a state.)

Anyway till tommorow, when I will hopefully solve this problem and possibly complete this darn game.

Thanks guys,
Crash,



"We Must Move Forwards NOT Backwards, Sideways NOT Forwards And Always Twirling Twirling Towards Success." - 2000

"If You Keep Looking Forward Your Gonna End Up Looking Backwards At Yourself Running Sideways!" - 2001
"We Must Move Forwards NOT Backwards, Sideways NOT Forwards And Always Twirling Twirling Towards Success." - 2000"If You Keep Looking Forward Your Gonna End Up Looking Backwards At Yourself Running Sideways!" - 2001

This topic is closed to new replies.

Advertisement