SoundPlayer.Load 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
同步載入聲音。
public:
void Load();
public void Load();
member this.Load : unit -> unit
Public Sub Load ()
例外狀況
載入期間經過的時間超過以 LoadTimeout毫秒為單位的時間。
找不到所 SoundLocation 指定的檔案。
範例
以下程式碼範例示範如何使用此 LoadAsync 方法將 .wav 檔案附加到類別的 SoundPlayer 實例中。 此程式碼範例是本類別更大範例 SoundPlayer 的一部分。
try
{
// Assign the selected file's path to
// the SoundPlayer object.
player->SoundLocation = filepathTextbox->Text;
// Load the .wav file.
player->Load();
}
catch ( Exception^ ex )
{
ReportStatus( ex->Message );
}
try
{
// Assign the selected file's path to
// the SoundPlayer object.
player.SoundLocation = filepathTextbox.Text;
// Load the .wav file.
player.Load();
}
catch (Exception ex)
{
ReportStatus(ex.Message);
}
Try
' Assign the selected file's path to the SoundPlayer object.
player.SoundLocation = filepathTextbox.Text
' Load the .wav file.
player.Load()
Catch ex As Exception
ReportStatus(ex.Message)
End Try
備註
此 Load 方法利用當前執行緒載入 .wav 檔案,阻止執行緒在載入完成前處理其他訊息。
此方法在載入完成時會 LoadCompleted 觸發事件,即使載入未成功。