如何确定歌曲使用winmm.dll多长时间? [英] How to determine how long a song is using winmm.dll?

查看:96
本文介绍了如何确定歌曲使用winmm.dll多长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

P/从WinMM.dll调用了mciSendString方法 :

[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn,
                                         int iReturnLength, IntPtr hwndCallback);

我可以播放,暂停和停止歌曲(我也可以打开/关闭CD驱动器,但这并不重要).现在,我希望用户能够跳到歌曲中的某个部分(例如1:21).我看过搜索功能文档除了我不知道一首歌有多长以外,这似乎很简单.在WinMM中是否存在执行此操作的命令/方法?

I can play, pause, and stop songs (I can also open/close the CD drive, but that's not important). Now I want my user to be able to skip to a certain part in a song (e.g. 1:21). I've looked at the seek functions documentation and it seems pretty staightforward except that I can't figure out how long a song is. Does a command/method exist to do this in WinMM?

推荐答案

可能是这样的:

StringBuilder sb = new StringBuilder(128);
mciSendString("status mediafile length", sb, 128, IntPtr.Zero);
long songlength = Convert.ToUInt64(sb.ToString());

这篇关于如何确定歌曲使用winmm.dll多长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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