且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#中的圆形滑块值更改玩家位置

更新时间:2023-02-12 10:12:04

首先,你可以在这里找到更好的答案 https://github.com/filoe/cscore/issues [ ^ ]



说到你的代码片段,你可以像这样简化

First of all you could probably get a better answer here https://github.com/filoe/cscore/issues[^]

When it comes to your code snippet you can simplify like this
private void songProgress_ValueChanged(object sender, ValueChangedEventArgs e)
{
    player.Position = TimeSpan.FromSeconds(songProgress.ProgressValue);
}



然后你在这一行设置一个断点并检查 player.Position 的值>执行该行之前和之后。



[更新]

由于你有播放器的源代码,你可以调试到代码也是。


Then you put a break-point at this line and check the value of player.Position before and after execution of the line.

[UPDATE]
As you have the source code for the player you can debug into that code too.

public TimeSpan Position
{
    get
    {
        if (_waveSource != null)
            return _waveSource.GetPosition();
        return TimeSpan.Zero;
    }
    set
    {
        if (_waveSource != null)
            _waveSource.SetPosition(value);
    }
}



我想你必须深入研究 IWaveSource.SetPosition 看看那里发生了什么。

我能想到的另一件事是滑块控制表现得很奇怪,但这似乎不太可能。

另外检查你是否有任何释放鼠标时发生的事件。


I guess you have to dig into IWaveSource.SetPosition as well to see what happens there.
The only other thing I can think of is that the slider control is behaving strangely, but that seems unlikely.
Also check if you have any event going on when you release the mouse.