Compartir a través de


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.

Commonly Used Properties, Methods, and Events

Name Description

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.

See Also

Reference

SoundPlayer
SystemSounds

Other Resources

SoundPlayer Class