Controls playback of a sound from a .wav file.
| All Members | Constructors | Methods | Properties | Events | |
| Icon | Member | Description |
|---|---|---|
| SoundPlayer()()() |
Initializes a new instance of the SoundPlayer class.
| |
| SoundPlayer(Stream) |
Initializes a new instance of the SoundPlayer class, attaches the .wav file within the specified Stream.
| |
| SoundPlayer(String) |
Initializes a new instance of the SoundPlayer class and attaches the specified .wav file.
| |
| Dispose()()() | Releases all resources used by the Component. (Inherited from Component.) | |
| Dispose(Boolean) | Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.) | |
| Disposed | Adds an event handler to listen to the Disposed event on the component. (Inherited from Component.) | |
| Equals(Object) | (Inherited from Object.) | |
| Events | Gets the list of event handlers that are attached to this Component. (Inherited from Component.) | |
| Finalize()()() | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.) | |
| GetHashCode()()() | Serves as a hash function for a particular type. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) | |
| GetType()()() | Gets the Type of the current instance. (Inherited from Object.) | |
| MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| Play()()() |
Plays the .wav file using a new thread.
| |
| PlayLooping()()() |
Plays and loops the .wav file using a new thread and loads the .wav file first if it has not been loaded.
| |
| PlaySync()()() |
Plays the .wav file using the UI thread.
| |
| Site | (Inherited from Component.) | |
| SoundLocation |
Gets or sets the file path of the .wav file to load.
| |
| SoundLocationChanged |
Occurs when the SoundLocation property is changed.
| |
| Stop()()() |
Stops playback of the sound if playback is occurring.
| |
| Stream |
Gets or sets the Stream from which to load the .wav file.
| |
| StreamChanged |
Occurs when the Stream property is changed.
| |
| Tag |
Gets or sets the Object that contains data about the SoundPlayer.
| |
| ToString()()() | (Inherited from Object.) |
The SoundPlayer class provides a simple interface for loading and playing a .wav file.
The SoundPlayer class supports loading a .wav file from a file path, a Stream that contains a .wav file, or an embedded resource that contains a .wav file.
This example plays a sound at a given path at run time.
CopyC#
CopyC#
[VB]
Private Sub playSimpleSound()
Dim simpleSound As New SoundPlayer("\Windows\alarm.wav")
simpleSound.Play()
End Subprivate void playSimpleSound() { SoundPlayer simpleSound = new SoundPlayer(@"\Windows\alarm.wav"); simpleSound.Play(); }
| Object | |||
| MarshalByRefObject | |||
| Component | |||
| SoundPlayer | |||