[vlc-devel] [PATCH 13/33] qml: change color scheme of Player widget based on media cover

Prince Gupta guptaprince8832 at gmail.com
Wed Feb 3 10:56:29 UTC 2021


---
 modules/gui/qt/player/qml/Player.qml | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt/player/qml/Player.qml b/modules/gui/qt/player/qml/Player.qml
index eb1c179893..be4cde2d53 100644
--- a/modules/gui/qt/player/qml/Player.qml
+++ b/modules/gui/qt/player/qml/Player.qml
@@ -36,8 +36,11 @@ Widgets.NavigableFocusScope {
 
     property bool hasEmbededVideo: mainInterface.hasEmbededVideo
     readonly property int positionSliderY: controlBarView.y + VLCStyle.fontHeight_normal + VLCStyle.margin_small
-
-    property VLCColors colors: VLCStyle.nightColors
+    readonly property string coverSource: (mainPlaylistController.currentItem.artwork && mainPlaylistController.currentItem.artwork.toString())
+                                          ? mainPlaylistController.currentItem.artwork
+                                          : VLCStyle.noArtCover
+    readonly property VLCColors colors: (mainInterface.hasEmbededVideo || (coverLuminance.luminance < 140))
+                                        ? VLCStyle.nightColors : VLCStyle.dayColors
 
     function dismiss() {
         if (_menu)
@@ -76,6 +79,13 @@ Widgets.NavigableFocusScope {
         }
     }
 
+    ImageLuminanceExtractor {
+        id: coverLuminance
+
+        enabled: !rootPlayer.hasEmbededVideo
+        source: rootPlayer.coverSource
+    }
+
     Widgets.DrawerExt {
         id: csdGroup
 
@@ -334,9 +344,8 @@ Widgets.NavigableFocusScope {
 
                     Image {
                         id: cover
-                        source: (mainPlaylistController.currentItem.artwork && mainPlaylistController.currentItem.artwork.toString())
-                                ? mainPlaylistController.currentItem.artwork
-                                : VLCStyle.noArtCover
+
+                        source: rootPlayer.coverSource
                         fillMode: Image.PreserveAspectFit
 
                         //source aspect ratio
-- 
2.25.1



More information about the vlc-devel mailing list