我正在使用MCI编写CD音频播放器程序,但无法在跟踪条上显示音频文件的进度。
有人知道是怎么回事吗?
请注意,我必须使用mciSendString来获取轨道长度。
发布于 2012-10-12 18:22:54
来自Simple MCI Player - CodeProject,稍作修改:
public int GetCurrentPosition()
{
String command = "status MediaFile position";
error = mciSendString(command, returnData,
returnData.Capacity, IntPtr.Zero);
return error == 0 ? int.Parse(returnData.ToString()) : 0;
}
public int GetSongLenght()
{
if (IsPlaying())
{
String command = "status MediaFile length";
error = mciSendString(command, returnData, returnData.Capacity, IntPtr.Zero);
return error == 0 ? int.Parse(returnData.ToString()) : 0;
}
else
return 0;
}发布于 2015-03-14 02:20:27
在VB中,我在一个定时器Sub...easy中做到了这一点,真的…
rem音频是mcisendstring thingy rem TotalLength是当前曲目的总秒数
Dim PlayPosition As Long = 0
PlayPosition = audio.SecondsPlayed
If PlayPosition > 0 And PlayPosition < TotalLength Then
TrackBar1.Value = (PlayPosition / TotalLength) * TotalLength
End Ifhttps://stackoverflow.com/questions/12855652
复制相似问题