blob: f93dabcddfc2ad8e65108fc4398b2fd75daa89b8 (
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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
Scene {
id: root
property real itemWidth: (width / 3) - 40
property real itemTopMargin: 50
QtObject {
id: contentProxy
function initialize() {
video1.initialize()
video2.initialize()
}
}
Component {
id: startStopComponent
Rectangle {
id: root
color: "transparent"
signal start
signal stop
Label {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
margins: 20
}
// qmllint disable
text: root.started ? qsTr("Tap to stop") : qsTr("Tap to start")
// qmllint enable
}
MouseArea {
anchors.fill: parent
// qmllint disable
onClicked: {
if (root.started)
root.stop()
else
root.start()
}
// qmllint enable
}
}
}
Content {
id: video1
anchors {
left: parent.left
leftMargin: 10
top: parent.top
topMargin: root.itemTopMargin
}
autoStart: false
contentType: "video"
showBorder: true
showFrameRate: started
source: parent.source1
width: root.itemWidth
volume: parent.volume
Loader {
id: video1StartStopLoader
property bool started: parent.started
onLoaded: {
item.parent = video1
item.anchors.fill = video1
item.start.connect(video1.start)
item.stop.connect(video1.stop)
}
}
onInitialized: video1StartStopLoader.sourceComponent = startStopComponent
}
Rectangle {
id: cameraHolder
property bool started: false
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: root.itemTopMargin
}
border.width: 1
border.color: palette.base
color: "transparent"
width: root.itemWidth
height: width
Loader {
id: cameraLoader
onLoaded: {
item.parent = cameraHolder
item.anchors.centerIn = cameraHolder
item.contentType = "camera"
item.showFrameRate = true
item.width = root.itemWidth
item.z = 1.0
cameraErrorConnection.target = item
item.initialize()
}
}
Loader {
id: cameraStartStopLoader
property bool started: parent.started
sourceComponent: startStopComponent
onLoaded: {
item.parent = cameraHolder
item.anchors.fill = cameraHolder
item.z = 2.0
item.start.connect(cameraHolder.start)
item.stop.connect(cameraHolder.stop)
}
}
Connections {
id: cameraErrorConnection
function onError() {
console.log("[qmlvideo] SceneMulti.camera.onError")
cameraHolder.stop()
}
ignoreUnknownSignals: true
}
function start() {
cameraLoader.source = "Content.qml"
cameraHolder.started = true
}
function stop() {
cameraLoader.source = ""
cameraHolder.started = false
}
}
Content {
id: video2
anchors {
right: parent.right
rightMargin: 10
top: parent.top
topMargin: root.itemTopMargin
}
autoStart: false
contentType: "video"
showBorder: true
showFrameRate: started
source: parent.source2
width: root.itemWidth
volume: parent.volume
Loader {
id: video2StartStopLoader
property bool started: parent.started
onLoaded: {
item.parent = video2
item.anchors.fill = video2
item.start.connect(video2.start)
item.stop.connect(video2.stop)
}
}
onInitialized: video2StartStopLoader.sourceComponent = startStopComponent
}
Component.onCompleted: root.content = contentProxy
}
|