summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/recorder/Controls.qml
blob: 7fbd4c20b5b29c09f93efe472f00040053ed8d68 (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
63
64
65
66
67
68
69
70
71
72
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtMultimedia

Row {
    id: root
    required property MediaRecorder recorder

    property bool settingsVisible: false
    property bool capturesVisible: false

    property alias audioInput: audioInputSelect.selected
    property alias camera: cameraSelect.selected

    spacing: Style.interSpacing * Style.ratio

    Column {
        id: inputControls
        spacing: Style.intraSpacing

        CameraSelect { id: cameraSelect }
        AudioInputSelect { id: audioInputSelect }
    }

    Column {
        width: recordButton.width
        RecordButton {
            id: recordButton
            recording: recorder.recorderState === MediaRecorder.RecordingState
            onClicked: recording ? recorder.stop() : recorder.record()
        }
        Text {
            id: recordingTime
            anchors.horizontalCenter: parent.horizontalCenter
            font.pointSize: Style.fontSize
        }
    }

    Column {
        id: optionButtons
        spacing: Style.intraSpacing
        Button {
            height: Style.height
            width: Style.widthMedium
            background: StyleRectangle { anchors.fill: parent }
            onClicked: root.capturesVisible = !root.capturesVisible
            text: "Captures"
            font.pointSize: Style.fontSize
        }
        Button {
            height: Style.height
            width: Style.widthMedium
            background: StyleRectangle { anchors.fill: parent }
            onClicked: settingsVisible = !settingsVisible
            text: "Settings"
            font.pointSize: Style.fontSize
        }
    }

    Timer {
        running: true; interval: 100; repeat: true
        onTriggered: {
            var m = Math.floor(recorder.duration / 60000)
            var ms = (recorder.duration / 1000 - m * 60).toFixed(1)
            recordingTime.text = `${m}:${ms.padStart(4, 0)}`
        }
    }
}