From 6429ee53320201fdd8664faa67d9e11c310d718b Mon Sep 17 00:00:00 2001 From: Chris Josten Date: Sun, 27 Sep 2020 20:51:07 +0200 Subject: [PATCH] Prevent device from sleeping while media is playing I was testing the entire time on net power, so I forgot that the device goes to sleep after a while. --- qml/harbour-sailfin.qml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/qml/harbour-sailfin.qml b/qml/harbour-sailfin.qml index 0d1a658..ebfd280 100644 --- a/qml/harbour-sailfin.qml +++ b/qml/harbour-sailfin.qml @@ -21,7 +21,9 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import QtMultimedia 5.6 import nl.netsoj.chris.Jellyfin 1.0 + import Nemo.Notifications 1.0 +import Nemo.KeepAlive 1.2 import "components" import "pages" @@ -52,11 +54,6 @@ ApplicationWindow { } } - MediaPlayer { - id: _mediaPlayer - autoPlay: true - } - initialPage: Component { MainPage { Connections { @@ -95,4 +92,19 @@ ApplicationWindow { publish(); } } + + MediaPlayer { + id: _mediaPlayer + autoPlay: true + } + + // Keep the sytem alive while playing media + KeepAlive { + enabled: _mediaPlayer.playbackState == MediaPlayer.PlayingState + } + + DisplayBlanking { + preventBlanking: _mediaPlayer.playbackState == MediaPlayer.PlayingState && _mediaPlayer.hasVideo + } + }