C # free audio libraries to download

Are there any free audio libraries for commercial use (for example, NAudio) that can play mp3 (but not NAudio!) Thank you so much! :)

+4
source share
2 answers

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.

+3
source

You can try using DirectSound. Entries for DirectSound are removed from the Add Link dialog box in VS 2008 or higher (I think), but you can still look in the GAC for the correct DLLs. Find the latest version. This is pretty easy, something like:

 Device dev = new Device(); dev.SetCooperativeLevel(this.Handle, CooperativeLevel.Priority); // this refers to the form to which DirectSound is tied SecondaryBuffer sound = new SecondaryBuffer("path\\to\\file", dev); sound.Volume = /* volume */; sound.Play(0, BufferPlayFlags.Default); 
+1
source

All Articles