Edit

Bagikan melalui


SoundPlayer Constructors

Definition

Initializes a new instance of the SoundPlayer class.

Overloads

SoundPlayer()

Initializes a new instance of the SoundPlayer class.

SoundPlayer(Stream)

Initializes a new instance of the SoundPlayer class, and attaches the .wav file within the specified Stream.

SoundPlayer(String)

Initializes a new instance of the SoundPlayer class, and attaches the specified .wav file.

SoundPlayer(SerializationInfo, StreamingContext)
Obsolete.

Initializes a new instance of the SoundPlayer class.

SoundPlayer()

Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs

Initializes a new instance of the SoundPlayer class.

public:
 SoundPlayer();
public SoundPlayer ();
Public Sub New ()

Remarks

This constructor initializes a SoundPlayer with no audio source. Until it is configured with an audio source path, the SoundPlayer will play a beep sound when one of its playback methods is called.

See also

Applies to

SoundPlayer(Stream)

Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs

Initializes a new instance of the SoundPlayer class, and attaches the .wav file within the specified Stream.

public:
 SoundPlayer(System::IO::Stream ^ stream);
public SoundPlayer (System.IO.Stream? stream);
public SoundPlayer (System.IO.Stream stream);
new System.Media.SoundPlayer : System.IO.Stream -> System.Media.SoundPlayer
Public Sub New (stream As Stream)

Parameters

stream
Stream

A Stream to a .wav file.

Remarks

The Stream passed to the stream parameter should be a Stream containing a .wav file. The data returned by the Read method of the Stream should be the data within a .wav file.

See also

Applies to

SoundPlayer(String)

Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs

Initializes a new instance of the SoundPlayer class, and attaches the specified .wav file.

public:
 SoundPlayer(System::String ^ soundLocation);
public SoundPlayer (string soundLocation);
new System.Media.SoundPlayer : string -> System.Media.SoundPlayer
Public Sub New (soundLocation As String)

Parameters

soundLocation
String

The location of a .wav file to load.

Exceptions

The URL value specified by soundLocation cannot be resolved.

Remarks

The string passed to the soundLocation parameter can be either a file path or a URL to a .wav file. If the path or URL is not valid, the SoundPlayer will still be constructed, but subsequent calls to a load or play method will fail.

See also

Applies to

SoundPlayer(SerializationInfo, StreamingContext)

Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs
Source:
SoundPlayer.cs

Caution

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Initializes a new instance of the SoundPlayer class.

protected:
 SoundPlayer(System::Runtime::Serialization::SerializationInfo ^ serializationInfo, System::Runtime::Serialization::StreamingContext context);
protected SoundPlayer (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected SoundPlayer (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context);
new System.Media.SoundPlayer : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Media.SoundPlayer
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Media.SoundPlayer : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Media.SoundPlayer
Protected Sub New (serializationInfo As SerializationInfo, context As StreamingContext)

Parameters

serializationInfo
SerializationInfo

The SerializationInfo to be used for deserialization.

context
StreamingContext

The destination to be used for deserialization.

Attributes

Exceptions

The SoundLocation specified in serializationInfo cannot be resolved.

See also

Applies to