C#轨迹栏mciSendString
我正在使用MCI编写一个CD音频播放器程序,但我无法在轨迹栏上显示音频文件的进度 有人知道怎么做吗 请注意,我必须使用以获取轨迹长度。从,稍微更改:C#轨迹栏mciSendString,c#,mci,C#,Mci,我正在使用MCI编写一个CD音频播放器程序,但我无法在轨迹栏上显示音频文件的进度 有人知道怎么做吗 请注意,我必须使用以获取轨迹长度。从,稍微更改: public int GetCurrentPosition() { String command = "status MediaFile position"; error = mciSendString(command, returnData, returnData.Capaci
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;
}
在VB中,我在定时器滴答子里做了这个…真的很简单 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
Dim播放位置,长度=0
播放位置=音频。秒显示
如果播放位置>0且播放位置<总长度,则
轨迹栏1.值=(播放位置/总长度)*总长度
如果结束
thx但我这里的问题是关于轨迹栏的…我不知道如何在上面显示轨迹进度…@user1740616调用GetCurrentPosition
获取文件的当前位置,然后将轨迹栏的值设置为该值。eventhandler如何?我想我也需要它?@user1740616你怎么会这么想?MCI会引发事件吗?好的,在我得到当前位置后,我将其传递给轨迹栏值,好的,我已经这样做了,但它仍然不会随着轨迹移动。所以我想我需要一个eventhandler。。。