-
Notifications
You must be signed in to change notification settings - Fork 0
/
Song_slider.qml
70 lines (65 loc) · 1.71 KB
/
Song_slider.qml
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
59
60
61
62
63
64
65
66
67
68
69
70
import QtQuick 2.0
import QtQuick.Controls 2.2
//slider
Slider {
id:song_slider
property double time_position: 0
wheelEnabled: true
orientation: Qt.Vertical
from: 0
value: time_position
to: player.time
implicitWidth: 26
implicitHeight: parent.height-100
stepSize: 200
//release
onPressedChanged: {
if(pressed && play_state)
timer.stop()
if( !pressed && play_state){
player.play_from(value)
timer.restart()
}
}
//移動顯示
handle: Rectangle {
x: song_slider.leftPadding + song_slider.availableWidth/2 - width/2
y: song_slider.bottomPadding + song_slider.visualPosition * (song_slider.availableHeight - height)
implicitWidth: 26
implicitHeight: 26
radius: 13
color: song_slider.pressed ? "#f0f0f0" : "#f6f6f6"
border.color: "#e6e6fa"
Text {
id: t
text: {
Math.floor(song_slider.value/60000)+":"+
Math.floor(song_slider.value/1000)%60+":"+
Math.floor(song_slider.value%1000)
}
}
}
//slider time/val update
Timer{
id:timer
interval: 64
running: play_state
repeat: true
onTriggered: {
song_slider.value = player.get_position()
}
}
onValueChanged: {
//譜面連動
if(lane.contenty !== view_height - song_slider.value ){
setValue(song_slider.value)
}
if(song_slider.value>=player.time - 10){
player.pause()
play_state = false
}
}
function setValue(value){
lane.contenty = view_height - value
}
}