Where did you find that? The name doesn't matter when you are calling a .dll, but I've never seen PlayWave. Are you trying to track how many people copy your post?
VB Code:
Option Explicit
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
When I try to put that declare function Playsounds thing in the form code, it said I can have only comments after end function. When i put it in a module, when I try to use the function, it can't find it. I'm so confused. Also, I'm trying to use nBass to have my program play mp3 and wma files. I dunno how to get it to play my music. Plz help
I just added two option buttons, and while the wav was looping, was able to click on both of them. I could also tab between the three controls while it was playing. There must be something in your code.
No way am I gonna use option buttons or command buttons or etc. Yeah, I know you could click on them while the wav is playing but I wanna make this one work...
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyDown) <> 0 Then
If Image2.top <> 480 Then
Image2.top = Image2.top + 48
Else
Image2.top = Image2.top - 96
End If
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", 0, SND_SYNC
ElseIf GetAsyncKeyState(vbKeyUp) <> 0 Then
If Image2.top <> 384 Then
Image2.top = Image2.top - 48
Else
Image2.top = Image2.top + 96
End If
PlaySound "C:\WINDOWS\MEDIA\TADA.WAV", 0, SND_SYNC
End If
If GetAsyncKeyState(vbKeyReturn) <> 0 And Image2.top = 480 Then
RetValue = ChangeRes(1280, 800, 32)
End
ElseIf GetAsyncKeyState(vbKeyReturn) <> 0 And Image2.top = 432 Then
LoadScreen.Show
Unload TitleScreen
End If
End Sub
You use the SND_SYNC flag in your PlaySound call which means the function doesn't return until the wave file has finished playing, so no other code you use can run. Use the SND_ASYNC flag instead.
That is 10 times per second. Change it to 1000 (one second) to see if that fixes things. The timer can't reference less than 10ms, and there is no way for the user to click that fast. If that works, you could try 750, or 500.
It also takes time to move the image. The timer fires again and again, but can't do anything in the time you've given it.
In the project you posted you don't play any sound files. Did you change the call to PlaySound to use the SND_ASYNC flag instead of SND_SYNC? I don't think the Interval of the Timer is especially relevant to this issue.