Click to See Complete Forum and Search --> : How to play MP3 files using C#?


Alex Rest
April 17th, 2005, 11:03 AM
Hi,

There is a question:
How to play MP3 files using C#?

Thanks,
Alex.

Anders
April 17th, 2005, 04:45 PM
Well, one way to find out is to do a search on 'MP3' here on CG. :-)

Another way, if you have access to Windows Media Player, is to right-click on your toolbox, select 'Choose Items...' and select the Windows Media Player ActiveX component from the COM Components tab, and use that to play your MP3 file!
A third way is to search your favorite search engine for 'MP3 playback', which in my case would yield (among tons of hits) this hit: http://www.gamedev.net/reference/articles/article2053.asp. This solution uses the MCI, which is also to be found if you search for MP3 right here at CG: http://www.codeguru.com/forum/showthread.php?t=213820

Now, if you don't want to use an ActiveX component, or MCI, or a third party component/assembly/whatever, then I can only advice you (as the 4th way) to read and playback (somehow) the MP3 file format yourself: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm

Oh, this is so fun :wave: , I am currently listening to Debelah Morgan - Dance With Me.mp3 using the 2nd way, without writing a single line of code. (Ofcourse I have the original CD, and decoded the song in MP3 format only for backup purpose :-) (yeah right...)

HTH!

mehdi62b
April 17th, 2005, 06:37 PM
the easiest way is,

System.Diagnostics.Process.Start("[Path].mp3");it opens the appropriate player which is determined on the local machine(ususally Media Player) and play the music.

Alex Rest
April 18th, 2005, 07:23 AM
the problem is: I want to contro volume,
background music etc.
I want to have much more control.

Thanks,
Alex.

Andy Tacker
April 18th, 2005, 09:11 AM
use windows media player. it's nicely intergrated and you can control it too...

right click toolbox and click customize ... select COM and find media Player and say Ok.

now drag the player from toolbox on to your form and off you go programming...

Alex Rest
April 18th, 2005, 11:35 AM
Thorry, I forgot say that I wan to play mp3 a Pocket PC
and it must not be a standard player.
In a Desctop PC I can all and much more using C++/MFC.
There is such instrument as DirectShow.
I used it.
But I do not know how you low functions in a Pocket PC.