|
-
Jun 1st, 2000, 11:22 PM
#1
Thread Starter
Hyperactive Member
I've loaded a wav file into a res file and I want to play it from my code.
It's loaded into a res file as "WAV" type, and read from a a .wav file.
This is what I've done:
eepSound = LoadResData(101, "WAV")
sndPlaySound eepSound, SND_NODEFAULT Or SND_ASYNC
However, I don't get any sound played.
Anybody want to clue me in as to how to load a wav file into a res file and then play it?
Thanks!
-
Jun 2nd, 2000, 01:37 AM
#2
This is what I use:
' the declares
Public Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Const SND_ASYNC = &H1 ' Play asynchronously
Public Const SND_NODEFAULT = &H2 ' Don't use default sound
Public Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
' play the sound
Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(101, "ATM_SOUND"), vbUnicode)
retVal = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
-
Jun 2nd, 2000, 01:59 AM
#3
Thread Starter
Hyperactive Member
Works Great!
Frans C -
Your solution works well!
Thanks a bunch!
-
Aug 10th, 2000, 03:37 AM
#4
Junior Member
I used the compiler on the vb5 cd and compiled a wav into a resource file, but vb5 tells me that no resource by the identifier i gave it exists!
Also, here's a little info from http://www.vbapi.com regarding the newer Playsound api call:
PlaySound
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Alternate Declare for when using a resource or memory location:
Declare Function PlaySound_Res Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As Long, ByVal hModule As Long, ByVal dwFlags As Long) As Long
lpszName
The name or some other identifier of the sound. Its exact format depends on the flags passed as dwFlags.
hModule
A handle to the application module containing the sound resource the play, if needed. If the function does not need this information, pass 0 for this parameter.
What exactly is a module handle? I know about window handles, but have never heard of module handles! (this api call would be a simpler way of doing the sound playing work...)
-
Aug 10th, 2000, 03:45 AM
#5
Junior Member
I just looked at vb help, it says that the max that LoadResData will load is 64k, however the sound I have in my .res file is 1.2mb! (very long sound file) could this be why loadresdata isn't seeing the resource??
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
|