1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

Fix media player positioning

fixes #235
This commit is contained in:
bbedward
2025-09-22 09:47:34 -04:00
parent 6a963ed618
commit 0a5f635a2d
3 changed files with 8 additions and 4 deletions

View File

@@ -90,7 +90,8 @@ Item {
if (!activePlayer || !activePlayer.length || activePlayer.length <= 0) {
return 0
}
const calculatedRatio = (activePlayer.position || 0) / activePlayer.length
const pos = (activePlayer.position || 0) % Math.max(1, activePlayer.length)
const calculatedRatio = pos / activePlayer.length
return Math.max(0, Math.min(1, calculatedRatio))
}
@@ -760,7 +761,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
text: {
if (!activePlayer) return "0:00"
const pos = Math.max(0, activePlayer.position || 0)
const rawPos = Math.max(0, activePlayer.position || 0)
const pos = activePlayer.length ? rawPos % Math.max(1, activePlayer.length) : rawPos
const minutes = Math.floor(pos / 60)
const seconds = Math.floor(pos % 60)
const timeStr = minutes + ":" + (seconds < 10 ? "0" : "") + seconds

View File

@@ -17,7 +17,8 @@ Card {
readonly property real ratio: {
if (!activePlayer || activePlayer.length <= 0) return 0
const calculatedRatio = displayPosition / activePlayer.length
const pos = displayPosition % Math.max(1, activePlayer.length)
const calculatedRatio = pos / activePlayer.length
return Math.max(0, Math.min(1, calculatedRatio))
}

View File

@@ -10,7 +10,8 @@ Item {
property MprisPlayer activePlayer
property real value: {
if (!activePlayer || activePlayer.length <= 0) return 0
const calculatedRatio = (activePlayer.position || 0) / activePlayer.length
const pos = (activePlayer.position || 0) % Math.max(1, activePlayer.length)
const calculatedRatio = pos / activePlayer.length
return Math.max(0, Math.min(1, calculatedRatio))
}
property bool isSeeking: false