/** * Get AMR * * @param file * @return * @throws ioexception/public static long GE
Tamrduration (file file) throws IOException {Long duration =-1;
Int[] Packedsize = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
Randomaccessfile randomaccessfile = null;
try {randomaccessfile = new Randomaccessfile (file, rw); Long length = File.length ()//file length int pos = 6;//set initial position int framecount = 0;//initial frame number int
Packedpos =-1; byte[] Datas = new byte[1];//initial data value while (PO
s <= length) {Randomaccessfile.seek (POS); if (Randomaccessfile.read (datas, 0, 1)!= 1) {duration = length > 0?
((length-6)/650): 0;
Break } Packedpos = (Datas[0] >> 3) & 0x0f;
POS + + Packedsize[packedpos] + 1;
framecount++;
/////////////////////////////////////////////////////Duration + + Framecount * 20;//Frame number *20
finally {if (randomaccessfile!= null) {randomaccessfile.close ();
} return duration; }