C#读取视频音频的播放时间

jerrold1108cn 2009-03-16 03:54:52
如题
...全文
369 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
p9855 2010-11-23
  • 打赏
  • 举报
回复
看看看看看看看看
老马2008 2009-09-07
  • 打赏
  • 举报
回复
看看
jerrold1108cn 2009-03-26
  • 打赏
  • 举报
回复
flv格式的文件能取到?
occam 2009-03-24
  • 打赏
  • 举报
回复
视频音频是一样的
只是在open的时候指定type mpegvideo

检查mcisendstring返回值,如果>0表示错误, 参考http://support.microsoft.com/kb/103647/zh-cn
jerrold1108cn 2009-03-24
  • 打赏
  • 举报
回复
这个是读取音频的,测了不能通过
有没读取视频的
chuxue1342 2009-03-18
  • 打赏
  • 举报
回复
没搞过!帮你顶!
芮言 2009-03-18
  • 打赏
  • 举报
回复
没有研究过,看了前辈的源码,你看看
C# 播放时间,得到音频文件的播放时间!
private string getasfTime(string filePath)
{
StringBuilder shortpath = new StringBuilder(80);
GetShortPathName(filePath, shortpath, shortpath.Capacity);
string name = shortpath.ToString();
StringBuilder buf = new StringBuilder(80);
mciSendString("close all", buf, buf.Capacity, 0);
mciSendString("open " + name + " alias media", buf, buf.Capacity, 0);
mciSendString("status media length", buf, buf.Capacity, 0);
TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim()));
return ts.ToString();
}
jerrold1108cn 2009-03-18
  • 打赏
  • 举报
回复
没有人做过吗?
自己顶下
occam 2009-03-18
  • 打赏
  • 举报
回复
2楼的很简单, 补充一下用到的两个方法

using System.Runtime.InteropServices;

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName(
string lpszLongPath,
string shortFile,
int cchBuffer
);

[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
jiningyin 2009-03-18
  • 打赏
  • 举报
回复
可以用暴风影音的控件,得到相关多媒体资料的所有信息
huohua123 2009-03-18
  • 打赏
  • 举报
回复
关注。。。。

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧