如何在asp.net中获取音频文件的持续时间 [英] How to get the duration of Audio file in asp.net

查看:113
本文介绍了如何在asp.net中获取音频文件的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,请帮助我。





我想要asp.net(Web应用程序)中音频文件的持续时间。这意味着如果音频长5分钟,那么我的要求是获得5分钟或300秒。

Dear All,Please help me.


I want the duration of Audio File in asp.net(Web Application).That means if the audio is 5 minutes long then my requirement is to get 5 Minutes or 300 seconds.

推荐答案

参见如何在Windows 7上获取C#中媒体文件的长度(持续时间) [ ^ ]


查看此文章如何在Windows 7上的C#中获取媒体文件的长度(持续时间) [ ^ ]



也有一些类似于你的帖子的问题:

如何在C#中获得音乐曲目的长度 [ ^ ]

需要找到的最长度的音频文件,在-minutes-in-asp-net [ ^ ]



希望这会有所帮助。 :)

也可以尝试在google上搜索,然后在这里发帖。
check this article How to get the length (duration) of a media File in C# on Windows 7[^]

also some questions similar to your post:
How to get the length of a music track in C#[^]
need-to-find-the-length-of-audio-file-in-minutes-in-asp-net[^]

Hope this helps. :)
Also try doing search on google before posting posts here.


谢谢大家快速回复。实际上我已经通过使用Naudio.dll解决了它。下面是完整的代码。



(首先从互联网上下载Naudio.dll)





TimeSpan span = GetWavFileDuration(filePath +\\+ fileName);

string spanSeconds = span.TotalSeconds.ToString();

string [] spanSecondsArray = spanSeconds.Split('。');

spanSeconds = spanSecondsArray [0] .ToString();



public static TimeSpan GetWavFileDuration(string fileName)

{

WaveFileReader wf = new WaveFileReader(fileName);

返回wf.TotalTime;

}
Thanks All for ur quick response. Actually I have solved it by using Naudio.dll. Below is the complete code for it.

(First download Naudio.dll from Internet)


TimeSpan span= GetWavFileDuration(filePath + "\\" + fileName);
string spanSeconds = span.TotalSeconds.ToString();
string []spanSecondsArray=spanSeconds.Split('.');
spanSeconds = spanSecondsArray[0].ToString();

public static TimeSpan GetWavFileDuration(string fileName)
{
WaveFileReader wf = new WaveFileReader(fileName);
return wf.TotalTime;
}


这篇关于如何在asp.net中获取音频文件的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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