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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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:
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?

Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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

anarki_jimbelSenior DeveloperCommented:
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...
New_AlexAuthor Commented:
I was going to run the executable on another PC. So .Net will not be necessary for the .exe file
Yes, you need some codec to play the file. Once installed, a call to
Will make the magic, launching the default media player.
Best regards.

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
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
New_AlexAuthor Commented:

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....

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.
New_AlexAuthor Commented:
cubaman you probably right matey. I will come back with some points.

Take care
anarki_jimbelSenior DeveloperCommented:
"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.
New_AlexAuthor Commented:
Thanks all. It is fair to close the question by distributing the points I promised
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
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.
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.