blob: 7869f95b29404ad1269877654fa60a1684065081 (
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
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
|
import QtQuick 2.0
import Qt.labs.PhononVideo 1.0
Rectangle {
id: toplevel
width: 1280
height: 720
color: "white"
function millisToFormattedTime(millis) {
var str = ""
var s = Math.floor(millis / 1000)
var m = Math.floor(s / 60)
var h = Math.floor(m / 60)
m %= 60
s %= 60
if (h < 10)
str += "0"
str += h
str += ":"
if (m < 10)
str += "0"
str += m
str += ":"
if (s < 10)
str += "0"
str += s
return str
}
Rectangle {
x: parent.width - 70
y: parent.height - 70
width: 50
height: 50
color: "blue"
NumberAnimation on rotation {
loops: Animation.Infinite
from: 360
to: 0
duration: 1000
}
}
Rectangle {
id: window
width: 640 + 10
height: 360 + 35
gradient: Gradient {
GradientStop { position: 0; color: "lightblue" }
GradientStop { position: 1; color: "white" }
}
border.width: 2
border.color: "black"
radius: 5
MouseArea {
anchors.fill: window
property bool resizeLeft: false
property bool resizeRight: false
property bool resizeTop: false
property bool resizeBottom: false
onPressed: {
resizeLeft = (mouse.x < 5)
resizeRight = (mouse.x > window.width - 5)
resizeTop = (mouse.y < 5)
resizeBottom = (mouse.y > window.height - 5)
mouse.accepted = true
}
onPositionChanged: {
if (resizeLeft) {
var delta = Math.min(mouse.x - 2, window.width - 100)
window.width -= delta
window.x += delta
}
if (resizeRight) {
window.width = Math.max(mouse.x + 2, 100)
}
if (resizeTop) {
var delta = Math.min(mouse.y - 2, window.height - 100)
window.height -= delta
window.y += delta
}
if (resizeBottom) {
window.height = Math.max(mouse.y + 2, 100)
}
}
}
MouseArea {
id: titlebar
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 5
height: 20
drag.target: window
drag.axis: Drag.XandYAxis
drag.maximumX: toplevel.width - window.width
drag.maximumY: toplevel.height - window.height
}
Item {
anchors.fill: titlebar
anchors.margins: 3
clip: true
Text {
anchors.centerIn: parent
text: player.source + " (" + millisToFormattedTime(player.time) + "/" + millisToFormattedTime(player.length) + ")"
font.family: "Arial"
font.pixelSize: titlebar.height * 0.7
}
}
PhononVideo {
id: player
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.top: titlebar.bottom
anchors.margins: 5
playing: true
sourceWidth: nativeWidth
sourceHeight: nativeHeight
fillMode: PhononVideo.PreserveAspectFit
// Windows 7 Sample video.
source: "C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"
smooth: true
property real t: 0
property real w: Math.max(0, parent.width - width)
property real h: Math.max(0, parent.height - height)
NumberAnimation on t {
loops: Animation.Infinite
from: 0
to: 10000
duration: 300000
}
onStateChanged: {
if (time >= length) {
time = 0
}
}
MouseArea {
anchors.fill: parent
onClicked: {
player.playing = !player.playing
}
}
Rectangle {
id: progressbar
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 20
height: 10
opacity: 0.5
color: "black"
border.width: 2
border.color: "white"
radius: 5
}
Rectangle {
anchors.top: progressbar.top
anchors.bottom: progressbar.bottom
width: 20
color: "white"
radius: 5
x: progressbar.x + (player.length == 0 ? 0 : (progressbar.width - width) * player.time / player.length)
MouseArea {
anchors.fill: parent
drag.target: parent
drag.axis: Drag.XAxis
drag.minimumX: progressbar.x
drag.maximumX: progressbar.x + progressbar.width - parent.width
property bool wasPlaying: false
onPositionChanged: {
// Only called when dragging.
player.time = player.length * (parent.x - progressbar.x) / (progressbar.width - parent.width)
}
onPressed: {
wasPlaying = player.playing
player.playing = false
mouse.accepted = true
}
onReleased: {
player.playing = wasPlaying
}
}
}
}
}
Rectangle {
x: 20
y: 20
width: 50
height: 50
color: "red"
NumberAnimation on rotation {
loops: Animation.Infinite
from: 0
to: 360
duration: 1000
}
}
}
|