My Android app records audio in both AMR
and WAV
format. And my application needs to insert second recorded audio file inside the first one at a position where it is paused. I did it right with WAV
files, but the AMR
file after insertion is not able to be played in Android MediaPlayer, it gives some error when it reaches the inserted position.But the same file plays fine in AMR players.
The steps I followed are:
1.Writing the data from file1 upto pause position:
raf3=new RandomAccessFile(result,"rw");
raf3.setLength(0);
int d=0;
//Write data from record1 upto the pause position
while(d!=pos)
{
raf3.write(bytes[d]);
d++;
}
2.Writing the data to be inserted from file2
//write all the data from record 2
int l=0;
raf3.writeBytes(" ");
while(l!=bytesread1)
{
raf3.write(bytes1[l]);
l++;
}
3.Writing the remaining data from file1 after pause position
while(d!=size){
raf3.write(bytes[d]);
d++;
}
Is there anything wrong with what I have done?