Update: Some changes in Main.qml regarding background and video player.

This commit is contained in:
Keyitdev
2025-01-03 21:52:18 +01:00
parent 8a6ed165c2
commit c9c592014d
+16 -4
View File
@@ -180,6 +180,13 @@ Pane {
] ]
} }
Image {
id: backgroundPlaceholderImage
z: 10
source: config.BackgroundPlaceholder
visible: false
}
AnimatedImage { AnimatedImage {
id: backgroundImage id: backgroundImage
@@ -189,13 +196,18 @@ Pane {
videoOutput: videoOutput videoOutput: videoOutput
autoPlay: true autoPlay: true
playbackRate: config.BackgroundSpeed == "" ? 1.0 : config.BackgroundSpeed
loops: -1 loops: -1
onPlayingChanged: {
console.log("Video started.")
backgroundPlaceholderImage.visible = false;
}
} }
VideoOutput { VideoOutput {
id: videoOutput id: videoOutput
fillMode: config.CropBackground == "true" ? Image.PreserveAspectCrop : Image.PreserveAspectFit fillMode: config.CropBackground == "true" ? VideoOutput.PreserveAspectCrop : VideoOutput.PreserveAspectFit
anchors.fill: parent anchors.fill: parent
} }
@@ -215,7 +227,6 @@ Pane {
Image.AlignBottom : Image.AlignVCenter Image.AlignBottom : Image.AlignVCenter
speed: config.BackgroundSpeed == "" ? 1.0 : config.BackgroundSpeed speed: config.BackgroundSpeed == "" ? 1.0 : config.BackgroundSpeed
source: config.BackgroundPlaceholder
paused: config.PauseBackground == "true" ? 1 : 0 paused: config.PauseBackground == "true" ? 1 : 0
fillMode: config.CropBackground == "true" ? Image.PreserveAspectCrop : Image.PreserveAspectFit fillMode: config.CropBackground == "true" ? Image.PreserveAspectCrop : Image.PreserveAspectFit
asynchronous: true asynchronous: true
@@ -225,8 +236,9 @@ Pane {
Component.onCompleted:{ Component.onCompleted:{
var fileType = config.Background.substring(config.Background.lastIndexOf(".") + 1) var fileType = config.Background.substring(config.Background.lastIndexOf(".") + 1)
const videoFileTypes = ["avi", "mp4", "mov", "mkv", "m4v", "webm"];
if (fileType === "mp4" || fileType === "mov" || fileType === "avi" || fileType === "webm") { if (videoFileTypes.includes(fileType)) {
backgroundPlaceholderImage.visible = true;
player.source = Qt.resolvedUrl(config.Background) player.source = Qt.resolvedUrl(config.Background)
player.play(); player.play();
} }