How to determine how long a song is using winmm.dll?

拈花ヽ惹草 提交于 2020-01-05 03:06:10

问题


I've P/Invoked the mciSendString method from WinMM.dll:

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

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?


回答1:


It would probably be something like this:

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


来源:https://stackoverflow.com/questions/1033559/how-to-determine-how-long-a-song-is-using-winmm-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!