<code>
Dim sp As SoundPool
Dim sir,erra As Int
sp.Initialize(1)
sir=sp.Load(File.DirDefaultExternal,"Siren.mp3")
erra=sp.Play(sir,1,1,1,0,1)
Log(erra)
</code>
1. Don't remove the starter service.
2. Don't initialize SoundPool multiple times.
3. Don't initialize SoundPool when the activity is created. Only when FirstTime = True.
This code works fine here:
B4X:
Sub Process_Globals
Private sp As SoundPool
Private SirenIndex As Int
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If FirstTime Then
sp.Initialize(2)
SirenIndex = sp.Load(File.DirAssets,"Siren0.mp3")
End If
End Sub
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
If Action = Activity.ACTION_DOWN Then
sp.Play(SirenIndex, 1, 1, 1, 0, 1)
End If
End Sub