-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.qml
More file actions
77 lines (70 loc) · 2.5 KB
/
main.qml
File metadata and controls
77 lines (70 loc) · 2.5 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
66
67
68
69
70
71
72
73
74
75
76
77
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtMultimedia 5.14
import QtQuick.Dialogs 1.2
// import com.example 1.0 // Import your C++ module
ApplicationWindow {
visible: true
width: 640
height: 480
title: "Qt + MLT Example"
Rectangle {
width: 640
height: 480
color: "black"
// VideoOutput to display the video
VideoOutput {
id: videoOutput
anchors.fill: parent
// MediaPlayer for playing the video
source: mediaPlayer
}
Row{
anchors.bottom: parent
spacing: 20
Button {
text: "视频合成"
// anchors.bottom: parent.right
anchors.horizontalCenter: parent.horizontalRight
onClicked: {
// Open the file dialog to choose a video file
// fileDialog.open()
worker.doCompose()
}
}
// Button to open FileDialog to select a video file
Button {
text: "Select Video"
// anchors.top: parent.
anchors.horizontalCenter: parent.horizontalLeft
onClicked: {
// Open the file dialog to choose a video file
fileDialog.open()
}
}
}
// FileDialog to allow the user to select a video file
FileDialog {
id: fileDialog
title: "Select a Video"
folder: "file:///C:/" // default folder (you can set this dynamically)
nameFilters: ["Video Files (*.mp4 *.avi *.mov)"] // File types
onAccepted: {
// When a file is selected, set it as the source of the MediaPlayer
mediaPlayer.source = fileDialog.fileUrl
// console.log("Open: ", mediaPlayer.source)
mediaPlayer.play()
}
}
// MediaPlayer to handle video playback
MediaPlayer {
id: mediaPlayer
// source: "gst-pipeline: filesrc location=../main/main.mp4 ! qtdemux ! avdec_h264 ! qtvideosink"
source: "../main/main.mp4"
autoPlay: false // Set to false since you control play via button click
onError: {
console.log("Error: " + mediaPlayer.errorString) // Log errors if any
}
}
}
}