设为首页 加入收藏

TOP

Android合并音频文件
2014-11-24 08:29:35 来源: 作者: 【 】 浏览:1
Tags: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) {
}
}


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android使用GridView实现日历功能.. 下一篇Linux平台用C++封装线程读写锁

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·如何从内核协议栈到 (2025-12-27 03:19:09)
·什么是网络协议?有哪 (2025-12-27 03:19:06)
·TCP/ IP协议有哪些 (2025-12-27 03:19:03)
·怎样用 Python 写一 (2025-12-27 02:49:19)
·如何学习python数据 (2025-12-27 02:49:16)