-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.qml
More file actions
65 lines (55 loc) · 1.34 KB
/
Main.qml
File metadata and controls
65 lines (55 loc) · 1.34 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
import QtQuick
import org.webrtsp.client 0.1
import org.freedesktop.gstreamer.Qt6GLVideoItem 1.0
Window {
width: 800
height: 600
visible: true
WebRTSPConnection {
id: connection
serverUrl: "wss://ipcam.stream:5555/"
authToken: "token"
stunServerUrl: "stun://global.stun.twilio.com"
}
GstGLQt6VideoItem {
id: video
anchors.fill: parent
}
property WebRTSPPlayer player
property WebRTSPUriInfo rootInfo: connection.uriInfo("*")
Connections {
target: rootInfo
function onListChanged(list) {
console.log("list changed:", list);
playNext();
}
}
property int activeItem: -1
function playNext() {
if(player) {
player.destroy();
player = null;
}
const list = rootInfo.list;
timer.running = list.length > 0;
if(list.length !== 0) {
++activeItem;
if(activeItem >= list.length) {
activeItem = 0;
}
player = connection.player(list[activeItem].uri, video);
}
}
Timer {
id: timer
interval: 10000;
running: false;
repeat: true
onTriggered: {
playNext();
}
}
Component.onCompleted: {
connection.open();
}
}