SoundPlayer.PlaySync メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SoundPlayer.PlaySync メソッドの意味・解説 

SoundPlayer.PlaySync メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

ユーザー インターフェイス (UI) スレッドを使用して .wav ファイルを再生します。.wav ファイルが読み込まれていない場合は、まずそのファイルを読み込みます。

名前空間: System.Media
アセンブリ: System (system.dll 内)
構文構文

Dim instance As SoundPlayer

instance.PlaySync
public void PlaySync ()
public:
void PlaySync ()
public void PlaySync ()
例外例外
例外の種類条件

TimeoutException

読み込み時の経過時間が、LoadTimeout で指定された時間 (ミリ秒単位) を超過しました。

FileNotFoundException

SoundLocation で指定したファイルが見つかりません。

InvalidOperationException

.wav ヘッダーが破損しています。SoundLocation で指定したファイルは、PCM .wav ファイルではありません。

解説解説
使用例使用例

PlaySync メソッドを使用して、.wav ファイルを同期的に再生するコード例を次に示します。

Private WithEvents Player As
 New SoundPlayer

Sub LoadSoundAsync()
    ' Note: You may need to change the location specified based on
    ' the location of the sound to be played.
    Me.Player.SoundLocation = "http://www.tailspintoys.com/sounds/stop.wav"
    Me.Player.LoadAsync ()
End Sub

Private Sub PlayWhenLoaded(ByVal
 sender As Object, ByVal
 e As _
    System.ComponentModel.AsyncCompletedEventArgs) Handles _
    Player.LoadCompleted
    If Me.Player.IsLoadCompleted = True
 Then
        Me.Player.Play()
    End If
End Sub
private SoundPlayer Player = new SoundPlayer();
private void loadSoundAsync()
{
    // Note: You may need to change the location specified based on
    // the location of the sound to be played.
    this.Player.SoundLocation = "http://www.tailspintoys.com/sounds/stop.wav";
    this.Player.LoadAsync();
}

private void Player_LoadCompleted (
    object sender, 
    System.ComponentModel.AsyncCompletedEventArgs e)
{
    if (this.Player.IsLoadCompleted)
    {
        this.Player.PlaySync();
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

SoundPlayer.PlaySync メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SoundPlayer.PlaySync メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS