Write a wav file player in C#
That is a bit hard to write a mp3 player in C#. I think you may need to find third party mp3 decoder dll. But if you only want to play to a wav file, that is very easy. .Net libraries already have a control class for you.
Code
System.Media.SoundPlayer |
All you need to put the file name into the constructor
Code
SoundPlayer player = new SoundPlayer(FileName); |
Then you can play and stop the file by these methods:
Code
player.Play(); | |
player.Stop(); |
This afternoon, I wrote an example project for this. Moreover, this project is implemented in WPF rather than normal Windows Forms, because I wish to practice my WPF skills.
Download the example project, please click here.
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
1 comment
This post has 373 feedbacks awaiting moderation...
Form is loading...
Comment from: rahman [Visitor]
tanx. how to play two or more wav files together?
in other word mix them together.