You can use the built-in WMPLib - see this MSDN article on Creating Windows Media Player Software Programmatically .
At the most basic level, you will need the following code:
private void PlayFile(String url) { Player = new WMPLib.WindowsMediaPlayer(); Player.URL = url; Player.controls.play(); }
However, you can also report that the playback status has changed so that you can start playing a new track or close the form (for example):
Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange) private void Player_PlayStateChange(int NewState) { if ((WMPLib.WMPPlayState)NewState == WMPLib.WMPPlayState.wmppsStopped) { this.Close(); } }
This means that your application is bound to Windows - therefore you cannot use Mono.
source share