954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Playing mp3 in C#

Hello, I want to ask if there is any way to play an mp3 file in C# without the use of P/Invoke or winmp dll and the like. I can use external libraries too. It would also be nice if I could "include" the mp3 in the C# project, as I will only be playing one sound, and the user is unable to choose.

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 

use this code u will be able to play wave as well as MP3 File if working dont forgate to mark solved

System.Media.SoundPlayer player = new System.Media.SoundPlayer();
 
player.SoundLocation = "My Wav File.wav";
player.Play();
WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
 
wplayer.URL = "My MP3 file.mp3";
wplayer.controls.play();
hirenpatel53
Posting Whiz in Training
221 posts since Jun 2010
Reputation Points: 10
Solved Threads: 27
 

No, that uses windows functions. I want to make it such that it does not depend on any external function, dll or library.

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 
Hello, I want to ask if there is any way to play an mp3 file in C# without the use of P/Invoke or winmp dll and the like. I can use external libraries too. It would also be nice if I could "include" the mp3 in the C# project, as I will only be playing one sound, and the user is unable to choose.

Hi Visit this weblog, Goude U Fully... http://www.deyamil.persianblog.ir

asad_dani
Newbie Poster
4 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

I can't read tamil. Besides, I cannot use external libraries, external including system.media

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 
I can't read tamil. Besides, I cannot use external libraries, external including system.media

Ok, why can't you use the built in support for what you're trying to accomplish?

Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 22
Solved Threads: 8
 

You see, asked my prof and he said I have to find some way to play the mp3 directly, without anything else. Actually I already know of SoundPlayer, but it needs the mp3 in a file, I need the program to be integrated, as one assembly. The only way would be to include the mp3 in the project. Is it possible? If not I will have to choose another project. Maybe this is one of his "unsolvables", as he likes to play tricks on us.

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 

So let me get this straight...

You want to play an MP3 file, but you can't use the built-in library, or any external library?

So you want to play an MP3 file without using any functionality?

This cannot be achieved. Either use the System.Media.SoundPlayer, or use a DLL file. They are your ONLY options (unless you want to low level program some soundcard I/O port and just hope the hell that it's actually there)

Ketsuekiame
Master Poster
752 posts since May 2010
Reputation Points: 349
Solved Threads: 107
 

Ok. Thanks. Now to tell my mates not to choose this project :)

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 
Ok. Thanks. Now to tell my mates not to choose this project :)

I would talk to your professor again, and clarify he actually meant you couldn't use .NET with your C# project.

I have a hard time believing that's what he meant.

C# is useless without .NET. He had to know you'd use it. I'd clarify that he meant you couldn't use any API or DLLs outside C# and .NET.

My money is on the latter.

Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 22
Solved Threads: 8
 

I would talk to your professor again, and clarify he actually meant you couldn't use .NET with your C# project.

I have a hard time believing that's what he meant.

C# is useless without .NET. He had to know you'd use it. I'd clarify that he meant you couldn't use any API or DLLs outside C# and .NET.

My money is on the latter.


Hmmmmm... I just had a thought. Is he trying to 'dis' C#? Or drive home how hard it is to write an MP3 player from scratch?

I have had professors that have done stupid stuff like that.

Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 22
Solved Threads: 8
 

Right... Turns out that you lost the money. I asked him, and he said NO .NET usage, besides basic stuff like System.IO and System.Console, and things like vars etc.

requimrar
Newbie Poster
19 posts since Apr 2010
Reputation Points: 12
Solved Threads: 1
 

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: