Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

oni_viper

newb ? :: mp3 in directx

This topic is 5294 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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();
}

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
.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();

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!