SoundPlayer.PlaySync Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
.wav dosyasını çalar ve yüklenmemişse önce .wav dosyasını yükler.
public:
void PlaySync();
public void PlaySync();
member this.PlaySync : unit -> unit
Public Sub PlaySync ()
Özel durumlar
Yükleme sırasında geçen süre, tarafından LoadTimeoutbelirtilen süreyi milisaniye cinsinden aşıyor.
tarafından SoundLocation belirtilen dosya bulunamıyor.
.wav üst bilgisi bozuk; tarafından SoundLocation belirtilen dosya bir PCM .wav dosyası değil.
Örnekler
Aşağıdaki kod örneği, bir .wav dosyasını zaman uyumlu bir şekilde yürütmek için yönteminin kullanımını PlaySync gösterir.
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
Açıklamalar
PlaySync yöntemi geçerli iş parçacığını kullanarak .wav bir dosyayı yürüterek iş parçacığının yükleme tamamlanana kadar diğer iletileri işlemesini engeller. .wav dosyasını önceden belleğe yüklemek için veya LoadAsync yöntemini kullanabilirsinizLoad. bir .wav dosyası veya URL'den Stream başarıyla yüklendikten sonra, ses yolu değişene SoundPlayer kadar .wav dosyasının yeniden yüklenmesi gerekmeyecek.
.wav dosyası belirtilmemişse veya yüklenemezse PlaySync , yöntem varsayılan bip sesini çalar.