Skip to content

Commit

Permalink
Merge pull request #67 from ccatterina/track-position-slider-improvem…
Browse files Browse the repository at this point in the history
…ents

fix: set position instead of use seek function
  • Loading branch information
ccatterina committed Mar 16, 2024
2 parents 04cc966 + bbf1a93 commit b612552
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/contents/ui/Player.qml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ QtObject {
mpris2Model.currentPlayer?.PlayPause();
}

function seek(offset) {
mpris2Model.currentPlayer?.Seek(offset);
function setPosition(position) {
mpris2Model.currentPlayer.position = position;
}

function next() {
Expand Down
5 changes: 2 additions & 3 deletions src/contents/ui/TrackPositionSlider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ Item {
if (pressed) {
return
}
changingPosition = true

changingPosition = true
const targetPosition = timeTrackSlider.value * container.songLength
if (targetPosition != container.songPosition) {
container.requireChangePosition(Math.round(targetPosition - container.songPosition))
container.requireChangePosition(targetPosition)
}

changingPosition = false
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ PlasmoidItem {
songLength: player.songLength
playing: player.playbackStatus === Mpris.PlaybackStatus.Playing
enableChangePosition: player.canSeek
onRequireChangePosition: (delta) => {
player.seek(delta)
onRequireChangePosition: (position) => {
player.setPosition(position)
}
onRequireUpdatePosition: () => {
player.updatePosition()
Expand Down

0 comments on commit b612552

Please sign in to comment.