Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MP3 Player C,C++

Options
  • 29-05-2001 6:02pm
    #1
    Closed Accounts Posts: 67 ✭✭


    Building 2nd Stand alone MP3 player....
    Have all the required code (C)...
    Any interest in this project? Reply smile.gif
    o2l@eircom.net



Comments

  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    I have a friend who made one for his car. I'll point him in this threads general direction.


  • Closed Accounts Posts: 218 ✭✭Void


    What the hell does that post mean?

    Since you have all the C code, I'll give you something better. Here's some C++ code (Win32). Mp3s are eaaassyyy...

    mp3.h
    /* NECROSOFT MP3 PLAYING BITS  */
    /* ROB AT YOUR OWN DISCRETION  */
    /* [url="HTTP://WWW.NECROSOFT.IE"]HTTP://WWW.NECROSOFT.IE[/url]     */
    #ifndef _MP3H_
    #define _MP3H_
    
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <mmsystem.h>
    #include <strmif.h>
    #include <Control.h>
    #include <evcode.h>
    #include <Uuids.h>
    
    class cMp3
    {
    private:
     IBaseFilter   *  pif;
     IGraphBuilder *  pigb;
     IMediaControl *  pimc;
     IMediaEventEx *  pimex;
    
     bool    ready;
    
    public:
    	cMp3();
    	~cMp3();
    
    	void Play();
    	void Pause();
    	void Stop();
    
    	int Load(LPSTR filename);
    	void Cleanup();	
    };
    
    #endif
    
    

    mp3.cpp
    /* NECROSOFT MP3 PLAYING BITS  */
    /* ROB AT YOUR OWN DISCRETION  */
    /* [url="HTTP://WWW.NECROSOFT.IE"]HTTP://WWW.NECROSOFT.IE[/url]     */
    #include "Mp3.h"
    
    cMp3::cMp3()
    {
    	pif = NULL;
    	pigb = NULL;
    	pimc = NULL;
    	pimex = NULL;
    	
    	ready = false;
    	
    	CoInitialize(NULL);
    }
    
    cMp3::~cMp3()
    {
    	Cleanup();
    }
    
    void cMp3::Cleanup()
    {
    	CoUninitialize();
    	
    	if (pimc)
    		pimc->Stop();
    	
    	if(pif)
    	{
    		pif->Release();
    		pif = NULL;
    	}
    	
    	if(pigb)
    	{
    		pigb->Release();
    		pigb = NULL;
    	}
    	
    	if(pimc)
    	{
    		pimc->Release();
    		pimc = NULL;
    	}
    	
    	if(pimex)
    	{
    		pimex->Release();
    		pimex = NULL;
    	}
    }
    
    int cMp3::Load(LPSTR szFile)
    {
    	WCHAR wFile[MAX_PATH];
    	MultiByteToWideChar(CP_ACP, 0, szFile, -1, wFile, MAX_PATH);
    	
    	if (SUCCEEDED(CoCreateInstance( CLSID_FilterGraph,
    		NULL,
    		CLSCTX_INPROC_SERVER,
    		IID_IGraphBuilder,
    		(void **)&this->pigb)))
    	{
    		pigb->QueryInterface(IID_IMediaControl, (void **)&pimc);
    		pigb->QueryInterface(IID_IMediaEventEx, (void **)&pimex);
    		
    		if (SUCCEEDED(pigb->RenderFile(wFile, NULL)))
    		{
    			ready = true;
    		}  
    	}
    	return (ready);
    }
    
    void cMp3::Play()
    {
    	if (ready)
    	{
    		pimc->Run();
    	}
    }
    
    void cMp3::Pause()
    {
    	if (ready)
    	{
    		pimc->Pause();
    	}
    }
    
    void cMp3::Stop()
    {
    	if (ready)
    	{
    		pimc->Stop();
    	}
    }
    

    Usage:
    cMp3 mp3madness;
    mp3madness.Load("Strauss - Also Sprach Zarathustra.mp3");
    mp3madess.Play();
    

    Script Kiddies of the world can now put mad tunes to their Win32 hax04 programs.


  • Closed Accounts Posts: 822 ✭✭✭Kastro


    yea but can they write a mp3 virus,
    like in napster when something is searched for.. lets say "x.mp3".

    the virus goes and pretends to be "x.mp3"
    and if the user downloads it.. it executes on play. then to infect the users computer and do the same to the next john doe that searches for a song. And on a certain date it would fe<k with computers around the world that downloades it.

    /me thinks this is something of a nasty nature.. ;p


  • Registered Users Posts: 380 ✭✭dogs


    <font face="Verdana, Arial" size="2">
    the virus goes and pretends to be "x.mp3"
    and if the user downloads it.. it executes on play.
    </font>
    Eh...no, users tend to play(/decode) mp3s rather than
    executing them. Yes, you could send them an executable that
    played music but also did something nasty, but that's just a trojan and not exactly a new idea...


  • Closed Accounts Posts: 822 ✭✭✭Kastro


    hmmm but have you ever seen it or heard of it being done?


  • Advertisement
  • Closed Accounts Posts: 822 ✭✭✭Kastro


    well has it?


Advertisement