获取mp3文件的持续时间 [英] Get duration of mp3 file
本文介绍了获取mp3文件的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ASP.NET和C#.NET 2.0。我在gridview中显示名为Sandler的文件夹的所有mp3文件。我想在gridview中显示每个mp3文件的持续时间。我尝试了但是我没有得到解决方案。
这是我的代码:
Hi, I am using ASP.NET and C#.NET 2.0. I am showing all the mp3 files of a folder called "Sandler" in a gridview. I want to display the duration of each mp3 file in the gridview. I tried but I didn''t get the solution.
Here is my code:
public void GetSandlerTrainingFiles()
{
String FileName="";
string[] filePaths = System.IO.Directory.GetFiles(Server.MapPath("sandler"/));
List<listitem> files = new List<listitem>();
foreach (string filePath in filePaths)
{
string p = filePath;
string fileExt=Path.GetExtension(p);
if (fileExt == ".mp3")
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
}
dgrid_sandlertraining.DataSource = files;
dgrid_sandlertraining.DataBind();
}
现在我想在gridview中显示音频文件的持续时间。这只能在.NET 2.0中完成。
请帮帮我。
谢谢
Srinivas D
Now I want to display audio file duration in gridview. This is to be done only in .NET 2.0.
Please help me.
Thanks
Srinivas D
推荐答案
我遇到了Windows计算持续时间错误的问题 - 特别是如果它们是VBR。
我使用 UltraId3 [ ^ ]读取元数据,因为这通常更准确。
I have had issues with Windows calculating the duration incorrectly - especially if they are VBR.
I use UltraId3[^] to read the meta data as that is usually more accurate.
这篇关于获取mp3文件的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文