-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.qml
146 lines (127 loc) · 3.4 KB
/
main.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
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
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import org.freedesktop.gstreamer.GLVideoItem 1.0
import Player 1.0
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Deepstream Video Player")
menuBar: MenuBar {
Menu {
id: fileMenu
title: qsTr("&File")
MenuItem {
action: fileOpenAction
}
MenuItem {
action: urlOpenAction
}
}
}
FileDialog {
id: fileOpenDialog
title: qsTr("Select a video file")
folder: shortcuts.movies
nameFilters: {
"Video files (*.mp4 *.avi *.wmv)"
}
onAccepted: player.addVideo(fileUrl);
}
Action {
id: fileOpenAction
text: qsTr("&Open")
onTriggered: fileOpenDialog.open()
}
Dialog {
id: urlOpenDialog
title: qsTr("Open URL")
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: player.addVideo(urlTextField.text)
onRejected: console.log("Cancel clicked")
Column {
Text {
text: qsTr("Please enter a URL: ")
}
TextField {
id: urlTextField
width: 350
selectByMouse: true
}
}
}
Action {
id: urlOpenAction
text: qsTr("Open URL")
onTriggered: urlOpenDialog.open()
}
Item {
anchors.fill: parent
Player {
id: player
output: videoOuput
onPlaylistChanged: {
console.log(playlist)
let model = playlistView.model
model.clear()
for(var i = 0; i < playlist.length; i++) {
model.append({"name": playlist[i]})
}
}
}
GstGLVideoItem {
id: videoOuput
objectName: "videoItem"
anchors.centerIn: parent
width: parent.width
height: parent.height
}
}
Item {
id: playlistItem
anchors.right: parent.right
anchors.top: parent.top
width: 400
height: parent.height
ListView {
id: playlistView
anchors.fill: parent
anchors.margins: 10
spacing: 4
clip: true
orientation: ListView.Vertical
model: ListModel{}
delegate: listItem
}
Component {
id: listItem
Rectangle {
width: playlistView.width
height: 32
color: Qt.rgba(0, 0, 0, 0.2)
Text {
anchors.left: parent.left
width: parent.width - 32
text: index + ": " + name
font.pixelSize: 20
color: Qt.rgba(1, 1, 1, 1.0)
wrapMode: Text.NoWrap
elide: Text.ElideLeft
}
Button {
anchors.right: parent.right
width: 32
height: 32
icon.source: "images/close.png"
opacity: 0.5
onClicked: {
player.removeVideo(index);
}
}
}
}
}
}