[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml/VolumeWidget: correctly sync volume with player

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sun Aug 22 14:23:43 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
c5ba7ca6 by Prince Gupta at 2021-08-22T14:00:39+00:00
qml/VolumeWidget: correctly sync volume with player

ref #25971

- - - - -
b621b597 by Prince Gupta at 2021-08-22T14:00:39+00:00
qt: correctly initialize volume

ref #25971

- - - - -


2 changed files:

- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/qml/VolumeWidget.qml


Changes:

=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1046,6 +1046,8 @@ PlayerControllerPrivate::PlayerControllerPrivate(PlayerController *playercontrol
 
     // Initialise fullscreen to match the player state
     m_fullscreen = vlc_player_vout_IsFullscreen( m_player );
+
+    m_volume = vlc_player_aout_GetVolume( m_player );
 }
 
 PlayerController::PlayerController( qt_intf_t *_p_intf )


=====================================
modules/gui/qt/player/qml/VolumeWidget.qml
=====================================
@@ -70,9 +70,11 @@ FocusScope{
             Navigation.rightItem: volControl
         }
 
-        Slider
-        {
+        Slider {
             id: volControl
+
+            property bool _inhibitPlayerVolumeUpdate: false
+
             width: VLCStyle.dp(100, VLCStyle.scale)
             height: parent.height
 
@@ -80,7 +82,6 @@ FocusScope{
             from: 0
             to: maxvolpos
             stepSize: 0.05
-            value: player.volume
             opacity: player.muted ? 0.5 : 1
 
             Accessible.name: i18n.qtr("Volume")
@@ -99,6 +100,23 @@ FocusScope{
                 }
             }
 
+            function _syncVolumeWithPlayer() {
+                if (paintOnly)
+                    return
+
+                volControl._inhibitPlayerVolumeUpdate = true
+                volControl.value = player.volume
+                volControl._inhibitPlayerVolumeUpdate = false
+            }
+
+            Component.onCompleted: volControl._syncVolumeWithPlayer()
+
+            Connections {
+                target: player
+
+                onVolumeChanged: volControl._syncVolumeWithPlayer()
+            }
+
             Timer {
                 // useful for keyboard volume alteration
                 id: tooltipShower
@@ -135,8 +153,14 @@ FocusScope{
             property double maxvolpos: maxvol / 100
 
             onValueChanged: {
-                if (!paintOnly && player.muted) player.muted = false
-                player.volume = volControl.value
+                if (paintOnly)
+                    return
+
+                if (player.muted)
+                    player.muted = false
+
+                if (!volControl._inhibitPlayerVolumeUpdate)
+                    player.volume = volControl.value
             }
 
             Widgets.PointingTooltip {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bd384d23347e184a2dbf31f00d92eced3a514670...b621b597c05622bb47d6fd1095e8412d1337c015

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bd384d23347e184a2dbf31f00d92eced3a514670...b621b597c05622bb47d6fd1095e8412d1337c015
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list