-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.qml
84 lines (67 loc) · 1.94 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
/*
* SPDX-FileCopyrightText: 2023 George Florea Bănuș <[email protected]>
*
* SPDX-License-Identifier: MIT
*/
import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Window
import QtQuick.Dialogs
import com.example.mpvqt
Window {
width: 1000
height: 600
visible: true
title: mpv.mediaTitle || "press f key to select a file"
MpvItem {
id: mpv
anchors.fill: parent
// do not load file on Component.onCompleted
// onReady: loadFile(["/path/to/video_file.mkv"])
// the results of all the async methods calls are received by MpvItem::onAsyncReply
onFileLoaded: commandAsync(["expand-text", "volume is ${volume}"], MpvItem.ExpandText);
Rectangle {
width: 200
height: 40
Text {
text: `${mpv.formattedPosition} / ${mpv.formattedDuration}`
anchors.centerIn: parent
}
}
Slider {
from: 0
to: mpv.duration
value: mpv.position
onValueChanged: mpv.position = value
anchors.bottom: mpv.bottom
anchors.horizontalCenter: mpv.horizontalCenter
anchors.bottomMargin: 20
width: mpv.width - 50
}
Shortcut {
sequence: "space"
onActivated: mpv.pause = !mpv.pause
}
Shortcut {
sequence: "m"
onActivated: mpv.setPropertyAsync(MpvProperties.Mute, !mpv.getProperty(MpvProperties.Mute))
}
Shortcut {
sequence: "f"
onActivated: fileDialog.open()
}
Shortcut {
sequence: "escape"
onActivated: Qt.quit()
}
}
FileDialog {
id: fileDialog
title: "Select file"
currentFolder: StandardPaths.standardLocations(StandardPaths.MoviesLocation)[0]
onAccepted: {
mpv.loadFile(selectedFile)
}
}
}