summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/declarative-camera/VideoPreview.qml
blob: f7b306794c38003b70fc5a7e21bca36d23ed9197 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtMultimedia

Item {
    id: videoPreview
    property alias source : player.source
    signal closed

    MediaPlayer {
        id: player

        //switch back to viewfinder after playback finished
        onMediaStatusChanged: {
            if (mediaStatus == MediaPlayer.EndOfMedia)
                videoPreview.closed();
        }
        onSourceChanged: {
            if (videoPreview.visible && source !== "")
                play();
        }

        videoOutput: output
        audioOutput: AudioOutput {
        }
    }

    VideoOutput {
        id: output
        anchors.fill : parent
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            videoPreview.closed();
        }
    }
}