Add screensaver to MovieSelection preview mode
authorlittlesat <littlesat99@yahoo.com>
Fri, 22 May 2015 17:11:51 +0000 (19:11 +0200)
committerlittlesat <littlesat99@yahoo.com>
Fri, 22 May 2015 17:11:51 +0000 (19:11 +0200)
So when audio files are played with the movie player you also get the
ScreenSaver. As discussed here: http://forums.openpli.org/topic/38018-screensaver-schijnt-niet-te-werken-in-movieplayer-bij-mp3/

lib/python/Screens/MovieSelection.py

index ab97729..4504bf7 100644 (file)
@@ -23,6 +23,8 @@ from Screens.ChoiceBox import ChoiceBox
 from Screens.LocationBox import MovieLocationBox
 from Screens.HelpMenu import HelpableScreen
 from Screens.InputBox import PinInput
+from Screens import ScreenSaver
+from Screens import Standby
 import Screens.InfoBar
 
 from Tools import NumericalTextInput
@@ -32,10 +34,11 @@ import Tools.Trashcan
 import NavigationInstance
 import RecordTimer
 
-from enigma import eServiceReference, eServiceCenter, eTimer, eSize, iPlayableService, iServiceInformation, getPrevAsciiCode, eRCInput
+from enigma import eServiceReference, eServiceCenter, eTimer, eSize, iPlayableService, iServiceInformation, getPrevAsciiCode, eRCInput, eActionMap
 import os
 import time
 import cPickle as pickle
+from sys import maxint
 
 config.movielist = ConfigSubsection()
 config.movielist.moviesort = ConfigInteger(default=MovieList.SORT_GROUPWISE)
@@ -501,7 +504,28 @@ class MovieSelectionSummary(Screen):
                else:
                        self["name"].text = ""
 
-class MovieSelection(Screen, HelpableScreen, SelectionEventInfo, InfoBarBase, ProtectedScreen):
+from Screens.InfoBarGenerics import InfoBarScreenSaver
+class MovieSelectionScreenSaver(InfoBarScreenSaver):
+
+       def ScreenSaverTimerStart(self):
+               time = int(config.usage.screen_saver.value)
+               if time:
+                       ref = self.session.nav.getCurrentlyPlayingServiceOrGroup()
+                       if ref and not (hasattr(self.session, "pipshown") and self.session.pipshown):
+                               ref = ref.toString().split(":")
+                               if os.path.splitext(ref[10])[1].lower() in AUDIO_EXTENSIONS:
+                                       self.screenSaverTimer.startLongTimer(time)
+               else:
+                       self.screenSaverTimer.stop()
+
+       def keypressScreenSaver(self, key, flag):
+               if flag:
+                       self.screensaver.hide()
+                       self.show()
+                       self.ScreenSaverTimerStart()
+                       eActionMap.getInstance().unbindAction('', self.keypressScreenSaver)
+
+class MovieSelection(Screen, HelpableScreen, SelectionEventInfo, InfoBarBase, ProtectedScreen, MovieSelectionScreenSaver):
        # SUSPEND_PAUSES actually means "please call my pauseService()"
        ALLOW_SUSPEND = Screen.SUSPEND_PAUSES
 
@@ -511,6 +535,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo, InfoBarBase, Pr
                if not timeshiftEnabled:
                        InfoBarBase.__init__(self) # For ServiceEventTracker
                ProtectedScreen.__init__(self)
+               MovieSelectionScreenSaver.__init__(self)
                self.protectContextMenu = True
 
                self.initUserDefinedActions()
@@ -1085,6 +1110,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo, InfoBarBase, Pr
                else:
                        self.list.playInBackground = current
                        self.session.nav.playService(current)
+                       self.ScreenSaverTimerStart()
 
        def previewCheckTimeshiftCallback(self, answer):
                if answer: