/// <summary>
/// c#获取Amr文件的时长(毫秒)
/// </summary>
/// <param name="fileName">文件路径</param>
/// <returns></returns>
private long GetAMRFileDuration(string fileName)
{
long duration = ;
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
{
byte[] packed_size = { , , , , , , , , , , , , , , , };
int pos = ;
pos += ;
long lenth = fs.Length;
byte[] toc = new byte[];
int framecount = ;
byte ft;
while (pos < lenth)
{
fs.Seek(pos, SeekOrigin.Begin);
if ( != fs.Read(toc, , ))
{
fs.Close();
break;
}
ft = (byte)((toc[] / ) & 0x0F);
pos += packed_size[ft] + ;
framecount++;
}
duration = framecount * ;
}
fs.Close();
return duration;
}