summaryrefslogtreecommitdiffstats
path: root/libmpv/qml_direct/main.qml
blob: a8a68d5f0529e6a3820908aebb028bd93e60fba4 (plain)
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
import QtQuick 2.0
import QtQuick.Controls 1.0

import mpvtest 1.0

Item {
    width: 1280
    height: 720

    MpvObject {
        id: renderer

        // This object isn't real and not visible; it just renders into the
        // background of the containing Window.
        width: 0
        height: 0
    }

    MouseArea {
        anchors.fill: parent
        onClicked: renderer.command(["loadfile", "test.mkv"])
    }

    Rectangle {
        id: labelFrame
        anchors.margins: -50
        radius: 5
        color: "white"
        border.color: "black"
        opacity: 0.8
        anchors.fill: box
    }

    Row {
        id: box
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.margins: 100

        Text {
            anchors.margins: 10
            wrapMode: Text.WordWrap
            text: "QtQuick and mpv are both rendering stuff.\n
                   In this example, mpv is always in the background.\n
                   Click to load test.mkv"
        }

        Column {
            Button {
                anchors.margins: 10
                text: "Reinit QQuickItem renderer (for testing opengl-cb uninit during playback)"
                onClicked: renderer.reinitRenderer()
            }
            Button {
                anchors.margins: 10
                text: "Cycle video"
                onClicked: renderer.command(["cycle", "video"])
            }
        }
    }
}