File: Main.qml

package info (click to toggle)
mpvqt 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 288 kB
  • sloc: cpp: 946; makefile: 3
file content (84 lines) | stat: -rw-r--r-- 1,990 bytes parent folder | download | duplicates (2)
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ș <georgefb899@gmail.com>
 *
 * 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)
        }
    }
}