summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/recorder/Playback.qml
blob: 78575ae268878bf810847b762238561445dc379a (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtMultimedia
import QtQuick.Controls

Item {
    id: root

    property bool active: false
    property bool playing: false
    visible: active && playing

    function playUrl(url) {
        playing = true
        mediaPlayer.source = url
        mediaPlayer.play()
    }

    function stop() {
        playing = false
        mediaPlayer.stop()
    }

    onActiveChanged: function() {
        if (!active)
            stop();
    }

    VideoOutput {
        anchors.fill: parent
        id: videoOutput
    }

    MediaPlayer {
        id: mediaPlayer
        videoOutput: videoOutput
        audioOutput: AudioOutput {}
    }

    HoverHandler { id: hover }

    RoundButton {
        width: 50
        height: 50
        opacity: hover.hovered && active ? 1.0 : 0.0
        anchors.centerIn: root
        radius: 25
        text: "\u25A0";
        onClicked: root.stop()

        Behavior on opacity { NumberAnimation { duration: 200 } }
    }
}