1,105,197 Community Members

Playing mp3 in C#

Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
hirenpatel53
Posting Whiz in Training
245 posts since Jun 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 31 [?]
Skill Endorsements: 0 [?]
 
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();
Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
asad_dani
Newbie Poster
5 posts since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 11 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
Ketsuekiame
Posting Virtuoso
1,674 posts since May 2010
Reputation Points: 793 [?]
Q&As Helped to Solve: 231 [?]
Skill Endorsements: 24 [?]
 
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)

Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 11 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
Zinderin
Junior Poster in Training
76 posts since Jun 2010
Reputation Points: 11 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
requimrar
Newbie Poster
20 posts since Apr 2010
Reputation Points: 2 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
asad_dani
Newbie Poster
5 posts since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: