Hello,
I was trying to play 2 or more sound in different interfaces generated Dynamically of MediaPlayer, but im getting:
My code:
Im newbie using MediaPlayers, i dont know how to create dynamically MediaPlayers and use it, without handling too much and limited IFs like
And so on mediaplayer3,4,5,6...
Can anyone help me?
I was trying to play 2 or more sound in different interfaces generated Dynamically of MediaPlayer, but im getting:
B4X:
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
My code:
B4X:
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
B4X:
if mps1.IsPlaying then
mps2.Load(...)
mps2.Play
Can anyone help me?
Last edited: