Android Question Click sound on buttons unreliable

Discussion in 'Android Questions' started by Roger Daley, Apr 8, 2015.

  1. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Hi All

    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

    Code:
    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
     
  2. NJDude

    NJDude Expert Licensed User

    Roger Daley likes this.
  3. Peter Simpson

    Peter Simpson Expert Licensed User

    Hello @Roger Daley,
    Try this code out.
    Code:
    You will need to check the 'Audio' library in your library tab

        
    Dim Beep As Beeper 'Place in Sub Globals 
            Beep.Initialize(1001000'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
    Enjoy...
     
    Roger Daley likes this.
  4. Roger Daley

    Roger Daley Well-Known Member Licensed User

    NJD/Peter

    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.

    Regards Roger
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice