mscorlib(4.0.0.0) API with additions
System.Media.SoundPlayer Class Reference

Controls playback of a sound from a .wav file. More...

Inheritance diagram for System.Media.SoundPlayer:
[legend]
Collaboration diagram for System.Media.SoundPlayer:
[legend]

Public Member Functions

 SoundPlayer ()
 Initializes a new instance of the T:System.Media.SoundPlayer class. More...
 
 SoundPlayer (string soundLocation)
 Initializes a new instance of the T:System.Media.SoundPlayer class, and attaches the specified .wav file. More...
 
 SoundPlayer (Stream stream)
 Initializes a new instance of the T:System.Media.SoundPlayer class, and attaches the .wav file within the specified T:System.IO.Stream. More...
 
void LoadAsync ()
 Loads a .wav file from a stream or a Web resource using a new thread. More...
 
void Load ()
 Loads a sound synchronously. More...
 
void Play ()
 Plays the .wav file using a new thread, and loads the .wav file first if it has not been loaded. More...
 
void PlaySync ()
 Plays the .wav file and loads the .wav file first if it has not been loaded. More...
 
void PlayLooping ()
 Plays and loops the .wav file using a new thread, and loads the .wav file first if it has not been loaded. More...
 
void Stop ()
 Stops playback of the sound if playback is occurring. More...
 
- Public Member Functions inherited from System.ComponentModel.Component
void Dispose ()
 Releases all resources used by the T:System.ComponentModel.Component. More...
 
override string ToString ()
 Returns a T:System.String containing the name of the T:System.ComponentModel.Component, if any. This method should not be overridden. More...
 
- Public Member Functions inherited from System.MarshalByRefObject
object GetLifetimeService ()
 Retrieves the current lifetime service object that controls the lifetime policy for this instance. More...
 
virtual object InitializeLifetimeService ()
 Obtains a lifetime service object to control the lifetime policy for this instance. More...
 
virtual ObjRef CreateObjRef (Type requestedType)
 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More...
 

Public Attributes

bool IsLoadCompleted => isLoadCompleted
 Gets a value indicating whether loading of a .wav file has successfully completed. More...
 

Protected Member Functions

 SoundPlayer (SerializationInfo serializationInfo, StreamingContext context)
 Initializes a new instance of the T:System.Media.SoundPlayer class. More...
 
virtual void OnLoadCompleted (AsyncCompletedEventArgs e)
 Raises the E:System.Media.SoundPlayer.LoadCompleted event. More...
 
virtual void OnSoundLocationChanged (EventArgs e)
 Raises the E:System.Media.SoundPlayer.SoundLocationChanged event. More...
 
virtual void OnStreamChanged (EventArgs e)
 Raises the E:System.Media.SoundPlayer.StreamChanged event. More...
 
- Protected Member Functions inherited from System.ComponentModel.Component
virtual void Dispose (bool disposing)
 Releases the unmanaged resources used by the T:System.ComponentModel.Component and optionally releases the managed resources. More...
 
virtual object GetService (Type service)
 Returns an object that represents a service provided by the T:System.ComponentModel.Component or by its T:System.ComponentModel.Container. More...
 
- Protected Member Functions inherited from System.MarshalByRefObject
MarshalByRefObject MemberwiseClone (bool cloneIdentity)
 Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
 

Properties

int LoadTimeout [get, set]
 Gets or sets the time, in milliseconds, in which the .wav file must load. More...
 
string SoundLocation [get, set]
 Gets or sets the file path or URL of the .wav file to load. More...
 
Stream Stream [get, set]
 Gets or sets the T:System.IO.Stream from which to load the .wav file. More...
 
object Tag [get, set]
 Gets or sets the T:System.Object that contains data about the T:System.Media.SoundPlayer. More...
 
AsyncCompletedEventHandler LoadCompleted
 Occurs when a .wav file has been successfully or unsuccessfully loaded. More...
 
EventHandler SoundLocationChanged
 Occurs when a new audio source path for this T:System.Media.SoundPlayer has been set. More...
 
EventHandler StreamChanged
 Occurs when a new T:System.IO.Stream audio source for this T:System.Media.SoundPlayer has been set. More...
 
- Properties inherited from System.ComponentModel.Component
EventHandlerList Events [get]
 Gets the list of event handlers that are attached to this T:System.ComponentModel.Component. More...
 
virtual ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite of the T:System.ComponentModel.Component. More...
 
IContainerContainer [get]
 Gets the T:System.ComponentModel.IContainer that contains the T:System.ComponentModel.Component. More...
 
bool??? DesignMode [get]
 Gets a value that indicates whether the T:System.ComponentModel.Component is currently in design mode. More...
 
EventHandler Disposed
 Occurs when the component is disposed by a call to the M:System.ComponentModel.Component.Dispose method. More...
 
- Properties inherited from System.ComponentModel.IComponent
ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite associated with the T:System.ComponentModel.IComponent. More...
 

Additional Inherited Members

- Protected Attributes inherited from System.ComponentModel.Component
virtual bool CanRaiseEvents => true
 Gets a value indicating whether the component can raise an event. More...
 
- Events inherited from System.ComponentModel.IComponent
EventHandler Disposed
 Represents the method that handles the E:System.ComponentModel.IComponent.Disposed event of a component. More...
 

Detailed Description

Controls playback of a sound from a .wav file.

Definition at line 16 of file SoundPlayer.cs.

Constructor & Destructor Documentation

◆ SoundPlayer() [1/4]

System.Media.SoundPlayer.SoundPlayer ( )

Initializes a new instance of the T:System.Media.SoundPlayer class.

Definition at line 299 of file SoundPlayer.cs.

◆ SoundPlayer() [2/4]

System.Media.SoundPlayer.SoundPlayer ( string  soundLocation)

Initializes a new instance of the T:System.Media.SoundPlayer class, and attaches the specified .wav file.

Parameters
soundLocationThe location of a .wav file to load.
Exceptions
T:System.UriFormatExceptionThe URL value specified by soundLocation cannot be resolved.

Definition at line 307 of file SoundPlayer.cs.

◆ SoundPlayer() [3/4]

System.Media.SoundPlayer.SoundPlayer ( Stream  stream)

Initializes a new instance of the T:System.Media.SoundPlayer class, and attaches the .wav file within the specified T:System.IO.Stream.

Parameters
streamA T:System.IO.Stream to a .wav file.

Definition at line 319 of file SoundPlayer.cs.

◆ SoundPlayer() [4/4]

System.Media.SoundPlayer.SoundPlayer ( SerializationInfo  serializationInfo,
StreamingContext  context 
)
protected

Initializes a new instance of the T:System.Media.SoundPlayer class.

Parameters
serializationInfoThe T:System.Runtime.Serialization.SerializationInfo to be used for deserialization.
contextThe destination to be used for deserialization.
Exceptions
T:System.UriFormatExceptionThe P:System.Media.SoundPlayer.SoundLocation specified in serializationInfo cannot be resolved.

Definition at line 329 of file SoundPlayer.cs.

Member Function Documentation

◆ Load()

void System.Media.SoundPlayer.Load ( )

Loads a sound synchronously.

Exceptions
T:System.ServiceProcess.TimeoutExceptionThe elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout.
T:System.IO.FileNotFoundExceptionThe file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found.

Definition at line 398 of file SoundPlayer.cs.

◆ LoadAsync()

void System.Media.SoundPlayer.LoadAsync ( )

Loads a .wav file from a stream or a Web resource using a new thread.

Exceptions
T:System.ServiceProcess.TimeoutExceptionThe elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout.
T:System.IO.FileNotFoundExceptionThe file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found.

Definition at line 357 of file SoundPlayer.cs.

◆ OnLoadCompleted()

virtual void System.Media.SoundPlayer.OnLoadCompleted ( AsyncCompletedEventArgs  e)
protectedvirtual

Raises the E:System.Media.SoundPlayer.LoadCompleted event.

Parameters
eAn T:System.ComponentModel.AsyncCompletedEventArgs that contains the event data.

Definition at line 630 of file SoundPlayer.cs.

◆ OnSoundLocationChanged()

virtual void System.Media.SoundPlayer.OnSoundLocationChanged ( EventArgs  e)
protectedvirtual

Raises the E:System.Media.SoundPlayer.SoundLocationChanged event.

Parameters
eAn T:System.EventArgs that contains the event data.

Definition at line 637 of file SoundPlayer.cs.

◆ OnStreamChanged()

virtual void System.Media.SoundPlayer.OnStreamChanged ( EventArgs  e)
protectedvirtual

Raises the E:System.Media.SoundPlayer.StreamChanged event.

Parameters
eAn T:System.EventArgs that contains the event data.

Definition at line 644 of file SoundPlayer.cs.

◆ Play()

void System.Media.SoundPlayer.Play ( )

Plays the .wav file using a new thread, and loads the .wav file first if it has not been loaded.

Exceptions
T:System.ServiceProcess.TimeoutExceptionThe elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout.
T:System.IO.FileNotFoundExceptionThe file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found.
T:System.InvalidOperationExceptionThe .wav header is corrupted; the file specified by P:System.Media.SoundPlayer.SoundLocation is not a PCM .wav file.

Definition at line 530 of file SoundPlayer.cs.

◆ PlayLooping()

void System.Media.SoundPlayer.PlayLooping ( )

Plays and loops the .wav file using a new thread, and loads the .wav file first if it has not been loaded.

Exceptions
T:System.ServiceProcess.TimeoutExceptionThe elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout.
T:System.IO.FileNotFoundExceptionThe file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found.
T:System.InvalidOperationExceptionThe .wav header is corrupted; the file specified by P:System.Media.SoundPlayer.SoundLocation is not a PCM .wav file.

Definition at line 548 of file SoundPlayer.cs.

◆ PlaySync()

void System.Media.SoundPlayer.PlaySync ( )

Plays the .wav file and loads the .wav file first if it has not been loaded.

Exceptions
T:System.ServiceProcess.TimeoutExceptionThe elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout.
T:System.IO.FileNotFoundExceptionThe file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found.
T:System.InvalidOperationExceptionThe .wav header is corrupted; the file specified by P:System.Media.SoundPlayer.SoundLocation is not a PCM .wav file.

Definition at line 539 of file SoundPlayer.cs.

◆ Stop()

void System.Media.SoundPlayer.Stop ( )

Stops playback of the sound if playback is occurring.

Definition at line 622 of file SoundPlayer.cs.

Member Data Documentation

◆ IsLoadCompleted

bool System.Media.SoundPlayer.IsLoadCompleted => isLoadCompleted

Gets a value indicating whether loading of a .wav file has successfully completed.

Returns
true if a .wav file is loaded; false if a .wav file has not yet been loaded.

Definition at line 243 of file SoundPlayer.cs.

Property Documentation

◆ LoadCompleted

AsyncCompletedEventHandler System.Media.SoundPlayer.LoadCompleted
addremove

Occurs when a .wav file has been successfully or unsuccessfully loaded.

Definition at line 261 of file SoundPlayer.cs.

◆ LoadTimeout

int System.Media.SoundPlayer.LoadTimeout
getset

Gets or sets the time, in milliseconds, in which the .wav file must load.

Returns
The number of milliseconds to wait. The default is 10000 (10 seconds).

Definition at line 175 of file SoundPlayer.cs.

◆ SoundLocation

string System.Media.SoundPlayer.SoundLocation
getset

Gets or sets the file path or URL of the .wav file to load.

Returns
The file path or URL from which to load a .wav file, or F:System.String.Empty if no file path is present. The default is F:System.String.Empty.

Definition at line 193 of file SoundPlayer.cs.

◆ SoundLocationChanged

EventHandler System.Media.SoundPlayer.SoundLocationChanged
addremove

Occurs when a new audio source path for this T:System.Media.SoundPlayer has been set.

Definition at line 274 of file SoundPlayer.cs.

◆ Stream

Stream System.Media.SoundPlayer.Stream
getset

Gets or sets the T:System.IO.Stream from which to load the .wav file.

Returns
A T:System.IO.Stream from which to load the .wav file, or null if no stream is available. The default is null.

Definition at line 221 of file SoundPlayer.cs.

◆ StreamChanged

EventHandler System.Media.SoundPlayer.StreamChanged
addremove

Occurs when a new T:System.IO.Stream audio source for this T:System.Media.SoundPlayer has been set.

Definition at line 287 of file SoundPlayer.cs.

◆ Tag

object System.Media.SoundPlayer.Tag
getset

Gets or sets the T:System.Object that contains data about the T:System.Media.SoundPlayer.

Returns
An T:System.Object that contains data about the T:System.Media.SoundPlayer.

Definition at line 248 of file SoundPlayer.cs.


The documentation for this class was generated from the following file: