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