0

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.

5
Contributors
12
Replies
49
Views
7 Years
Discussion Span
Last Post by asad_dani
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();
Votes + Comments
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.

0

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

0

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

0

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?

0

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.

0

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)

0

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.

Edited by Zinderin: n/a

0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.