Playing a mp3 file at button click event in windows form

Archer picture Archer · May 15, 2012 · Viewed 17.9k times · Source

How to play a .mp3 file during the button click event in windows form?

I'm new to C# and any pointers to this will be really helpful.

Answer

default locale picture default locale · May 15, 2012

You can use WindowsMediaPlayer COM control to play mp3.

Here is a guide from msdn.

WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
player.URL = @"track.mp3";
player.controls.play();

Also you can use SoundPlayer to play wav files. There are also several third party .net mp3 libraries.