summaryrefslogtreecommitdiffstats
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 16:57:10 +0000
commit393d930faa465e2c5d28cfea276fdfc3ceeae8aa (patch)
tree5a522b550caf6e469df1ec35d99d7f723d27bcdc
parent5205f17aef80c3b4f9f7e4d5bc88f62ec7601ccf (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>
-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 {