dimanche 8 février 2015

Play a music in the background vb6

hi i make a small game with vb6 and i need play 2 sound in some time i use this code





Private Declare Function PlaySoundMem Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As Long, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_ASYNC = &H1, SND_MEMORY = &H4, SND_NODEFAULT = &H2, SND_NOSTOP = &H1, SND_NOWAIT = &H2000
Dim Sound() As Byte
Dim x As Integer

Private Sub Form_Load()
On Error Resume Next
Sound = LoadResData("music", "CUSTOM")
Call PlaySoundMem(VarPtr(Sound(0)), 0, SND_NOWAIT Or SND_NODEFAULT Or SND_MEMORY Or SND_ASYNC Or SND_NOSTOP)
DoEvents

End Sub

Private Sub snd()
If nrd.Text = 1 Then
x = 1
snd_hero
ElseIf nrd.Text = 2 Then
x = 2
snd_hero
ElseIf nrd.Text = 3 Then
x = 3
snd_hero
ElseIf nrd.Text = 4 Then
x = 4
snd_hero
ElseIf nrd.Text = 5 Then
x = 5
snd_hero
ElseIf nrd.Text = 6 Then
x = 6
snd_hero
End If
End Sub

Private Sub snd_hero()
On Error Resume Next
Sound = LoadResData(x, "CUSTOM")
Call PlaySoundMem(VarPtr(Sound(0)), 0, SND_NOWAIT Or SND_NODEFAULT Or SND_MEMORY Or SND_ASYNC Or SND_NOSTOP)
DoEvents
ReDim Sound(0)



its play music whin game start but the music stop whin play another sound i need play to sound at some time what i do thanks

Aucun commentaire:

Enregistrer un commentaire