[英]C# trackbar mciSendString
I'm writing a CD Audio player program using MCI, but I can't show the progress of the audio file on a trackbar. 我正在使用MCI编写CD音频播放器程序,但是无法在轨迹栏上显示音频文件的进度。
Does anyone know how? 有人知道吗?
Note that I must use mciSendString
to get the track length. 请注意,我必须使用
mciSendString
来获取轨道长度。
From Simple MCI Player - CodeProject , slightly altered: 在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;
}
In VB I did this inside a Timer Tick Sub...easy peasy really... 在VB中,我是在Timer Tick Sub内部完成此操作的。
rem audio is the mcisendstring thingy rem TotalLength is total seconds of current track rem音频是最重要的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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.