Skip to content

Commit

Permalink
Add delay on startup & pausing and fix audio muting
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbocanegra committed Mar 19, 2024
1 parent 02cb5c2 commit ccceaee
Showing 1 changed file with 50 additions and 38 deletions.
88 changes: 50 additions & 38 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,71 @@ import QtMultimedia
WallpaperItem {
anchors.fill: parent
id: main
property string videoWallpaperBackgroundVideo: wallpaper.configuration.VideoWallpaperBackgroundVideo
property bool playing: windowModel.playVideoWallpaper
property bool isLoading: true
onPlayingChanged: playing && !isLoading ? main.play() : main.pause()
onVideoWallpaperBackgroundVideoChanged: {
if (isLoading) return
updateState()
}

WindowModel {
id: windowModel
screenGeometry: main.parent.screenGeometry
}

Rectangle {
id: background
anchors.fill: parent
color: wallpaper.configuration.BackgroundColor
property string videoWallpaperBackgroundVideo: wallpaper.configuration.VideoWallpaperBackgroundVideo
property bool playing: windowModel.playVideoWallpaper
onPlayingChanged: background.playing ? playlistplayer.play() : playlistplayer.pause()

onVideoWallpaperBackgroundVideoChanged: {
if (playing) {
playlistplayer.play()
} else {
playlistplayer.play()
playlistplayer.pause()
}
Video {
id: player
source: wallpaper.configuration.VideoWallpaperBackgroundVideo
loops: MediaPlayer.Infinite
fillMode: wallpaper.configuration.FillMode
anchors.fill: parent
volume: wallpaper.configuration.MuteAudio ? 0.0 : 1
}
}

WindowModel {
id: windowModel
screenGeometry: main.parent.screenGeometry
}
function play(){
pauseTimer.stop();
player.play();
}
function pause(){
pauseTimer.start();
}

MediaPlayer {
id: playlistplayer
activeAudioTrack: -1 //muted: wallpaper.configuration.MuteAudio
source: wallpaper.configuration.VideoWallpaperBackgroundVideo
videoOutput: videoView
loops: MediaPlayer.Infinite
function updateState() {
if (playing) {
main.pause()
main.play()
} else {
main.play()
main.pause()
}
}

VideoOutput {
id: videoView
fillMode: wallpaper.configuration.FillMode
anchors.fill: parent
Timer {
id: pauseTimer
interval: 300
onTriggered: {
player.pause()
}
}

function dumpProps(obj) {
console.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
for (var k of Object.keys(obj)) {
print(k + "=" + obj[k]+"\n")
Timer {
id: startTimer
interval: 3000
onTriggered: {
isLoading = false
updateState()
}
}

// Timer {
// id: debugTimer
// interval: 1000
// repeat: true
// running: true
// onTriggered: {
// //
// }
// }
Component.onCompleted: {
startTimer.start()
}
}

0 comments on commit ccceaee

Please sign in to comment.