开发者

Play audio from buffer

开发者 https://www.devze.com 2023-03-29 08:59 出处:网络
I want to play audio from a buffer. Something l开发者_开发问答ike using the AudioRecord to record the audio into buffer and play

I want to play audio from a buffer. Something l开发者_开发问答ike using the AudioRecord to record the audio into buffer and play it from the buffer.

Is there a way of doing it? In the MediaPlayer there is no such option.


You can do this with the AudioTrack class. Its interface is very similar to that of AudioRecord, except that the AudioTrack can only use buffers of type byte[] and short[].


You may use temp file as described in solution here:

Android - Playing mp3 from byte[]

or if your file comes from the internet (referenced by URL for example), you may use:

setDataSource(Context context, Uri uri)

presented in the same question.

0

精彩评论

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

关注公众号