设为首页 加入收藏

TOP

Android合并音频文件
2014-11-24 08:29:35 来源: 作者: 【 】 浏览:0
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++封装线程读写锁

评论

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

·Python 数据分析与可 (2025-12-26 21:51:20)
·从零开始学Python之 (2025-12-26 21:51:17)
·超长干货:Python实 (2025-12-26 21:51:14)
·为什么 Java 社区至 (2025-12-26 21:19:10)
·Java多线程阻塞队列 (2025-12-26 21:19:07)