SoundPlayer.PlaySync 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
.wav 파일을 재생하고 로드되지 않은 경우 먼저 .wav 파일을 로드합니다.
public:
void PlaySync();
public void PlaySync();
member this.PlaySync : unit -> unit
Public Sub PlaySync ()
예외
로드하는 동안 경과된 시간이 지정한 시간(밀리초)을 초과합니다 LoadTimeout.
지정한 SoundLocation 파일을 찾을 수 없습니다.
.wav 헤더가 손상되었습니다. 지정한 SoundLocation 파일이 PCM .wav 파일이 아닙니다.
예제
다음 코드 예제에서는 메서드를 사용하여 PlaySync .wav 파일을 동기적으로 재생하는 방법을 보여 줍니다.
private:
SoundPlayer^ Player;
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();
}
void Player_LoadCompleted( Object^ /*sender*/, System::ComponentModel::AsyncCompletedEventArgs^ /*e*/ )
{
if (this->Player->IsLoadCompleted)
{
this->Player->PlaySync();
}
}
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();
}
}
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.PlaySync()
End If
End Sub
설명
이 메서드는 PlaySync 현재 스레드를 사용하여 .wav 파일을 재생하여 로드가 완료될 때까지 스레드가 다른 메시지를 처리하지 못하도록 합니다. 또는 LoadAsync 메서드를 Load 사용하여 .wav 파일을 메모리에 미리 로드할 수 있습니다. .wav 파일이 a 또는 URL에서 Stream 성공적으로 로드된 후에는 소리에 대한 SoundPlayer 경로가 변경될 때까지 .wav 파일을 다시 로드할 필요가 없습니다.
.wav 파일이 지정되지 않았거나 로드에 실패하면 메서드가 PlaySync 기본 경고음 소리를 재생합니다.