Possible fix for MediaCard slider

MediaCard: use proper seek binding
MediaService: add seek binding
autoformat
This commit is contained in:
Ly-sec 2025-08-27 14:21:42 +02:00
parent 6f7528c87a
commit 563a151277
3 changed files with 92 additions and 71 deletions

View file

@ -11,6 +11,7 @@ Singleton {
property var currentPlayer: null
property real currentPosition: 0
property bool isSeeking: false
property int selectedPlayerIndex: 0
property bool isPlaying: currentPlayer ? (currentPlayer.playbackState === MprisPlaybackState.Playing
|| currentPlayer.isPlaying) : false
@ -158,11 +159,12 @@ Singleton {
Timer {
id: positionTimer
interval: 1000
running: currentPlayer && currentPlayer.isPlaying && currentPlayer.length > 0
running: currentPlayer && !root.isSeeking && currentPlayer.isPlaying && currentPlayer.length > 0
&& currentPlayer.playbackState === MprisPlaybackState.Playing
repeat: true
onTriggered: {
if (currentPlayer && currentPlayer.isPlaying && currentPlayer.playbackState === MprisPlaybackState.Playing) {
if (currentPlayer && !root.isSeeking && currentPlayer.isPlaying
&& currentPlayer.playbackState === MprisPlaybackState.Playing) {
currentPosition = currentPlayer.position
} else {
running = false
@ -170,6 +172,21 @@ Singleton {
}
}
// Avoid overwriting currentPosition while seeking due to backend position changes
Connections {
target: currentPlayer
function onPositionChanged() {
if (!root.isSeeking && currentPlayer) {
currentPosition = currentPlayer.position
}
}
function onPlaybackStateChanged() {
if (!root.isSeeking && currentPlayer) {
currentPosition = currentPlayer.position
}
}
}
// Reset position when switching to inactive player
onCurrentPlayerChanged: {
if (!currentPlayer || !currentPlayer.isPlaying || currentPlayer.playbackState !== MprisPlaybackState.Playing) {