SoundPlayer 建構函式

定義

初始化 SoundPlayer 類別的新執行個體。

多載

SoundPlayer()

初始化 SoundPlayer 類別的新執行個體。

SoundPlayer(Stream)

初始化 SoundPlayer 類別的新執行個體,並將 .wav 檔附加到指定的 Stream 中。

SoundPlayer(String)

初始化 SoundPlayer 類別的新執行個體,並附加指定的 .wav 檔。

SoundPlayer(SerializationInfo, StreamingContext)
已淘汰.

初始化 SoundPlayer 類別的新執行個體。

SoundPlayer()

來源:
SoundPlayer.cs
來源:
SoundPlayer.cs
來源:
SoundPlayer.cs

初始化 SoundPlayer 類別的新執行個體。

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

備註

這個建構函式會 SoundPlayer 初始化沒有音訊來源的 。 在設定音訊來源路徑之前,呼叫 SoundPlayer 其中一個播放方法時,會播放擷取音效。

另請參閱

適用於

SoundPlayer(Stream)

來源:
SoundPlayer.cs
來源:
SoundPlayer.cs
來源:
SoundPlayer.cs

初始化 SoundPlayer 類別的新執行個體,並將 .wav 檔附加到指定的 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)

參數

stream
Stream

到 .wav 檔的 Stream

備註

Stream傳遞至 參數的 stream 應該是包含Stream.wav檔案的 。 方法所傳ReadStream回的數據應該是.wav檔案內的數據。

另請參閱

適用於

SoundPlayer(String)

來源:
SoundPlayer.cs
來源:
SoundPlayer.cs
來源:
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 仍會建構 ,但對載入或播放方法的後續呼叫將會失敗。

另請參閱

適用於

SoundPlayer(SerializationInfo, StreamingContext)

來源:
SoundPlayer.cs
來源:
SoundPlayer.cs
來源:
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

要用於還原序列化 (Deserialization) 的 SerializationInfo

context
StreamingContext

要用於還原序列化的目的端。

屬性

例外狀況

無法解析在 serializationInfo 中所指定的 SoundLocation

另請參閱

適用於