PDA

Click to See Complete Forum and Search --> : Music


firemage80
Mar 19th, 2002, 11:43 AM
Hey, what's the code to have music repeating in the background? You know, like in games. And I still need help in my "Option Box" question.

firemage80
Mar 19th, 2002, 12:16 PM
there are multiple people on 1 IP adress using this account. Thats why theres so many questions from me :)

spyplayer
Mar 20th, 2002, 12:06 AM
'SoundPlayWorks


'Modual

Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

' flag values for uFlags parameter
Public Const SND_SYNC = &H0 ' play synchronously (default)
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Public Const SND_NODEFAULT = &H2 ' silence not default, if sound not found

Public Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Public Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest
Public Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
Public Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
Public Const SRCERASE = &H440328




'Code''''''''''''''''''''''''''''''''''''''''''''''''''


Private Sub Form_Load()
j = sndPlaySound(App.Path + "\Needle.wav", SND_ASYNC Or SND_LOOP)'Makes the music loop, delete the Or SND_LOOP if you do not want the music to keep on playing
End Sub


'I would also add this code into the form terminate and stuff like that because if you dont and the program quits on accident, it will keep on playing the music... heh
Private Sub Form_Unload(Cancel As Integer)
j = sndPlaySound(vbNullString, SND_ASYNC)
End Sub



'YOU MIGHT HAVE TO ADJUSTS SOME THINGS TO FIT ON ONE LINE:p