do a search for "button sound" or "sound feedback" or "button click" and you will get a wealth of information plus a load more
:icon_clap:
Have a look at this post from Erel http://www.b4x.com/forum/additional-libraries-official-updates/11816-audio-library-v1-2-beeper.html#post66053
'=============================================
'beeper from audio library
Dim b As Beeper
'---------------------------------------------
'init the beeper noise
b.Initialize(300, 500) '300 milliseconds, 500 hz
'---------------------------------------------
Sub Radio8902a_CheckedChange(Checked As Boolean)
b.Beep
End Sub
Thanks. That does allow a tone, but not the beep associated with the android click. It sounds completely different. So I guess my next question is, "what settings do you use in the bellow to make it sound like an android click?" Millisecs and hertz. Surely someone has done this.
B4X:'============================================= 'beeper from audio library Dim b As Beeper '--------------------------------------------- 'init the beeper noise b.Initialize(300, 500) '300 milliseconds, 500 hz '--------------------------------------------- Sub Radio8902a_CheckedChange(Checked As Boolean) b.Beep End Sub
A quick google search indicates there is a function; "playSoundEffect" within java. It does not appear to be available with B4A, a search shows nothing. You'll have to create your own click sound and use it for all your functions that need to click.
Sub Button_Click
sp.Play(yourSoundObject, 1, 1, 1, 0, 1)
[I]your code here[/I]
End Sub
I'm sure it is a simple command to call the android sound button click noise.
Public Sub PlaySoundEffect(v As View)
Dim r As Reflector
r.Target = v
r.RunMethod2("playSoundEffect",0,"java.lang.int")
End Sub
Dim s As esClickSound
s.Initialize
s.keyclickFx(1)
It's simple with the help of Agrahams Reflection Library:
B4X:Public Sub PlaySoundEffect(v As View) Dim r As Reflector r.Target = v r.RunMethod2("playSoundEffect",0,"java.lang.int") End Sub
'Index API Android Constant Description
' 0 1 FX_KEY_CLICK Keyboard and direction pad click sound
' 1 1 FX_FOCUS_NAVIGATION_UP Focus has moved up
' 2 1 FX_FOCUS_NAVIGATION_DOWN Focus has moved down
' 3 1 FX_FOCUS_NAVIGATION_LEFT Focus has moved left
' 4 1 FX_FOCUS_NAVIGATION_RIGHT Focus has moved right
' 5 3 FX_KEYPRESS_STANDARD IME standard keypress sound
' 6 3 FX_KEYPRESS_SPACEBAR IME spacebar keypress sound
' 7 3 FX_KEYPRESS_DELETE IME delete keypress sound
' 8 3 FX_KEYPRESS_RETURN IME return_keypress sound
' 9 19 FX_KEYPRESS_INVALID Invalid keypress sound
Sub PlaySoundEffectFromService(Index As Int)
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod2("playSoundEffect", Index, "java.lang.int")
End Sub
Sub PlaySoundEffectFromServiceVol(Index As Int, Volume As Float)
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod3("playSoundEffect", Index, "java.lang.int", Volume, "java.lang.float")
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?