From c9c592014d05c078b09ac21b94301108ff40f912 Mon Sep 17 00:00:00 2001 From: Keyitdev <70140437+Keyitdev@users.noreply.github.com> Date: Fri, 3 Jan 2025 21:52:18 +0100 Subject: [PATCH] Update: Some changes in Main.qml regarding background and video player. --- Main.qml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Main.qml b/Main.qml index e8feda6..9d28318 100644 --- a/Main.qml +++ b/Main.qml @@ -180,6 +180,13 @@ Pane { ] } + Image { + id: backgroundPlaceholderImage + + z: 10 + source: config.BackgroundPlaceholder + visible: false + } AnimatedImage { id: backgroundImage @@ -189,13 +196,18 @@ Pane { videoOutput: videoOutput autoPlay: true + playbackRate: config.BackgroundSpeed == "" ? 1.0 : config.BackgroundSpeed loops: -1 + onPlayingChanged: { + console.log("Video started.") + backgroundPlaceholderImage.visible = false; + } } VideoOutput { id: videoOutput - fillMode: config.CropBackground == "true" ? Image.PreserveAspectCrop : Image.PreserveAspectFit + fillMode: config.CropBackground == "true" ? VideoOutput.PreserveAspectCrop : VideoOutput.PreserveAspectFit anchors.fill: parent } @@ -215,7 +227,6 @@ Pane { Image.AlignBottom : Image.AlignVCenter speed: config.BackgroundSpeed == "" ? 1.0 : config.BackgroundSpeed - source: config.BackgroundPlaceholder paused: config.PauseBackground == "true" ? 1 : 0 fillMode: config.CropBackground == "true" ? Image.PreserveAspectCrop : Image.PreserveAspectFit asynchronous: true @@ -225,8 +236,9 @@ Pane { Component.onCompleted:{ var fileType = config.Background.substring(config.Background.lastIndexOf(".") + 1) - - if (fileType === "mp4" || fileType === "mov" || fileType === "avi" || fileType === "webm") { + const videoFileTypes = ["avi", "mp4", "mov", "mkv", "m4v", "webm"]; + if (videoFileTypes.includes(fileType)) { + backgroundPlaceholderImage.visible = true; player.source = Qt.resolvedUrl(config.Background) player.play(); }