SoundPlayer 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 SoundPlayer 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| SoundPlayer() |
初始化 SoundPlayer 類別的新執行個體。 |
| SoundPlayer(Stream) |
初始化該類別的新實例 SoundPlayer ,並將.wav檔案附加於指定的 Stream。 |
| SoundPlayer(String) |
初始化該類別的新實例 SoundPlayer ,並附加指定的 .wav 檔案。 |
| SoundPlayer(SerializationInfo, StreamingContext) |
已淘汰.
初始化 SoundPlayer 類別的新執行個體。 |
SoundPlayer()
初始化 SoundPlayer 類別的新執行個體。
public:
SoundPlayer();
public SoundPlayer();
Public Sub New ()
備註
此建構子初始 SoundPlayer 化時沒有音訊來源。 在設定音訊來源路徑之前,當呼叫其中一種播放方法時,會 SoundPlayer 播放嗶聲。
另請參閱
適用於
SoundPlayer(Stream)
初始化該類別的新實例 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的 應該是Stream包含一個 .wav 檔案。 該方法Read回傳Stream的資料應該是.wav檔案中的資料。
另請參閱
適用於
SoundPlayer(String)
初始化該類別的新實例 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。 如果路徑或網址不有效,仍會建構, SoundPlayer 但後續呼叫載入或播放方法會失敗。
另請參閱
適用於
SoundPlayer(SerializationInfo, StreamingContext)
警告
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);
[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);
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}")>]
new System.Media.SoundPlayer : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Media.SoundPlayer
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
用於反序列化的目的地。
- 屬性
例外狀況
在中SoundLocation指定的 無法serializationInfo解決。