如何获取一个MP3在C#中的长度 [英] How to get the length of a MP3 in C#
问题描述
是的,这是这个问题,但链接给出接受的答案是不是为我工作。它返回不正确的值(仅需2分钟的MP3将被列为1'30 3分钟为2'20),没有明显的规律。
所以,这里要再次重申:我怎样才能使用C#一个MP3的长度是多少?
或的
我在做什么毛病 MP3Header类:
MP3Header mp3hdr =新MP3Header();
布尔boolIsMP3 = mp3hdr.ReadMP3Information(1.MP3);
如果(boolIsMP3)
回复于(mp3hdr.intLength);
显然,此类计算使用作品尺寸/比特率的持续时间。这只能用于恒定比特率的工作,我相信你的MP3具有可变比特率...
编辑:看看标签库夏普,它可以给你时间
Yes this is an exact duplicate of this question, but the link given and accepted as answer is not working for me. It is returning incorrect values (a 2 minutes mp3 will be listed as 1'30, 3 minutes as 2'20) with no obvious pattern.
So here it is again: how can I get the length of a MP3 using C# ?
or
What am I doing wrong with the MP3Header class:
MP3Header mp3hdr = new MP3Header();
bool boolIsMP3 = mp3hdr.ReadMP3Information("1.mp3");
if(boolIsMP3)
Response.Write(mp3hdr.intLength);
Apparently this class computes the duration using fileSize / bitRate. This can only work for constant bitrate, and I assume your MP3 has variable bitRate...
EDIT : have a look at TagLib Sharp, it can give you the duration
这篇关于如何获取一个MP3在C#中的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!