SoundPlayer 构造函数

定义

初始化 SoundPlayer 类的新实例。Initializes a new instance of the SoundPlayer class.

重载

SoundPlayer()

初始化 SoundPlayer 类的新实例。Initializes a new instance of the SoundPlayer class.

SoundPlayer(Stream)

初始化 SoundPlayer 类的新实例,并在指定的 Stream 内附加 .wav 文件。Initializes a new instance of the SoundPlayer class, and attaches the .wav file within the specified Stream.

SoundPlayer(String)

初始化 SoundPlayer 类的新实例,并附加指定的 .wav 文件。Initializes a new instance of the SoundPlayer class, and attaches the specified .wav file.

SoundPlayer(SerializationInfo, StreamingContext)

初始化 SoundPlayer 类的新实例。Initializes a new instance of the SoundPlayer class.

SoundPlayer()

初始化 SoundPlayer 类的新实例。Initializes a new instance of the SoundPlayer class.

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

注解

此构造函数初始化 SoundPlayer 不带音频源的。This constructor initializes a SoundPlayer with no audio source. 在将其配置为使用音频源路径之前, SoundPlayer 将在其中一种播放方法发出嘟嘟声。Until it is configured with an audio source path, the SoundPlayer will play a beep sound when one of its playback methods is called.

适用于

SoundPlayer(Stream)

初始化 SoundPlayer 类的新实例,并在指定的 Stream 内附加 .wav 文件。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);
new System.Media.SoundPlayer : System.IO.Stream -> System.Media.SoundPlayer
Public Sub New (stream As Stream)

参数

stream
Stream

.wav 文件的 StreamA Stream to a .wav file.

注解

Stream传递给参数的 stream 应为 Stream 包含 .wav 文件的。The Stream passed to the stream parameter should be a Stream containing a .wav file. 的方法返回的数据 Read Stream 应是 .wav 文件中的数据。The data returned by the Read method of the Stream should be the data within a .wav file.

适用于

SoundPlayer(String)

初始化 SoundPlayer 类的新实例,并附加指定的 .wav 文件。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)

参数

soundLocation
String

要加载的 .wav 文件的位置。The location of a .wav file to load.

例外

无法解析由 soundLocation 指定的 URL 值。The URL value specified by soundLocation cannot be resolved.

注解

传递给参数的字符串 soundLocation 可以是文件路径,也可以是 .wav 文件的 URL。The string passed to the soundLocation parameter can be either a file path or a URL to a .wav file. 如果路径或 URL 无效, SoundPlayer 仍将构造,但对 load 或 play 方法的后续调用将失败。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.

适用于

SoundPlayer(SerializationInfo, StreamingContext)

初始化 SoundPlayer 类的新实例。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);
new System.Media.SoundPlayer : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Media.SoundPlayer
Protected Sub New (serializationInfo As SerializationInfo, context As StreamingContext)

参数

serializationInfo
SerializationInfo

要用于反序列化的 SerializationInfoThe SerializationInfo to be used for deserialization.

context
StreamingContext

用于反序列化的目标。The destination to be used for deserialization.

例外

无法解析 serializationInfo 中指定的 SoundLocationThe SoundLocation specified in serializationInfo cannot be resolved.

适用于