Monday, April 7, 2008

Extras - Sound

Below is the code for the sound. You will have to replace the red text below with the sound file's name (remember that if you put the sound files in your debug folder you can access it with only the name and not the entire path). Note: This only works with .wav files:


'Alex Maureau, Queens College
'Credits:
'http://www.codeproject.com/vb/net/SoundClass.asp
'by Angelo Cresta


Imports System
Imports System.Runtime.InteropServices
Imports System.Resources
Imports System.IO

Public Class Sound


Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, _
ByVal flags As Integer) As Integer

Public Const SND_SYNC = &H0 'play synchronously
Public Const SND_ASYNC = &H1 'play asynchronously
Public Const SND_LOOP = &H8 'play with a loop

Public Shared Sub PlayWaveFile( _
ByVal fileWaveFullPath As String)
Try
PlaySound(fileWaveFullPath, 0, SND_ASYNC)
Catch
End Try
End Sub
End Class

No comments: