(Mouse)activity while playing a wave-file

G

Guest

Thanks to the discussion in the "Sound button"-thread I can
play more than one piece of WAV-music under the same button. Magic !

As global functiondeclaration I use the recommanded script of
http://www.mvps.org/access/api/api0011.htm
For more wavs under one button I use a case-script. Works just fine !

Now I'd like students to answer questions by clicking radiobuttons while a
wave-file is playing.
There I have a problem: When a wavefile is playing there is no other
(mouse)activity possible. Can you please help me solve this problem ?
 
R

RuralGuy

Thanks to the discussion in the "Sound button"-thread I can
play more than one piece of WAV-music under the same button. Magic !

As global functiondeclaration I use the recommanded script of
http://www.mvps.org/access/api/api0011.htm
For more wavs under one button I use a case-script. Works just fine !

Now I'd like students to answer questions by clicking radiobuttons while a
wave-file is playing.
There I have a problem: When a wavefile is playing there is no other
(mouse)activity possible. Can you please help me solve this problem ?

Hi Eric,
Are you using the Async play mode?
Public Const pcsASYNC = 1 ' don't wait for finish
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
R

RuralGuy

Hi RuralGuy
Thanks for responding.
I created a new Module, named basPlaySounds, and put the complete
ProgramCode of http://www.mvps.org/access/api/api0011.htm in it, with indeed
Public Const pcsASYNC = 1 ' don't wait for finish

greetings eric

Hi Eric,
Here's a link that uses a different call into the dll. See if it will work for
you. http://allenbrowne.com/func-04.html
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
G

Guest

Hi RG
Thank you again for responding and pointing to the programcode.
I'm puzzled very much about how to implement this code

I understand I have to use this part:

Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long

Function PlaySound(sWavFile As String)
End Function

My buttoncode is:
Private Sub butMusic_Click()
Select Case txtQuestionID
Case 1
fPlayStuff ("C:\rsSound01.wav")
Case 2
fPlayStuff ("C:\rsSound02.wav")
End Select
End sub

Is it possible that you show me how to combine the two codes ?
Thank you so much in advance !

greetings
 
D

Douglas J. Steele

As long as you've got the other stuff between Function PlaySound(sWavFile As
String) and End Function, replace fPlayStuff in your existing code with
PlaySound.
 
R

RuralGuy

Hi RG
Thank you again for responding and pointing to the programcode.
I'm puzzled very much about how to implement this code

I understand I have to use this part:

Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long

Function PlaySound(sWavFile As String)
End Function

My buttoncode is:
Private Sub butMusic_Click()
Select Case txtQuestionID
Case 1
fPlayStuff ("C:\rsSound01.wav")
Case 2
fPlayStuff ("C:\rsSound02.wav")
End Select
End sub

Is it possible that you show me how to combine the two codes ?
Thank you so much in advance !

greetings

Listen to Mr.Steele. He knows of what he speaks!
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
G

Guest

Hi Doug,
Thank you for responding
Perhaps you can lead me a little bit further on this ?
(appologies for the lot of text I use)

The declaration "Declare Function apisndPlaySound Lib...." (etc) I put in a
module under the name "basPlaySounds"

Then I tried three setups:
1. First the one I think you pointed out to me:

Function PlaySound(sWavFile As String)
Private Sub butMusic_Click()
PlaySound ("C:\rsSound01.wav")
End Sub
End Function

VB-comment: Compile-error: remarks only alowed after End Sub, End Function
or End Property (I don't see any remarks here !?)


2. Second, I tried the other way around:

Private Sub butMusic_Click()
Function PlaySound(sWavFile As String)
PlaySound ("C:\rsSound01.wav")
End Function
End Sub

Comment VB: End Sub expected before Function Play Sound (done so, but
offcourse then button doesn't get any response at all )

3. Third I tried:

Private Sub butMusic_Click()

"Declare Function apisndPlaySound Lib...." (etc)

Function PlaySound(sWavFile As String)
PlaySound ("C:\rsSound01.wav")
End Function
End Sub

VB-comment: error on evaluating function, event or macro
Comment is referring to Ms Knowledge Base article 283806, but unfortunately
that doesn't make much sense to me.

Can you please shed some light in my darkness (sorry, bit too dramatic)

greetings
 
D

Douglas J. Steele

Create a new module, copy Allen's code and paste it there and save the
module as basPlaySounds. The entire content of the module should be:

Option Compare Database
Option Explicit

Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long


Function PlaySound(sWavFile As String)
' Purpose: Plays a sound.
' Argument: the full path and file name.

If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function


Back in your form, change the code associated with your button to:

Private Sub butMusic_Click()
Call PlaySound ("C:\rsSound01.wav")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top