0

我正在使用 winmm.dll 制作一个基本的 mp3 播放器。我的 FFW 方法有点问题。当我激活它时,基本上什么都没有发生。

你大概能猜出我想要做什么。

前 6 行注释掉,保存一个工作示例代码,运行我的循环时它对我不起作用,我做错了什么?

public void FFW()
{
    //string cmd1 = "set MyMp3 time format ms";
    //mciSendString(cmd1, null, 0, 0);
    //cmd1 = "seek MyMp3 to 8000";
    //mciSendString(cmd1, null, 0, 0);
    //cmd = "play MyMp3";
    //mciSendString(cmd, null, 0, 0);

    int ffw5sec = 5000;

    while (isPlaying == true)
    {
        string cmd = "set MyMp3 time format ms";
        mciSendString(cmd, null, 0, 0);
        cmd = "seek MyMp3 to " + ffw5sec.ToString();
        mciSendString(cmd, null, 0, 0);
        cmd = "play MyMp3";
        mciSendString(cmd, null, 0, 0);

        ffw5sec += 5000;

    }
}
4

1 回答 1

0

ohh, I got it working when I took my code out from the loop....

my solution: the Skip feature is not optimal, but atleast its doing what I was looking for, I think I need to add a timer in the future, to calculate a better skip.

int ffw5sec = 5000;

public void FFW()
{
    if(isPlaying == true)
    {
        string cmd = "set MyMp3 time format ms";
        mciSendString(cmd, null, 0, 0);
        cmd = "seek MyMp3 to " + ffw5sec.ToString();
        mciSendString(cmd, null, 0, 0);
        cmd = "play MyMp3";
        mciSendString(cmd, null, 0, 0);

        ffw5sec += 5000;
    }
}
于 2013-09-28T19:09:05.440 回答