Hello,
I was trying to play 2 or more sound in different interfaces generated Dynamically of MediaPlayer, but im getting:
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
My code:
Sub Play_Sound(Snd As String)
Dim media As String
Dim mps() as MediaPlayer
For i = 0 To 2 -1
Log(i)
If Not(mps(i).IsPlaying) Then
mps(i).Initialize()
media="sounds/" & Snd
mps(i).Load(File.DirAssets,media)
mps(i).Play
Exit
End If
Next
End Sub
Im newbie using MediaPlayers, i dont know how to create dynamically MediaPlayers and use it, without handling too much and limited IFs like
if mps1.IsPlaying then
mps2.Load(...)
mps2.Play
And so on mediaplayer3,4,5,6...
Can anyone help me?