Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android合并音频文件

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相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11