如何通过.NET/C#获取mp3文件的持续时间? [英] How to get a duration of mp3 file via .NET/C#?

查看:90
本文介绍了如何通过.NET/C#获取mp3文件的持续时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个mp3歌曲的M3U播放列表.

I need to create a M3U playlist of mp3 songs.

有什么方法可以读取MP3文件的duration属性?

Is there any way to read the duration attribute of MP3 files?

推荐答案

不要重新发明轮子.使用诸如NAudio之类的外部库来完成这项工作.

Don't reinvent the wheel. Use an external library such as NAudio to do the hard work.

  • NAudio is available at CodePlex.

您可以像这样使用它:

Mp3FileReader reader = new Mp3FileReader("<YourMP3>.mp3");
TimeSpan duration = reader.TotalTime;

当然,可以选择此答案.

这篇关于如何通过.NET/C#获取mp3文件的持续时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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