Android Question AudioTrack - How to pause/resume?

noeleon

Member
Licensed User
I tried the sample project attest.zip for AudioTrack and I can't figure out how to pause/resume playing.

Calling at.pause immediately triggers the Play_Ended event. And if I comment out at.Release and call at.play it will only play for a few milliseconds which I'm guessing is the data left in the buffer, then nothing else.

B4X:
Sub activity_Click
    ToastMessageShow("pause", False)
    at.Pause
End Sub

Sub activity_LongClick
    ToastMessageShow("resume", False)
    at.Play
End Sub
 

stevel05

Expert
Licensed User
This was one of my first libraries and a lot has changed in the Andriod class since this was written, however the Audiotrack,Pause method pauses the Audiotrack object not the data that is fed to it which is done in the code. This needs to be implemented in the code either with a flag, or as Erel suggests using a timer with either option remembering the current data position and resuming when needed.
 
Upvote 0
Top