|
-
Oct 17th, 2002, 02:41 PM
#1
Thread Starter
Member
Sounds
How can I get my program to play a sound when I press a key, or click somewhere? Like:
If keycode = 17 then
'play sound
end if
end sub
-
Oct 17th, 2002, 02:53 PM
#2
Enter this in a code module:
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_ASYNC = &H1 ' play asynchronously
and call it fram the form like this:
sndPlaySound soundName, SND_ASYNC
where soundName is a string holding the directory and filename of your wav file...
-
Oct 17th, 2002, 04:33 PM
#3
Hyperactive Member
it depends on what type of sound you want to play if you just want to make a windows beep type in Beep other wise youll have to use the code in the above post unless their are other ways i dont know of.
-
Oct 17th, 2002, 04:34 PM
#4
There is many ways to do a thing, but wav files....my way...beeps...dogfish227s way...would probably be the best for your game...
-
Oct 18th, 2002, 10:17 AM
#5
Thread Starter
Member
Yea, i already have sounds added that way, but what i want is some back ground music, and since MP3 is the only kind i have, is there a way to add that, and so the game doesnt actualy stop while its playing?
-
Oct 18th, 2002, 01:05 PM
#6
DirectShow should be able to play MP3 in the background.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 18th, 2002, 05:22 PM
#7
Thread Starter
Member
-
Oct 18th, 2002, 07:56 PM
#8
Sleep mode
lol ,
he means Direct Sound
which contains huge api functions giving you full control of the sound card , even its memory .
-
Oct 19th, 2002, 06:38 AM
#9
When I say DirectShow then I mean DirectShow.
DirectSound is not capable of playing MP3s without you writing the decoder. But DirectShow is capable of reading and playing MP3s.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 19th, 2002, 07:26 AM
#10
Good Ol' Platypus
I might also suggest FMod, get your feet wet with professional sound features without going into DirectX 
www.fmod.org
It can play wave, ogg vorbis, mp3, pcm, etc. and it's free if your app is.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|