Android Question No more Sound after sub calling many time

ALBRECHT

Active Member
Licensed User
Hello,

I'm using that sub see bellow after a Button_Click, with a "wait for" function :
but when there is many fast click, the sound disapear ...
Probably is there a buffer management for sound queue, or there is an other pb ?

B4X:
Sub Process_Globals  
    Dim MP As MediaPlayer
End Sub

'after Button_Click
Wait For(audio.PlaySound("smallsound.mp3", 1500)) Complete (Result As Boolean)
'the rest of the code

'the Sub in audio module
Sub PlaySound(audiofile As String, DurSleep As Int) As ResumableSub
    If Main.MusicEnable = True Then
        If MP.IsInitialized = True Then
            MP.Stop ' try to stop an previous playing if there is
            MP.Release
        End If
        MP.Initialize2("MP")
        MP.Load(File.DirAssets, audiofile)
        MP.Play   
    End If
    Sleep(DurSleep)
    Return True
End Sub

Regards
Michel
 

ALBRECHT

Active Member
Licensed User
Why are you initialing a new MP each time? =>
it was a last change to try to correct my pb and avoid that the Sound disapear, but that dont change the pb !
 
Upvote 0
Top