Controls playback of a sound from a .wav file.
More...
|
| 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...
|
|
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...
|
|
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...
|
|
|
bool | IsLoadCompleted => isLoadCompleted |
| Gets a value indicating whether loading of a .wav file has successfully completed. More...
|
|
|
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...
|
|
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...
|
|
IContainer? | Container [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...
|
|
ISite | Site [get, set] |
| Gets or sets the T:System.ComponentModel.ISite associated with the T:System.ComponentModel.IComponent. More...
|
|
|
virtual bool | CanRaiseEvents => true |
| Gets a value indicating whether the component can raise an event. More...
|
|
EventHandler | Disposed |
| Represents the method that handles the E:System.ComponentModel.IComponent.Disposed event of a component. More...
|
|
Controls playback of a sound from a .wav file.
Definition at line 16 of file SoundPlayer.cs.
◆ 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
-
soundLocation | The location of a .wav file to load. |
- Exceptions
-
T:System.UriFormatException | The 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
-
stream | A T:System.IO.Stream to a .wav file. |
Definition at line 319 of file SoundPlayer.cs.
◆ SoundPlayer() [4/4]
Initializes a new instance of the T:System.Media.SoundPlayer class.
- Parameters
-
serializationInfo | The T:System.Runtime.Serialization.SerializationInfo to be used for deserialization. |
context | The destination to be used for deserialization. |
- Exceptions
-
T:System.UriFormatException | The P:System.Media.SoundPlayer.SoundLocation specified in serializationInfo cannot be resolved. |
Definition at line 329 of file SoundPlayer.cs.
◆ Load()
void System.Media.SoundPlayer.Load |
( |
| ) |
|
Loads a sound synchronously.
- Exceptions
-
T:System.ServiceProcess.TimeoutException | The elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout. |
T:System.IO.FileNotFoundException | The 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.TimeoutException | The elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout. |
T:System.IO.FileNotFoundException | The file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found. |
Definition at line 357 of file SoundPlayer.cs.
◆ OnLoadCompleted()
Raises the E:System.Media.SoundPlayer.LoadCompleted event.
- Parameters
-
e | An 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
-
e | An 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
-
e | An 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.TimeoutException | The elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout. |
T:System.IO.FileNotFoundException | The file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found. |
T:System.InvalidOperationException | The .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.TimeoutException | The elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout. |
T:System.IO.FileNotFoundException | The file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found. |
T:System.InvalidOperationException | The .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.TimeoutException | The elapsed time during loading exceeds the time, in milliseconds, specified by P:System.Media.SoundPlayer.LoadTimeout. |
T:System.IO.FileNotFoundException | The file specified by P:System.Media.SoundPlayer.SoundLocation cannot be found. |
T:System.InvalidOperationException | The .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.
◆ 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.
◆ 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
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
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 |
The documentation for this class was generated from the following file: