https://bugs.kde.org/show_bug.cgi?id=416128

Noah Davis <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Noah Davis <[email protected]> ---
As of version 5.26.1, it seems that the slider does react to scrolling, but the
position is almost immediately reset back to the current media position rather
than changing the media position to the slider's position. This sometimes
causes a slight stuttering effect in the audio.

The behavior is defined in
plasma-workspace/applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml.
There are a few key parts to be aware of when fixing this bug.

The `seekSlider` has its value set to the position of the MPRIS2 source
whenever the MPRIS2 source position changes, unless the slider is currently
being pressed. `disablePositionUpdate` is a bool property defined in
expandedRepresentation. It is used to keep the slider from doing things when
the MPRIS2 source info changes.

```
onPositionChanged: {
    // we don't want to interrupt the user dragging the slider
    if (!seekSlider.pressed && !keyPressed) {
        // we also don't want passive position updates
        disablePositionUpdate = true
        // Slider refuses to set value beyond its end, make sure "to" is
up-to-date first
        seekSlider.to = length;
        seekSlider.value = position
        disablePositionUpdate = false
    }
}
```

`seekTimer` can also change the value periodically and block slider input as
long as the slider is not pressed.

```
PlasmaComponents3.Slider { // Slider
    id: seekSlider
// [snip]
    value: 0
// [snip]
    onMoved: {
        if (!disablePositionUpdate) {
            // delay setting the position to avoid race conditions
            queuedPositionUpdate.restart()
        }
    }
// [snip]
    Timer {
        id: seekTimer
        interval: 1000 / expandedRepresentation.rate
        repeat: true
        running: root.isPlaying && root.expanded && !keyPressed && interval > 0
&& seekSlider.to >= 1000000
        onTriggered: {
            // some players don't continuously update the seek slider position
via mpris
            // add one second; value in microseconds
            if (!seekSlider.pressed) {
                disablePositionUpdate = true
                if (seekSlider.value == seekSlider.to) {
                    retrievePosition();
                } else {
                    seekSlider.value += 1000000
                }
                disablePositionUpdate = false
            }
        }
    }
}
```

`queuedPositionUpdate` sets the value of the `seekSlider` as the MPRIS2
service's position 100ms after the timer is started.

```
Timer {
    id: queuedPositionUpdate
    interval: 100
    onTriggered: {
        if (position == seekSlider.value) {
            return;
        }
        var service = mpris2Source.serviceForSource(mpris2Source.current)
        var operation = service.operationDescription("SetPosition")
        operation.microseconds = seekSlider.value
        service.startOperationCall(operation)
    }
}
```

In order to fix this without changing a lot, we may need to accumulate wheel
delta and then use it to set the slider's value or reset the accumulated delta
after a short delay.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to