Android Question ogg file is not played in soundpool

mkvidyashankar

Active Member
Licensed User
Longtime User
Hi

I am trying to play two soundfiles simultaneously, but not able to play. the same code, if i use wav files, it works, but not in case of ogg files.
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim playID1,playID2,loadid1,loadid2 As Int
    Dim sp  As SoundPool
    Private Panel1 As Panel
    Private Button_forest As Button
    sp.
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    Panel1.SetLayout(0,0,100%x,100%y)
    Button_forest.SetLayout(10dip,50dip,100%x-20dip,50dip)
    sp.Initialize(5)

    loadid1=sp.Load(File.DirAssets,"Bird_in_Rain-Mike_Koenig-441535833.ogg")
    loadid2=sp.Load(File.DirAssets,"river.ogg")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button_forest_Click
   
    playID1=sp.Play(loadid1,1, 1, 1, -1, 1)
    playID2=sp.Play(loadid2,1, 1, 2, -1, 1)
   
End Sub
 

mkvidyashankar

Active Member
Licensed User
Longtime User
Monitor the unfiltered logs (you will need to connect in USB debug mode). There will probably a message about the format not being supported.

thanks erel

i checked the log, it is not supported. it is supporting only wav files, but it consumes lot of memory space. what is the alternative to play 2-3 tracks simultaneously?
 
Upvote 0
Top