Sub Process_Globals
Dim sounds As SoundPool
Dim RXId2,RXId3,RXId4 As Int
Dim p As Phone 'so as to be able to change the volume level from 0-15
Dim SoundOn As Boolean = True 'by default turn sound on
End Sub
Sub Activity_Create(FirstTime As Boolean)
' initialise sound
sounds.Initialize(4) 'added extra streams incase two or more sounds are played simultaneously (20/8/2022)
RXId2 = Load_Sound("ErrorBeep.mp3") 'used when no more WPs can be selected with left or right arrows
RXId3 = Load_Sound("Tick03.mp3") 'used for WP gesture
RXId4 = Load_Sound("woerrroep.mp3") 'used for waypoint increment
End Sub
Sub Load_Sound(fileName As String) As Int
Dim loadIndex As Int = 0
For i = 0 To 1000 'this will try harder to load the file with greater success according to canalrun on the B4A forum
loadIndex = sounds.Load(File.DirAssets, fileName) 'used when no more WPs can be selected with left or right arrows
If RXId2 > 0 Then Exit 'stop trying to load it
Next
Return loadIndex 'returns 0 if it fails to load
End Sub
Sub btnLeftArrow_Click
If SoundOn Then
If RXId4 > 0 Then sounds.Play(RXId4, 0.07, 0.07, 1, 0, 1)' play woerrroep sound (only play sound if loaded or > 0)
End If
End Sub
Sub PlayErrorBeep 'used by other routines
If SoundOn Then
If RXId2 > 0 Then sounds.Play(RXId2, 0.07, 0.07, 1, 0, 1) 'only play sound if loaded or > 0
End If
End Sub