Sunday, June 6, 2010

Playing a Wave - File

For playing Wave - files .Net provides the class System.Media.SoundPlayer.
This class can either be initialized with a path to the Wave - file in its constructor, or the path can be set by the property SoundLocation.
The following code plays a sample sound:
System.Media.SoundPlayer ExamplePlayer = new System.Media.SoundPlayer();
ExamplePlayer.SoundLocation = "C:\\Dokumente und Einstellungen\\Oliver\\Desktop\\wav\\MM_Lachen.wav";
In the post Playing MP3 - Files I show the use of the Windows Media Player control, which allows the playing of nearly all audio formats (so the title actually is a bit wrong). So anybody who wants to use more audio formats than just the Wave described here, is refered to that post.

No comments:

Post a Comment