Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

SoundPlayer Class Overview

The SoundPlayer class enables you to easily include sounds in your applications.

The SoundPlayer class can play sound files in the .wav format, either from a resource or from UNC or HTTP locations. Additionally, the SoundPlayer class enables you to load or play sounds asynchronously.

You can also use the SystemSounds class to play common system sounds, including a beep.



SoundLocation property

The file path or Web address of the sound. Acceptable values can be UNC or HTTP.

LoadTimeout property

The number of milliseconds your program will wait to load a sound before it throws an exception. The default is 10 seconds.

IsLoadCompleted property

A Boolean value indicating whether the sound has finished loading.

Load method

Loads a sound synchronously.

LoadAsync method

Begins to load a sound asynchronously. When loading is complete, it raises the OnLoadCompleted event.

Play method

Plays the sound specified in the SoundLocation or Stream property in a new thread.

PlaySync method

Plays the sound specified in the SoundLocation or Stream property in the current thread.

Stop method

Stops any sound currently playing.

LoadCompleted event

Raised after the load of a sound is attempted.

Community Additions

© 2015 Microsoft