-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.qml
129 lines (112 loc) · 3.6 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
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtMultimedia 5.15
import Qt.labs.platform 1.1
ApplicationWindow {
visible: true
width: 800
height: 600
title: qsTr("Video Player")
Rectangle {
color: "#121212"
anchors.fill: parent
Rectangle {
color: "#1F1F1F"
height: 50
anchors.top: parent.top
width: parent.width
border.color: "#3C3C3C"
Text {
text: qsTr("Challenge 2 _ Video Player")
color: "#FFFFFF"
font.bold: true
font.pixelSize: 20
anchors.centerIn: parent
}
}
Rectangle {
id: videoContainer
color: "#000000"
width: parent.width * 0.9
height: parent.height * 0.7
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 60
radius: 8
border.color: "#3C3C3C"
Video {
id: videoPlayer
autoPlay: true
anchors.fill: parent
source: "qrc:/resources/videos/test.mp4"
}
Text {
id: noVideoText
text: qsTr("No video loaded.\nClick 'Browse' to select a file.")
color: "#888888"
font.pixelSize: 16
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.centerIn: parent
visible: videoPlayer.source === ""
}
}
Rectangle {
color: "#1F1F1F"
width: parent.width
height: 60
anchors.bottom: parent.bottom
border.color: "#3C3C3C"
Row {
spacing: 7
anchors.centerIn: parent
Button {
text: qsTr("🎥 Browse")
onClicked: {
fileDialog.folder = "file:///storage/emulated/0/Download"
fileDialog.visible = true
}
font.pixelSize: 12
}
Button {
text: qsTr("▶ Play")
enabled: videoPlayer.source !== ""
onClicked: videoPlayer.play()
font.pixelSize: 12
}
Button {
text: qsTr("⏸ Pause")
enabled: videoPlayer.source !== ""
onClicked: videoPlayer.pause()
font.pixelSize: 12
}
Button {
text: qsTr("■ Stop")
enabled: videoPlayer.source !== ""
onClicked: videoPlayer.stop()
font.pixelSize: 12
}
}
}
FileDialog {
id: fileDialog
folder : "file:///storage/emulated/0/Download"
title: qsTr("Select Video File")
onAccepted: {
console.log("from dialg-> fileDialog.file:", fileDialog.file)
videoPlayer.source = fileDialog.file
noVideoText.visible = false
videoPlayer.play()
}
onRejected: {
console.log("File selection canceled")
}
onVisibleChanged: {
if (visible) {
console.log("Dialog opened in folder:", fileDialog.folder)
}
}
visible: false
}
}
}