[vlc-commits] [Git][videolan/vlc][master] qml: don't show fallback image immediately while loading MediaCover

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jul 26 09:40:43 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
f993009c by Pierre Lamot at 2024-07-26T09:26:07+00:00
qml: don't show fallback image immediately while loading MediaCover

Showing a blank rectangle (which is already drawn behind the image) is cheaper
than loading the fallback image. The fallback image is still displayed if the
regular image fails to load or takes more time to load than a `humanMoment`

* When the image starts loading: `root.isImageReady` is false (`Image.Loading`),
  timer is running, no image is visible, the background is drawn

* If the image finish loading successfully: `root.isImageReady` becomes true the
  fallback is not loaded

* If the image finish fails to load: `root.isImageReady` remains false and
  `timer.running` becomes false (`Image.Error`), the fallback image becomes
  visible

* If the image takes a long time to load: `root.isImageReady` remains false, timer
  times out so `timer.running` becomes false, the fallback image is loaded

- - - - -


1 changed file:

- modules/gui/qt/widgets/qml/MediaCover.qml


Changes:

=====================================
modules/gui/qt/widgets/qml/MediaCover.qml
=====================================
@@ -68,6 +68,16 @@ Rectangle {
 
     // Children
 
+    //delay placeholder showing up
+    Timer {
+        id: timer
+        //changing running value will start/stop the timer,
+        //the running value will change back to false when the timer
+        //timeout regardless of the binding
+        running: image.state === Image.Loading
+        interval: VLCStyle.duration_long
+    }
+
     Widgets.RoundImage {
         id: image
 
@@ -88,7 +98,7 @@ Rectangle {
 
         radius: root.radius
 
-        visible: !root.isImageReady
+        visible: !root.isImageReady && !timer.running
 
         // we only keep this image till there is no main image
         // try to release the resources otherwise



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/f993009c6e190eb129591d93e21f830e12d11a1e

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


VideoLAN code repository instance


More information about the vlc-commits mailing list