繁体   English   中英

C#跟踪栏mciSendString

[英]C# trackbar mciSendString

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

有人知道吗?

请注意,我必须使用mciSendString来获取轨道长度。

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;
}

在VB中,我是在Timer Tick Sub内部完成此操作的。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM