2e0550651e
We've had separate title & artist for a while, and all clients should be using those by now. Also fixes the position change not being emitted when the song changes, and fixes the values being written after emitting that they changed.
60 lines
1.3 KiB
QML
60 lines
1.3 KiB
QML
/**
|
|
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
*/
|
|
|
|
import QtQuick 2.2
|
|
import QtQuick.Controls 2.2
|
|
|
|
Loader {
|
|
|
|
property var plugin
|
|
property var lastPosition: plugin.position
|
|
property date lastPositionTime: new Date()
|
|
property bool updatePositionSlider: true
|
|
|
|
sourceComponent: plugin.canSeek ? seekBar : progressBar
|
|
|
|
onLastPositionChanged: {
|
|
if (item != null) {
|
|
item.value = lastPosition
|
|
lastPositionTime = new Date();
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: seekBar
|
|
|
|
Slider {
|
|
from: 0
|
|
to: plugin.length
|
|
onPressedChanged: {
|
|
if (pressed) {
|
|
updatePositionSlider = false
|
|
} else {
|
|
updatePositionSlider = true
|
|
plugin.position = value
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: progressBar
|
|
|
|
ProgressBar {
|
|
from: 0
|
|
to: plugin.length
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: positionUpdateTimer
|
|
interval: 1000
|
|
repeat: true
|
|
running: updatePositionSlider && plugin.isPlaying
|
|
|
|
onTriggered: item.value = lastPosition + (new Date().getTime() - lastPositionTime.getTime())
|
|
}
|
|
}
|