From 529dafa55a1dc0cdb9135db316649c0978bcd89a Mon Sep 17 00:00:00 2001 From: eximus Date: Sat, 1 Apr 2017 11:11:58 +0100 Subject: [PATCH] videos played are now random --- Main.qml | 26 ++++++++++++++++--- randomize_playlist.sh => generate_playlist.sh | 0 2 files changed, 22 insertions(+), 4 deletions(-) rename randomize_playlist.sh => generate_playlist.sh (100%) diff --git a/Main.qml b/Main.qml index dbae90a..6d4925e 100644 --- a/Main.qml +++ b/Main.qml @@ -56,9 +56,14 @@ Rectangle { MediaPlayer { id: mediaplayer autoPlay: true - loops: MediaPlayer.Infinite - source: config.background muted: true + playlist: Playlist { + id: playlist + playbackMode: Playlist.Random + onLoaded: { + mediaplayer.play() + } + } } VideoOutput { @@ -67,6 +72,14 @@ Rectangle { source: mediaplayer } + MouseArea { + anchors.fill: parent; + onPressed: { + playlist.shuffle(); + playlist.next(); + } + } + // Clock and Login Area Rectangle { id: rectangle @@ -331,13 +344,18 @@ Rectangle { } } - - // Set Focus Component.onCompleted: { + // Set Focus if (username_input_box.text == "") username_input_box.focus = true else password_input_box.focus = true + + // load and randomize playlist + playlist.load(Qt.resolvedUrl(config.background), 'm3u') + for (var k = 0; k < Math.ceil(Math.random() * 10) ; k++) { + playlist.shuffle() + } } } diff --git a/randomize_playlist.sh b/generate_playlist.sh similarity index 100% rename from randomize_playlist.sh rename to generate_playlist.sh