开发者

Play audio from buffer

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜