Peter Larsson
2003-10-12 05:59:24 UTC
Hi,
I'm trying to use the PlaySound function in VB.NET to play two sound files
simultaneously. We have one "theme song" that is being played throughout the
whole execution of the program, but then we also want to add separate sounds
when certain events occur. For the theme song, we're using the following
class/sub:
Public Class SoundClass
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 As Integer = &H0 ' play synchronously
Public Const SND_ASYNC As Integer = &H1 ' play asynchronously
Public Const SND_FILENAME As Integer = &H20000 ' name is file name
Public Const SND_RESOURCE As Integer = &H40004 ' name is resource name
or atom
Public Const SND_LOOP As Integer = &H8 ' Loop sound continuously (used
with SND_ASYNC)
Public Const SND_NOSTOP As Integer = &H10 ' don't stop any currently
playing sound
Public Const SND_NOWAIT As Integer = &H2000 ' don't wait if the driver
is busy
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC Or
SND_LOOP )
End Sub
End Class
And we're invoking the PlaySound sub by:
PlaySound("C:\soundfile.wav")
The question now is how we can make this work with another sound file
simultaneously?
Thank you in advance for any suggestions/solutions!
Peter Larsson
I'm trying to use the PlaySound function in VB.NET to play two sound files
simultaneously. We have one "theme song" that is being played throughout the
whole execution of the program, but then we also want to add separate sounds
when certain events occur. For the theme song, we're using the following
class/sub:
Public Class SoundClass
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 As Integer = &H0 ' play synchronously
Public Const SND_ASYNC As Integer = &H1 ' play asynchronously
Public Const SND_FILENAME As Integer = &H20000 ' name is file name
Public Const SND_RESOURCE As Integer = &H40004 ' name is resource name
or atom
Public Const SND_LOOP As Integer = &H8 ' Loop sound continuously (used
with SND_ASYNC)
Public Const SND_NOSTOP As Integer = &H10 ' don't stop any currently
playing sound
Public Const SND_NOWAIT As Integer = &H2000 ' don't wait if the driver
is busy
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC Or
SND_LOOP )
End Sub
End Class
And we're invoking the PlaySound sub by:
PlaySound("C:\soundfile.wav")
The question now is how we can make this work with another sound file
simultaneously?
Thank you in advance for any suggestions/solutions!
Peter Larsson