1
my.Computer.Audio.Play()
支持不同的模式
AudioPlayMode.Background
在后台播放声音。调用代码继续执行。
AudioPlayMode.BackgroundLoop
在后台播放声音,直到调用 My.Computer.Audio.Stop 方法。调用代码继续执行。
AudioPlayMode.WaitToComplete
播放声音并等待播放完毕,然后再继续执行调用代码。
http://msdn.microsoft.com/zh-cn/asp.net/cf1shcah(VS.80).aspx有详细说明
2
http://dobon.net/vb/dotnet/programing/playwavfile.html
.Net Framework2.0以后
Private player As System.Media.SoundPlayer = Nothing
'WAVEファイルを再生する
Private Sub PlaySound(ByVal waveFile As String)
'再生されているときは止める
If Not (player Is Nothing) Then
StopSound()
End If
'読み込む
player = New System.Media.SoundPlayer(waveFile)
'非同期再生する
player.Play()
'次のようにすると、ループ再生される
'player.PlayLooping()
'次のようにすると、最後まで再生し終えるまで待機する
'player.PlaySync()
End Sub
'再生されている音を止める
Private Sub StopSound()
If Not (player Is Nothing) Then
player.Stop()
player.Dispose()
player = Nothing
End If
End Sub
'Button1のClickイベントハンドラ
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles Button1.Click
PlaySound("C:/music.wav")
End Sub
'Button2のClickイベントハンドラ
Private Sub Button2_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button2.Click
StopSound()
End Sub
3 声音的连续播放
'該当再生リストの再生
Dim myProcess As Process = New Process
Dim a As New ProcessStartInfo("mplay32.exe")
Try
‘PlayList ,you can create by MediaPlay
‘You can play a wav file certainly
myProcess.StartInfo.FileName = "c:/temp.wpl"
myProcess.Start()
Catch
End Try