mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
* feat: rewind to track start on previous when past 8 seconds Adds MprisController.previousOrRewind() which rewinds the current track to position 0 if more than 8 seconds in (with canSeek check), and falls back to previous() otherwise — matching traditional media player behaviour. All previous() call sites across Media.qml, MediaPlayerTab.qml, MediaOverviewCard.qml, LockScreenContent.qml and DMSShellIPC.qml are updated to use the new shared function. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: poll position in MprisController for previousOrRewind accuracy Without a polling timer, activePlayer.position is never updated in contexts that don't display a seekbar (e.g. the DankBar widget), causing the position > 8 check in previousOrRewind() to always see 0 and fall through to previous() instead of rewinding. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
848 B
QML
30 lines
848 B
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Services.Mpris
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
readonly property list<MprisPlayer> availablePlayers: Mpris.players.values
|
|
property MprisPlayer activePlayer: availablePlayers.find(p => p.isPlaying) ?? availablePlayers.find(p => p.canControl && p.canPlay) ?? null
|
|
|
|
Timer {
|
|
interval: 1000
|
|
running: root.activePlayer?.playbackState === MprisPlaybackState.Playing
|
|
repeat: true
|
|
onTriggered: root.activePlayer?.positionChanged()
|
|
}
|
|
|
|
function previousOrRewind(): void {
|
|
if (!activePlayer)
|
|
return;
|
|
if (activePlayer.position > 8 && activePlayer.canSeek)
|
|
activePlayer.position = 0;
|
|
else if (activePlayer.canGoPrevious)
|
|
activePlayer.previous();
|
|
}
|
|
}
|