Confusion About Thread Life And Audiotrack In Android Java
I have the following functions: void playSound(){ final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, AudioFormat.CHANNEL_OUT_MONO
Solution 1:
The call to audioTrack.play() does not block. It will begin playback and the run() method of the Thread will return, likely before playback is over. The actual playback of audio is happening in yet another thread internally created, not the one it was called from.
You have AudioTrack.setPlaybackPositionUpdateListener()
available to receive a callback when playback reaches a point set with AudioTrack.setNotificationMarkerPosition()
which will solve your problem.
Post a Comment for "Confusion About Thread Life And Audiotrack In Android Java"