-->![Soundplayer Sound Api Only Supports Playing Pcm Wave Files Soundplayer Sound Api Only Supports Playing Pcm Wave Files](/uploads/1/2/5/8/125850377/452225547.jpg)
![Soundplayer sound api only supports playing pcm wave files online Soundplayer sound api only supports playing pcm wave files online](http://theocacao.com/images/content/000576-versionstimeline.png)
This example plays a sound at a given path at run time.
Example
Compiling the Code
We use the Microsoft Sound API, the only supported format is. In this case Microsoft has an api called soundapi, which is what developers use to play back.wav files. The api only supports PCM files, so for any microsoft developer to play back the recorded. NET under the SoundPlayer class in System. My sound file format like this: 8000 Hz A-Law bit rate: 64 bit. But c# does not play this format. The format must be PCM Signed 24 bit- mono.
![Soundplayer Sound Api Only Supports Playing Pcm Wave Files Soundplayer Sound Api Only Supports Playing Pcm Wave Files](/uploads/1/2/5/8/125850377/452225547.jpg)
This example requires:
- That you replace the file name
'c:WindowsMediachimes.wav'
with a valid file name. - (C#) A reference to the System.Media namespace.
Robust Programming
![Soundplayer sound api only supports playing pcm wave files online Soundplayer sound api only supports playing pcm wave files online](http://theocacao.com/images/content/000576-versionstimeline.png)
File operations should be enclosed within appropriate structured exception handling blocks.
The following conditions may cause an exception:
- The path name is malformed. For example, it contains illegal characters or is only white space (ArgumentException class).
- The path is read-only (IOException class).
- The path name is
null
(ArgumentNullException class). - The path name is too long (PathTooLongException class).
- The path is invalid (DirectoryNotFoundException class).
- The path is only a colon, ':' (NotSupportedException class).
.NET Framework Security
Do not make decisions about the contents of the file based on the name of the file. For example, the file
Form1.vb
may not be a Visual Basic source file. Verify all inputs before using the data in your application.See also
|