开发者

Notification message from AudioTrack stream

I've implemented a PCM decoder that writes to an AudioTrack object.

Everything seems great, however, I need to get some sort of notification from the AudioTrack object when the last written chunk has stopped playing.

I've noticed that there are callback methods such as setNotificationMarkerPos开发者_如何学运维ition, however, I couldn't find any extensive documentation as how to use them.

Thanks in advance!


To get an AudioTrack callback, you could set a marker callback or use the periodic callback. I've seen reports of problems with the marker, so you may want to try both.

For the marker callback, first call setNotificationMarkerPosition with whatever frame number you want a call for.

For a periodic callback, instead call setPositionNotificationPeriod and it will call every x frames.

Either way, you'll need to call setPlaybackPositionUpdateListener to register the callback. This will call two methods, onMarkerReached if it reaches a marker, or onPeriodicNotification every set number of frames. You can choose to use one or the other, or both. Both callbacks refer the instance of AudioTrack you used to set it.

By default, it will call back in the same thread the AudioTrack instance was created. Alternatively, you can pass a handler when you register the callbacks to send it to another thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜