newb ? :: mp3 in directx

Started by
16 comments, last by oni_viper 20 years ago
i''m a big newb here, but does anyone know how to play mp3''s in directx with c++? i''ve searched the internet, but couldn''t find anything. examples/source code is much appreciated.
oops...
Advertisement
Look at the DirectShow examples in the SDK. As far as I know DirectMusic and DirectSound will not play .mp3''s only DirectShow.

-UltimaX-
Ariel Productions
|Designing A Screen Shot System|

"You wished for a white christmas... Now go shovel your wishes!"
you will need to link with strmiids.lib

class CMp3{protected:  IGraphBuilder* m_pGraph;  IMediaControl* m_pControl;public:  void Create();  void Destroy();  void Load(LPCWSTR lpcwstrFile);  void Play();};


#include <dshow.h>#include "mp3.h"void CMp3::Create(){  CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGraph);  m_pGraph->QueryInterface(IID_IMediaControl, (void **)&m_pControl);}void CMp3::Destroy(){  m_pControl->Release();  m_pGraph->Release();}void CMp3::Load(LPCWSTR lpcwstrFile){  m_pGraph->RenderFile(lpcwstrFile, NULL);}void CMp3::Play(){  m_pControl->Run();}
i have a small problem with that code. it gives me this error:

c:\dxsdk\include\ksuuids.h(236) : error C2374: ''IID_IKsControl'' : redefinition; multiple initialization
c:\dxsdk\include\dmksctrl.h(148) : see declaration of ''IID_IKsControl''

it points at this in ksuuids.h:

// 28F54685-06FD-11D2-B27A-00A0C9223196
OUR_GUID_ENTRY(IID_IKsControl,
0x28F54685L, 0x06FD, 0x11D2, 0xB2, 0x7A, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96)

(if that helps at all)
oops...
im not really sure why that error would occur
try also linking with dxguid.lib
already done, but still nothing =(

[edited by - oni_viper on March 18, 2004 10:59:52 PM]
oops...
if u still have the original dx sdk download try replacing those files
make sure you have the dx includes/libs at the top of the list in the options
um ya I dont know
maybe make a new project
I really have no idea
what!? eFoDay so u r sayin that is all the code i need to play a mp3????
.mp3''s, .avi''s and .mids will play using that code
I think .ogg also plays

Example use:

CMp3 myMp3;

// startup
myMp3.Create();
myMp3.Load(L"http://example.microsoft.com/Example.avi");

// at startup or in game loop
myMp3.Play();

// shutdown
myMp3.Destroy();
if only my compiler would let me use it =(
stupid idd_ikscontrol...
oops...

This topic is closed to new replies.

Advertisement