如何附加到 Android MediaRecorder 输出文件 [英] How to append to Android MediaRecorder output file

查看:28
本文介绍了如何附加到 Android MediaRecorder 输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法告诉 MediaRecorder 附加到现有的音频文件而不是从头开始.换句话说,我想使用现有文件调用 setOutputFile() 并将新音频附加到该文件而不是删除它.

I am wondering if there is a way to tell the MediaRecorder to append to an existing audio file instead of starting it over from the beginning. In other words, I would like to call setOutputFile() with an existing file and have the new audio appended to that file instead of erasing it.

推荐答案

Android MediaRecorder 不支持追加.

Android MediaRecorder does not support appending.

录制完成后,唯一可能的操作是停止和重置.

Once you are recording the only possible actions are stop and reset.

因此,一种选择是另存为 WAV 文件,然后使用 AudioRecord 附加到保存在 SD 卡上的现有 WAV 文件.AudioRecord.read() 允许将原始音频数据保存到缓冲区,您可以轻松地将其附加到现有录音中.

So one option is saving as a WAV file, and then append to an existing WAV file saved on the SD card using AudioRecord instead. AudioRecord.read() allows one to save the raw audiodata to a buffer, which you could easily append to an existing recording.

这篇关于如何附加到 Android MediaRecorder 输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆