答案 0 :(得分:0)
来自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;
}
答案 1 :(得分:0)
在VB中我在Timer Tick Sub中做到了这一点......真的很容易......
rem audio是mcisendstring的东西 rem TotalLength是当前曲目的总秒数
Dim PlayPosition As Long = 0
PlayPosition = audio.SecondsPlayed
If PlayPosition > 0 And PlayPosition < TotalLength Then
TrackBar1.Value = (PlayPosition / TotalLength) * TotalLength
End If