Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#轨迹栏mciSendString_C#_Mci - Fatal编程技术网

C#轨迹栏mciSendString

C#轨迹栏mciSendString,c#,mci,C#,Mci,我正在使用MCI编写一个CD音频播放器程序,但我无法在轨迹栏上显示音频文件的进度 有人知道怎么做吗 请注意,我必须使用以获取轨迹长度。从,稍微更改: public int GetCurrentPosition() { String command = "status MediaFile position"; error = mciSendString(command, returnData, returnData.Capaci

我正在使用MCI编写一个CD音频播放器程序,但我无法在轨迹栏上显示音频文件的进度

有人知道怎么做吗

请注意,我必须使用以获取轨迹长度。

从,稍微更改:

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。。。