summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/mediaplayer
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-06-25 15:17:25 +0200
committerPiotr Srebrny <piotr.srebrny@qt.io>2021-06-28 10:20:39 +0200
commit2b804546a8ee5a16aca50242778d8f8e607e5bbe (patch)
tree1031b0a60bc39885d95afaab66be277458295099 /examples/multimedia/video/mediaplayer
parent72656351ecaf2932b39ff5bac7173b3f73d721ad (diff)
Fix audio handling in the media player example
Adapt to recent API changes that broke that volume/muted handling in this example. Change-Id: I7a3d151fe0ffcc6f937418703bf815b2f75323a5 Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples/multimedia/video/mediaplayer')
-rw-r--r--examples/multimedia/video/mediaplayer/AudioControl.qml18
-rw-r--r--examples/multimedia/video/mediaplayer/PlaybackControl.qml3
-rw-r--r--examples/multimedia/video/mediaplayer/main.qml3
3 files changed, 11 insertions, 13 deletions
diff --git a/examples/multimedia/video/mediaplayer/AudioControl.qml b/examples/multimedia/video/mediaplayer/AudioControl.qml
index f6e9fc619..a3f911b89 100644
--- a/examples/multimedia/video/mediaplayer/AudioControl.qml
+++ b/examples/multimedia/video/mediaplayer/AudioControl.qml
@@ -57,6 +57,8 @@ Item {
id: root
required property MediaPlayer mediaPlayer
+ property bool muted: false
+ property real volume: volumeSlider.value/100.
implicitWidth: 150
implicitHeight: buttons.height
@@ -72,30 +74,20 @@ Item {
RoundButton {
id: muteButton
- visible: !mediaPlayer.muted
radius: 50.0
- icon.source: "qrc:///Speaker_Icon.svg"
- onClicked: { mediaPlayer.setMuted(true) }
- }
-
- RoundButton {
- id: unmuteButton
- visible: mediaPlayer.muted
- radius: 50.0
- icon.source: "qrc:///Mute_Icon.svg"
- onClicked: { mediaPlayer.setMuted(false) }
+ icon.source: muted ? "qrc:///Mute_Icon.svg" : "qrc:///Speaker_Icon.svg"
+ onClicked: { muted = !muted }
}
}
Slider {
+ id: volumeSlider
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
enabled: true
to: 100.0
value: 100.0
-
- onMoved: { mediaPlayer.setVolume(value) }
}
}
}
diff --git a/examples/multimedia/video/mediaplayer/PlaybackControl.qml b/examples/multimedia/video/mediaplayer/PlaybackControl.qml
index 51e4e794d..8809bff57 100644
--- a/examples/multimedia/video/mediaplayer/PlaybackControl.qml
+++ b/examples/multimedia/video/mediaplayer/PlaybackControl.qml
@@ -58,6 +58,8 @@ Item {
required property MediaPlayer mediaPlayer
property int mediaPlayerState: mediaPlayer.playbackState
+ property alias muted: audio.muted
+ property alias volume: audio.volume
implicitHeight: 80
opacity: 1
@@ -139,6 +141,7 @@ Item {
}
AudioControl {
+ id: audio
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
diff --git a/examples/multimedia/video/mediaplayer/main.qml b/examples/multimedia/video/mediaplayer/main.qml
index e88117112..b021e46e2 100644
--- a/examples/multimedia/video/mediaplayer/main.qml
+++ b/examples/multimedia/video/mediaplayer/main.qml
@@ -74,6 +74,9 @@ Window {
id: mediaPlayer
videoOutput: videoOutput
audioOutput: AudioOutput {
+ id: audio
+ muted: playbackControl.muted
+ volume: playbackControl.volume
}
onErrorOccurred: { mediaErrorText.text = mediaPlayer.errorString; mediaError.open() }