c#获取Amr文件的时长(毫秒)亲测有效

/// <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;
}
上一篇:关于启动调试时,总是启动多个web端口的问题


下一篇:iOS 9应用开发教程之使用开关滑块控件以及滚动部署视图