blob: e41f6cc82178cc4b6c7940cf216198a4c853f5c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Automotive Grade Linux
// SPDX-License-Identifier: GPL-3.0+
import QtQuick
import QtQuick.Controls.Fusion
import QtQuick.Layouts
import QtMultimedia
import Config
Item {
id: root
implicitHeight: 40
required property MediaPlayer mediaPlayer
property alias isMediaSliderPressed: mediaSlider.pressed
function getTime(time : int) {
const h = Math.floor(time / 3600000).toString()
const m = Math.floor(time / 60000).toString()
const s = Math.floor(time / 1000 - m * 60).toString()
return `${h.padStart(2,'0')}:${m.padStart(2,'0')}:${s.padStart(2, '0')}`
}
RowLayout {
anchors.fill: root
anchors.leftMargin: 200
anchors.rightMargin: 200
Label {
id: mediaTime
color: Config.secondaryColor
font.bold: true
text: root.getTime(root.mediaPlayer.position)
}
CustomSlider {
id: mediaSlider
backgroundColor: !Config.activeTheme ? "white" : "#41CD52"
backgroundOpacity: !Config.activeTheme ? 0.8 : 0.2
enabled: root.mediaPlayer.seekable
to: 1.0
value: root.mediaPlayer.position / root.mediaPlayer.duration
Layout.fillWidth: true
onMoved: root.mediaPlayer.setPosition(value * root.mediaPlayer.duration)
}
Label {
id: durationTime
color: Config.secondaryColor
font.bold: true
text: root.getTime(root.mediaPlayer.duration)
}
}
}
|