首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android合龙音频文件

2013-02-05 
Android合并音频文件/** * 需求:将两个amr格式音频文件合并为1个 * 注意:amr格式的头文件为6个字节的长度

Android合并音频文件

/** * 需求:将两个amr格式音频文件合并为1个 * 注意:amr格式的头文件为6个字节的长度 * @param partsPaths       各部分路径 * @param unitedFilePath   合并后路径 */public void uniteAMRFile(String[] partsPaths, String unitedFilePath) {try {File unitedFile = new File(unitedFilePath);FileOutputStream fos = new FileOutputStream(unitedFile);RandomAccessFile ra = null;for (int i = 0; i < partsPaths.length; i++) {ra = new RandomAccessFile(partsPaths[i], "r");if (i != 0) {ra.seek(6);}byte[] buffer = new byte[1024 * 8];int len = 0;while ((len = ra.read(buffer)) != -1) {fos.write(buffer, 0, len);}}ra.close();fos.close();} catch (Exception e) {}}

热点排行