Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Revisiting the wave file...how do you STOP one?

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
I recently asked for help with the following:
Code:
WavFileName = "c:\mywavefile.wav"
x = sndPlaySound(WavFileName, &H0)
That's my code. The particular wave file runs for about 1 minute. I asked the question, "Is there any way to allow a user to interrupt the wave file while it's playing? Also, while the file is playing, the application is locked up. Is it possible to free it, like with some variation of DoEvents so the user can use the app while the wave file is playing?"
I received this answer:
Code:
sndPlaySound( LPCSTR lpszSound, UINT fuSound );
fuSound = SND_ASYNC
I can't figure this out. I replaced my code:
Code:
x=sndPlaySound(WavFileName, &H0)
with the new suggested code,
Code:
x=sndPlaySound( LPCSTR lpszSound, UINTfuSound )
and I get an error message that says
Code:
Compile Error
Expected: list separator or )
before I even run the code
Also, what do I do with the part of the new code that reads:
Code:
fuSound = SND_ASYNC
?
Thanks for you help again!!!!
Mike Kemp
kempmike65@aol.com
 
here is the Full version of the .WAV file player routine.

So if it can be shortened then it might be using a different paramter at the end of the Play command line

' ----------------------- Put this in a Module ----------------
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
' for playing sounds (each one is listed below in detail)
Global Const KEY_RETURN = &HD
Global Const SND_SYNC = &H0
Global Const SND_ASYNC = &H1
Global Const SND_NODEFAULT = &H2
Global Const SND_LOOP = &H8
Global Const SND_NOSTOP = &H10
'---------------------------------------------------------------

'----------------- Put this in a sub to play a wav file ---------
wFlags% = SND_SYNC
SoundName$ = App.Path & "wav-file\THEADER.WAV"
x% = sndPlaySound(SoundName$, wFlags%)

one line
x% = sndPlaySound("c:\wavs\beep.wav", &H0)
'----------------------------------------------------------------

'----------------------- PLay numbers in a sequnce --------------
For a = 1 To Len(Text1)
SoundName$ = GetWaveFile(Mid$(Text1, a, 1))
wFlags% = SND_SYNC
x% = sndPlaySound(SoundName$, wFlags%)
Next
'------------------------------------------------------------------

'--------------- function needed for above to play numbers---------
Function GetWaveFile(Info)
FileFront$ = "C:\TIME-IS\Wav-file\"
Select Case Int(Info)
Case 1 To 50
WaveName = "ta" & LTrim$(Str$(Info)) & ".wav"
Case Else
WaveName = "ta" & LTrim$(Str$(Info)) & ".wav"
End Select

GetWaveFile = FileFront$ & WaveName
Debug.Print GetWaveFile
End Function
'------------------------------------------------------------------



' Specifies options for playing the sound using one or more of the following flags:
' SND_SYNC
' The sound is played synchronously and the function does
' not return until the sound ends.

' SND_ASYNC
' The sound is played asynchronously and the function
' returns immediately after beginning the sound.

' SND_NODEFAULT
' If the sound cannot be found, the function returns
' silently without playing the default sound.

' SND_LOOP
' The sound will continue to play repeatedly until

' sndPlaySound is called again with the lpszSoundName$
' parameter set to null. You must also specify the
' SND_ASYNC flag to loop sounds.

' SND_NOSTOP
' If a sound is currently playing, the function will
' immediately return False without playing the requested
' sound.



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top