Share via


SoundPlayer 构造函数

定义

初始化 SoundPlayer 类的新实例。

重载

SoundPlayer()

初始化 SoundPlayer 类的新实例。

SoundPlayer(Stream)

初始化 SoundPlayer 类的新实例,并在指定的 Stream 内附加 .wav 文件。

SoundPlayer(String)

初始化 SoundPlayer 类的新实例,并附加指定的 .wav 文件。

SoundPlayer(SerializationInfo, StreamingContext)
已过时.

初始化 SoundPlayer 类的新实例。

SoundPlayer()

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

初始化 SoundPlayer 类的新实例。

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

注解

此构造函数初始化 SoundPlayer 没有音频源的 。 在配置音频源路径之前, SoundPlayer 在调用其播放方法之一时将播放蜂鸣声。

另请参阅

适用于

SoundPlayer(Stream)

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

初始化 SoundPlayer 类的新实例,并在指定的 Stream 内附加 .wav 文件。

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)

参数

stream
Stream

.wav 文件的 Stream

注解

Stream传递给 参数的 stream 应该是一个Stream包含 .wav 文件的 。 的 Read 方法 Stream 返回的数据应该是.wav文件中的数据。

另请参阅

适用于

SoundPlayer(String)

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

初始化 SoundPlayer 类的新实例,并附加指定的 .wav 文件。

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 文件的位置。

例外

无法解析由 soundLocation 指定的 URL 值。

注解

传递给 参数的 soundLocation 字符串可以是文件路径,也可以是.wav文件的 URL。 如果路径或 URL 无效, SoundPlayer 仍将构造 ,但对 load 或 play 方法的后续调用将失败。

另请参阅

适用于

SoundPlayer(SerializationInfo, StreamingContext)

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

注意

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

初始化 SoundPlayer 类的新实例。

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)

参数

serializationInfo
SerializationInfo

要用于反序列化的 SerializationInfo

context
StreamingContext

用于反序列化的目标。

属性

例外

无法解析 serializationInfo 中指定的 SoundLocation

另请参阅

适用于