2021-02-27 19:04:47 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2023-12-23 16:48:04 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
2019-07-17 22:19:53 +01:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
|
|
|
property var plugin
|
|
|
|
property var lastPosition: plugin.position
|
|
|
|
property date lastPositionTime: new Date()
|
|
|
|
property bool updatePositionSlider: true
|
|
|
|
|
|
|
|
sourceComponent: plugin.canSeek ? seekBar : progressBar
|
|
|
|
|
|
|
|
onLastPositionChanged: {
|
2023-06-07 19:20:21 +01:00
|
|
|
if (item != null) {
|
|
|
|
item.value = lastPosition
|
|
|
|
lastPositionTime = new Date();
|
|
|
|
}
|
2019-07-17 22:19:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
}
|