且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

混淆螺纹生活和AudioTrack android中的java

更新时间:2023-12-03 23:18:52

要audioTrack.play()的调​​用不会阻塞。它会开始播放和线程的run()方法将返回,可能之前播放结束。音频的实际播放在内部创建另一个线程正在发生的事情,不是那个它从调用。

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.

您有 AudioTrack.setPlaybackPositionUpdateListener()可接收回调,当播放到与设置一个点AudioTrack.setNotificationMarkerPosition()这将解决您的问题。

You have AudioTrack.setPlaybackPositionUpdateListener() available to receive a callback when playback reaches a point set with AudioTrack.setNotificationMarkerPosition() which will solve your problem.