summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/recorder
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-09-10 10:08:21 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-10 12:14:38 +0000
commitd9918b395c20694670acf5eec59723f58b30e590 (patch)
treeccc7bfa7edf50cdcc6784c0090d9f65e1614df3e /examples/multimedia/video/recorder
parent6355e75f84f6d4d8847916382057c4f6ab2d9de2 (diff)
Fix capture view in recorder example
Once the capture view had played back a video, it would never move the video output back to the camera, rendering the app unusable for recording until restarted. Fix this by giving the player its own video output, and properly hiding it when not in use. Change-Id: I19bc88b0c6a8bf20dd4d3846a5c843d11ee7f8cb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 782a682be989e0738dff4ce25021e275cb92ff60) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/multimedia/video/recorder')
-rw-r--r--examples/multimedia/video/recorder/Playback.qml31
-rw-r--r--examples/multimedia/video/recorder/main.qml10
2 files changed, 22 insertions, 19 deletions
diff --git a/examples/multimedia/video/recorder/Playback.qml b/examples/multimedia/video/recorder/Playback.qml
index 9ae49d4d3..fdcfd1723 100644
--- a/examples/multimedia/video/recorder/Playback.qml
+++ b/examples/multimedia/video/recorder/Playback.qml
@@ -55,31 +55,36 @@ import QtQuick.Controls
Item {
id: root
- required property VideoOutput videoOutput
property bool active: false
+ property bool playing: false
+ visible: active && playing
function playUrl(url) {
- root.active = true
- if (!videoOutput) {
- console.log("videooutput is null")
- }
-
- mediaPlayer.videoOutput = videoOutput
- mediaPlayer.audioOutput = audioOutput
+ playing = true
mediaPlayer.source = url
mediaPlayer.play()
}
function stop() {
+ playing = false
mediaPlayer.stop()
- mediaPlayer.videoOutput = null
- mediaPlayer.audioOutput = null
- root.active = false
}
- AudioOutput { id: audioOutput }
+ onActiveChanged: function() {
+ if (!active)
+ stop();
+ }
- MediaPlayer { id: mediaPlayer }
+ VideoOutput {
+ anchors.fill: parent
+ id: videoOutput
+ }
+
+ MediaPlayer {
+ id: mediaPlayer
+ videoOutput: videoOutput
+ audioOutput: AudioOutput {}
+ }
HoverHandler { id: hover }
diff --git a/examples/multimedia/video/recorder/main.qml b/examples/multimedia/video/recorder/main.qml
index 42158cf6e..6e32dfc80 100644
--- a/examples/multimedia/video/recorder/main.qml
+++ b/examples/multimedia/video/recorder/main.qml
@@ -68,6 +68,7 @@ Window {
VideoOutput {
id: videoOutput
anchors.fill: parent
+ visible: !playback.playing
}
Popup {
@@ -81,7 +82,7 @@ Window {
recorder: recorder
audioInput: controls.audioInput
camera: controls.camera
- videoOutput: playback.active ? null : videoOutput
+ videoOutput: videoOutput
}
MediaRecorder {
@@ -100,13 +101,10 @@ Window {
Playback {
id: playback
anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- bottom: controls.capturesVisible ? mediaListFrame.top : controlsFrame.top
+ fill: parent
margins: 50
}
- videoOutput: videoOutput
+ active: controls.capturesVisible
}
Frame {