-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
120 lines (108 loc) · 3.33 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
import QtQuick 2.2
import QtQuick.Window 2.1
import QtMultimedia 5.0
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import VideoFrame.Controls 1.0
import VideoPlayer.Controls 1.0
Window {
visible: true
width: 1080
height: 960
title: qsTr("VideoOutput")
property var videocontrol: null
VideoFrameProvider {
id: provider
// videoUrl: "rtsp://xxx.xxx.xxx/channel=1"
}
// VideoPlayer {
// id: videocontrol
// // videoUrl: "rtsp://xxx.xxx.xxx/channel=1"
// Component.onCompleted: {
// console.log("VideoPlayer");
// }
// }
VideoOutput {
width: 640 // 设置宽度为 640
height: 480 // 设置高度为 480
anchors.fill: parent
source: provider
}
FileDialog {
id: fileDialog
title: "Select a file"
folder: shortcuts.movies // 默认打开的文件夹
onAccepted: {
console.log("Selected file: " + fileUrl)
videocontrol.set_url(fileUrl);
//selectedFileUrl.text = fileUrl // 显示选中文件的 URL
}
onRejected: {
console.log("File selection canceled")
}
}
Row {
id: controller
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 4
spacing: 4
FlatButton {
text: "Open File"
iconSource: "打开文件夹.png"
onClicked: {
if (!videocontrol) {
// 动态创建 VideoPlayer 对象
try {
videocontrol = Qt.createQmlObject('
import VideoPlayer.Controls 1.0;
VideoPlayer {
id: videocontrol;
}', parent, "dynamicvideocontrol");
console.log("VideoPlayer created successfully");
} catch (error) {
console.error("Error creating VideoPlayer:", error);
}
}
fileDialog.open(); // 打开文件对话框
}
}
FlatButton {
id: start
text: "play"
iconSource: "ic_play.png"
onClicked: {
videocontrol.Init();
videocontrol.setVideoFrameProvider(provider)
videocontrol.Play()
}
}
FlatButton {
id: pause
text: "pause"
iconSource: "ic_pause.png"
onClicked: {
videocontrol.Pause()
}
}
FlatButton {
id: stop
text: "stop"
iconSource: "ic_stop.png"
onClicked: {
videocontrol.Stop();
videocontrol.destroy(); // Destroys the VideoPlayer object
}
}
// FlatButton {
// id: destroy
// text: "destroy"
// iconSource: "ic_stop.png"
// onClicked: {
// videocontrol.destroy(); // Destroys the VideoPlayer object
// }
// }
}
}