如何在C#中获取音乐曲目的长度 [英] How to get the length of a music track in C#

查看:127
本文介绍了如何在C#中获取音乐曲目的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

我想知道如何获取C#中音乐曲目(具有mp3类型)的长度(持续时间).(例如:3:45).

我之前问过这个问题,但没人能回答正确!
如果您有解决方案,请与以前的解决方案进行比较,因为它们没有用!!!
关于(.Length),我应该告诉细节没有长度"选项!!!
而ID3并没有使用它只给艺术家,专辑使用的长度... !!!

:D

谢谢

Hi...

I want to know how can i get the length(duration) of a music track (with mp3 type).(for example: 3:45) in C#.

I asked this question before but no one couldn''t answer it right!
If you a solution please compare it with the ex-solutions because they weren''t useful !!!
and about the (.Length) I should tell the details doesn''t have Length option !!!
and the ID3 doesnt give use the length it just give artist, album...!!!

:D

Thank you

推荐答案

这些链接可能有帮助-
一个简单的C#Wave编辑器,第1部分:背景和分析 [ http://social.msdn.microsoft .com/forums/zh-CN/Vsexpressvcs/thread/b83106f2-e16d-4f30-ac31-854055c9efdc/#2685871 [
These links could help -
A simple C# Wave editor, part 1: Background and analysis[^]
http://social.msdn.microsoft.com/forums/en-US/Vsexpressvcs/thread/b83106f2-e16d-4f30-ac31-854055c9efdc/#2685871[^]


检查这篇文章:

http://www.codeproject.com/KB/vb/Windows_Media_Player_COM.aspx [ ^ ]

尽管它在VB中,但是您可以使用以下工具对其进行转换: http://www.developerfusion.com/tools/convert/vb-to-csharp/ [ ^ ]
Check out this article :

http://www.codeproject.com/KB/vb/Windows_Media_Player_COM.aspx[^]

Though its in VB, you can convert it using this tool : http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]


我认为您正在寻找返回TimeSpan对象的
I think you are looking for the
TagLib.File.Properties.Duration

.从那里,您可以使用TotalSeconds来获取mp3的长度(以秒为单位).

或通过此链接-
链接 [

which returns a TimeSpan object. From there you can use TotalSeconds to get the length of the mp3 in seconds.

or go through this link-
Link[^]


这篇关于如何在C#中获取音乐曲目的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆