newb ? :: mp3 in directx
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.
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!"
-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)
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)
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
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
.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();
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();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement