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.

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();
commented: Nice example, was searching for this. Thanks +0

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

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

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

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?

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.

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)

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

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.

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.

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.

Hello...
In this page,I send answer's of play sound by C#.net.
Click Here
excuse me for i don't write english well!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.