How to Play a .wav Sound or System Sound
The My.Computer.Audio.Play and My.Computer.Audio.PlaySystemSound methods can be used to play .wav sound files and system sounds.
My.Computer.Audio.Play(FileName, AudioPlayMode.Background)
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Asterisk)
Sample Code
Dim dr As DialogResult
Dim OpenFileDialogWav As New OpenFileDialog
OpenFileDialogWav.Filter = "Sound files (.wav)|*.wav"
dr = OpenFileDialogWav.ShowDialog()
If dr <> Windows.Forms.DialogResult.OK Then
Exit Sub
End If
My.Computer.Audio.Play(OpenFileDialogWav.FileName, AudioPlayMode.Background)
To use the sample code, create a Windows Forms project and paste the code into a Button on the default form.
Download Sample Project
Also See
How to Play a .wma, .mp3 or other Music
How to Host Windows Media Player to Play Music & Video
All code examples on this site have been developed for .Net Framework 3.5 | |||