I have an App with a number of buttons which have the option of making a "click" sound when pressed. I have used Media Player and a sound file [7ms] to do this, however the "click" sound does not always work. It's operation is intermittent and unpredictable.
Possibly there is a better way to use Media Player or even a better way to make a button "click".
Any sugestions welcome.
Regards Roger
B4X:
Sub Process_Globals
Dim MP As MediaPlayer
Dim btnClick_flag As Int
Etc........
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
MP.Initialize2("MP")
MP.Load(File.DirAssets,"click.wav")
Etc............
End If
End Sub
Sub AnyButton_Click
If btnClick_flag = 1 Then MP.Play
Etc..........
End Sub
You will need to check the 'Audio' library in your library tab
Dim Beep As Beeper 'Place in Sub Globals
Beep.Initialize(100, 1000) 'Place in Activity_Create. Adjust the duration and frequency until you get the desired click sound
Beep.Beep 'Call in button sub whenever you want hear hear beep/click sound
Thanks guys both solutions work. I went for sound pool to keep the recorded [waveform shaped] sound but Beeper opens up other possibilties for the future.