blob: c94d844f83d3a3e5da05a5cdae98087a725d0aa0 (
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
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtMultimedia
Item {
id: seekController
required property MediaPlayer mediaPlayer
property alias busy: slider.pressed
implicitHeight: 20
function formatToMinutes(milliseconds) {
const min = Math.floor(milliseconds / 60000)
const sec = ((milliseconds - min * 60000) / 1000).toFixed(1)
return `${min}:${sec.padStart(4, 0)}`
}
RowLayout {
anchors.fill: parent
spacing: 22
//! [0]
Text {
id: currentTime
Layout.preferredWidth: 45
text: seekController.formatToMinutes(seekController.mediaPlayer.position)
horizontalAlignment: Text.AlignLeft
font.pixelSize: 11
}
//! [0]
Slider {
id: slider
Layout.fillWidth: true
//! [2]
enabled: seekController.mediaPlayer.seekable
value: seekController.mediaPlayer.position / seekController.mediaPlayer.duration
//! [2]
onMoved: seekController.mediaPlayer.setPosition(value * seekController.mediaPlayer.duration)
}
//! [1]
Text {
id: remainingTime
Layout.preferredWidth: 45
text: seekController.formatToMinutes(seekController.mediaPlayer.duration - seekController.mediaPlayer.position)
horizontalAlignment: Text.AlignRight
font.pixelSize: 11
}
//! [1]
}
}
|