Repository navigation
Expand file tree
/
Copy pathBottomControlView.qml
More file actions
335 lines (322 loc) · 8.58 KB
/
Copy pathBottomControlView.qml
File metadata and controls
335 lines (322 loc) · 8.58 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtMultimedia 5.8
Rectangle
{
property bool isPlay: false
property var leyalPlay: (function(url)
{
mediaplayer.source = url;
playPauseBtn.state = "play"
mediaplayer.play();
// bottomControlView.isPlay = !bottomControlView.isPlay
})
id:bottomControlView
width: 1050*dp
height: 63*dp
// color: "#D8D8D8"
anchors
{
left:parent.left
leftMargin:0
right:parent.right
rightMargin:0
bottom:parent.bottom
}
MediaPlayer
{
id:mediaplayer
source:"https://lc-ba69fjyb.cn-n1.lcfile.com/c6eed7879d00b5310a0c.mp3"
onStopped:
{
playPauseBtn.state = "pause"
}
}
//时间格式化
function currentTime(time)
{
var sec= Math.floor(time/1000);
var hours=Math.floor(sec/3600);
var minutes=Math.floor((sec-hours*3600)/60);
var seconds=sec-hours*3600-minutes*60;
var hh,mm,ss;
if(hours.toString().length<2)
hh="0"+hours.toString();
else
hh=hours.toString();
if(minutes.toString().length<2)
mm="0"+minutes.toString();
else
mm=minutes.toString();
if(seconds.toString().length<2)
ss="0"+seconds.toString();
else
ss=seconds.toString();
return mm+":"+ss
}
Rectangle
{
id:diverLine3
width: 1050*dp
height: 1*dp
color: "#706D6D"
anchors
{
top:parent.top
topMargin:0
left:parent.left
leftMargin:0
right:parent.right
rightMargin:0
}
}
MyImageButton
{
_width:33*dp
_height:33*dp
_normalSource:"qrc:/NeteasCloudImages/lowerButtonNormal.png"
_pressSource:"qrc:/NeteasCloudImages/lowerButtonPress.png"
anchors
{
left:parent.left
leftMargin:10*dp
verticalCenter:parent.verticalCenter
}
onButtonClicked: function()
{
console.log("上一首")
}
}
//播放暂停
MyImageButton
{
id:playPauseBtn
_width:38*dp
_height:38*dp
_normalSource:"qrc:/NeteasCloudImages/playButtonNormal.png"
// _pressSource:"qrc:/NeteasCloudImages/playButtonNormal.png"
anchors
{
left:parent.left
leftMargin:75*dp
verticalCenter:parent.verticalCenter
}
states: [
State {
name: "play"
PropertyChanges {
target: playPauseBtn
_normalSource:"qrc:/NeteasCloudImages/pauseButton.png"
}
},
State {
name: "pause"
PropertyChanges {
target: playPauseBtn
_normalSource:"qrc:/NeteasCloudImages/playButtonNormal.png"
}
}
]
onButtonClicked: function()
{
if(mediaplayer.hasAudio)
{
if(playPauseBtn.state==="play")
{
playPauseBtn.state="pause";
mediaplayer.pause();
}
else
{
playPauseBtn.state="play";
mediaplayer.play();
}
}
}
}
MyImageButton
{
_width:33*dp
_height:33*dp
_normalSource:"qrc:/NeteasCloudImages/upperButtonNormal.png"
_pressSource:"qrc:/NeteasCloudImages/upperButtonPress.png"
anchors
{
left:parent.left
leftMargin:145*dp
verticalCenter:parent.verticalCenter
}
onButtonClicked: function()
{
console.log("下一首")
}
}
//进度条
Slider{
id:playPos
width:bottomControlView.width*0.45
height: 10
maximumValue: mediaplayer.duration
minimumValue: 0
value:mediaplayer.position
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 220*dp
stepSize:1000
function updateData()
{
playPos.value= mediaplayer.duration * mouse.x/parent.width
}
style: SliderStyle {
groove: Rectangle {
width: bottomControlView.width*0.45
height: 3
color: "gray"
radius: 1
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: mediaplayer.duration>0?parent.width*mediaplayer.position/mediaplayer.duration:0
color: "red"
}
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "darkgray"
border.color: "#A51100"
border.width: 4
implicitWidth: 12
implicitHeight:12
radius:6
Rectangle{
width: 4
height: width
radius: width/2
color: "white"
anchors.centerIn: parent
}
}
}
//点击鼠标设置播放位置
MouseArea {
property int pos
anchors.fill: parent
onClicked: {
if (mediaplayer.seekable)
pos = mediaplayer.duration * mouse.x/parent.width
mediaplayer.seek(pos)
playPos.value=pos
}
}
}
Text {
id: sliderValue
color: "black"
text:bottomControlView.currentTime(mediaplayer.position)+"/"+bottomControlView.currentTime(mediaplayer.duration)
anchors
{
verticalCenter:parent.verticalCenter
left:playPos.right
leftMargin:10*dp
}
}
//音量
Image
{
id:voiceIcon
width: 20*dp
height: 16*dp
source: "qrc:/NeteasCloudImages/voiceButton.png"
anchors
{
right:parent.right
rightMargin:235*dp
verticalCenter:parent.verticalCenter
}
MouseArea
{
anchors.fill: parent
onClicked:rightWdRouter("qrc:/LeftScrollView.qml",{})
}
}
//调节音量
Slider{
id:voice
width: 125*dp
height: 10
anchors.verticalCenterOffset: 0
value:mediaplayer.volume
stepSize: 0.1
maximumValue: 1
minimumValue: 0
anchors.verticalCenter: parent.verticalCenter
anchors.left: voiceIcon.right
anchors.leftMargin: 5*dp
onValueChanged:
{
mediaplayer.volume = value
}
style: SliderStyle {
groove: Rectangle {
implicitWidth: 120*dp
implicitHeight: 3
color: "gray"
radius: 2
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: mediaplayer.volume>0?parent.width*mediaplayer.volume:0
color: "red"
}
}
handle: Rectangle {
anchors.centerIn: parent
color: "white"
border.color: "black"
border.width: 1
implicitWidth: 8
implicitHeight: 8
radius:4
}
}
}
//歌词按钮
Image
{
id:lyric
width: 16*dp
height: 16*dp
source: "qrc:/NeteasCloudImages/lyricButton.png"
anchors
{
verticalCenter:parent.verticalCenter
right:parent.right
rightMargin:82*dp
}
MouseArea
{
anchors.fill: parent
onClicked:
{
// rightWdRouter("qrc:/LyricView.qml",{})
}
}
}
//更多按钮
Image
{
id:moreButton
width: 18*dp
height: 14*dp
source:"qrc:/NeteasCloudImages/menuButton.png"
anchors
{
verticalCenter:parent.verticalCenter
right:parent.right
rightMargin:41*dp
}
}
}