[vlc-commits] qml: change color scheme of Player widget based on media cover

Prince Gupta git at videolan.org
Mon Feb 8 10:00:04 UTC 2021


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Tue Jan 12 17:23:19 2021 +0530| [38af5d81cbe6988604d812372bf640853c2c9b8f] | committer: Pierre Lamot

qml: change color scheme of Player widget based on media cover

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38af5d81cbe6988604d812372bf640853c2c9b8f
---

 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



More information about the vlc-commits mailing list