How do I play an MP3 file using C# ?

Lets say my file is located at "c:\song.mp3"
Lets say also that my PC does not have any other players, activeX or codecs installed.


Is it possible to write a code in C# that it simply plays the song?

Do I need aditional codecs to play it?

Thanks
LVL 1
New_AlexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kalpesh ChhatralaSoftware ConsultantCommented:
0
New_AlexAuthor Commented:
The point of the above codes is that they rely on the [DllImport("winmm.dll")]
which I can guess is a part of Windows Media Player.

If for some reasons you have WMP detached from your XP (like me) that will not work.

Any ideas?

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

New_AlexAuthor Commented:
I mean I would like my code to work on a PC that does not have .NET or DirectX installed

???
0
anarki_jimbelCommented:
OK, consider this as a comment only - I don't really going to give an answer as the question is marked to be deleted.

But think logically! If no player application is installed - how can you use sound cards if no DirectX?!
How can you run YOUR program if no .Net installed?!

OK, answer - you cannot play MP3 or any if programms you are talking are not installed...
0
New_AlexAuthor Commented:
I was going to run the executable on another PC. So .Net will not be necessary for the .exe file
0
cubaman_24Commented:
Hello:
Yes, you need some codec to play the file. Once installed, a call to
Process.Start("mymp3.mp3");
Will make the magic, launching the default media player.
Best regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cubaman_24Commented:
Me and other users have provided several answers. "No answer provided" is not a true reason to cancel the request. Could you specify why none answer fits you?
Best regards
0
New_AlexAuthor Commented:
Cubaman,

I needed a code and a location of the .dll file I needed to run the code. The línks above didn^t provide working source....

0
cubaman_24Commented:
New_Alex:
Your question says literally :
"Is it possible to write a code in C# that it simply plays the song? Do I need additional codecs to play it? "
There isn't any mention to code, you're asking if it's possible. And people answered according to your question... It's not that there ain't an answer, it's that you made the wrong question.. or not.
0
New_AlexAuthor Commented:
cubaman you probably right matey. I will come back with some points.

Take care
0
anarki_jimbelCommented:
"I was going to run the executable on another PC. So .Net will not be necessary for the .exe file"

Are you sure? If your program is written in C# - you need .Net framework installed on a computer... Otherwise your exe is useless. That's life...

So, answers again are: not possible / not possible.
0
New_AlexAuthor Commented:
Thanks all. It is fair to close the question by distributing the points I promised
0
New_AlexAuthor Commented:
That is life, unfortunately. I am throwing out the crappy C# for Visual C++ MFC. Still microsoft, but at least I feel more in control without the crappy .NET and shitsu dependencies.  

I have also downloaded tutorials for C++ MFC.

BYE BYE C# , Welcome Visual C++ on MFC
That is right. I put Tampax Tampons and I feel free and clean again.

Take care guys
0
cubaman_24Commented:
Hello again New Alex:
I strongly disagree with your opinion about .net.
.Net is already there in any fresh install of windows since XP. You don't need any extra downloads.
Also, it's much safer as environment than C++. No buffers overruns or unsafe pointers and things like that.
.Net is also inter-operable. You can take an exe compiled in a windows x32 machine and run it without any change in, for example, a x64 linux box with mono installed.
Now wait till' you start your C++ development and start fighting with headers and lib files.. ;-)

.Net has many more advantages for normal developers. For creating regular business There is no need of low level access to program a mp3 player.. C++ is more adequate for drivers and things like that, from my point of view. Each language has it's own niche.
Best regards.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.