Bug 416128 - Seekbar on applet doesn't respond to scrolling
Summary: Seekbar on applet doesn't respond to scrolling
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Media Player widget (show other bugs)
Version: 5.17.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: Kai Uwe Broulik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-11 18:11 UTC by D. Debnath
Modified: 2025-01-24 05:38 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.4.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description D. Debnath 2020-01-11 18:11:15 UTC
SUMMARY

STEPS TO REPRODUCE
1. Move your mouse pointer over the seekbar in the media applet.
2. Scroll

OBSERVED RESULT
Nothing happens.

EXPECTED RESULT
Seek.
Comment 1 Noah Davis 2023-08-02 20:59:55 UTC
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.
Comment 2 Bug Janitor Service 2025-01-19 08:50:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5091
Comment 3 Kai Uwe Broulik 2025-01-20 18:12:41 UTC
Git commit 8f6ee9e12bb1f2c79724b6838a365248f242a7cb by Kai Uwe Broulik.
Committed on 20/01/2025 at 17:22.
Pushed by broulik into branch 'master'.

Set stepSize on seek slider to make wheel work

MPRIS operates in microseconds, so the default step size of 1 makes no
discernible difference in seeking the played track.

Set it to 5 seconds so that wheel works as expected. It also has the nice
side-effect of making the built-in left/right key handling work.

Unfortunately, it might cause tick marks to appear for short tracks.

M  +1    -8    applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml

https://invent.kde.org/plasma/plasma-workspace/-/commit/8f6ee9e12bb1f2c79724b6838a365248f242a7cb