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.
| |
| CanRaiseEvents |
Gets a value indicating whether the component can raise an event.
(Inherited from Component.) | |
| Container |
Gets the IContainer that contains the Component.
(Inherited from Component.) | |
| CreateObjRef(Type) |
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.) | |
| DesignMode |
Gets a value that indicates whether the Component is currently in design mode.
(Inherited from Component.) | |
| 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 |
Occurs when the component is disposed by a call to the Dispose()()()() method.
(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.
(Inherited from Object.) | |
| GetLifetimeService()()()() |
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.) | |
| GetService(Type) | (Inherited from Component.) | |
| GetType()()()() |
Gets the Type of the current instance.
(Inherited from Object.) | |
| InitializeLifetimeService()()()() |
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.) | |
| MemberwiseClone(Boolean) |
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.) | |
| 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()()()() |
Returns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component.) |
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.
CopyVB.NET
CopyC#
Private Sub playSimpleSound() Dim simpleSound As New SoundPlayer("\Windows\alarm.wav") simpleSound.Play() End Sub
private void playSimpleSound() { SoundPlayer simpleSound = new SoundPlayer(@"\Windows\alarm.wav"); simpleSound.Play(); }
| Object | |||
| MarshalByRefObject | |||
| Component | |||
| SoundPlayer | |||