In The Hand LtdIn The Hand
SoundPlayer Class
NamespacesInTheHand.MediaSoundPlayer
.NET Components for Mobility
Controls playback of a sound from a .wav file.
Declaration Syntax
C#Visual Basic
public sealed class SoundPlayer : Component
Public NotInheritable Class SoundPlayer _
	Inherits Component
Members
All MembersConstructorsMethodsPropertiesEvents



IconMemberDescription
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)
Determines whether the specified Object is equal to the current 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)
Returns an object that represents a service provided by the Component or by its Container.
(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
Gets or sets the ISite of the Component.
(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.)
Remarks
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.
Examples
This example plays a sound at a given path at run time.
CopyVB.NET
Private Sub playSimpleSound()
    Dim simpleSound As New SoundPlayer("\Windows\alarm.wav")
    simpleSound.Play()
End Sub
CopyC#
private void playSimpleSound()
{
    SoundPlayer simpleSound = new SoundPlayer(@"\Windows\alarm.wav");
    simpleSound.Play();
}
Inheritance Hierarchy

Assembly: InTheHand (Module: InTheHand) Version: 7.0.0.0