enigma2: switch back to previous service when mediacenter audio player is closed...
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / enigma2-4.2.3r4-dm7080 / 0001-split-previous-service-handling-to-own-class-and-use.patch
1 From caab0054166f5dc9a8d514d2a5fa76733a23453a Mon Sep 17 00:00:00 2001
2 From: ghost <andreas.monzner@dream-property.net>
3 Date: Tue, 1 Sep 2015 23:34:51 +0200
4 Subject: [PATCH] split previous service handling to own class and use it in
5  MediaCenter PlaylistPlayer when audio content is played...
6
7 ---
8  usr/lib/enigma2/python/Plugins/Extensions/MediaCenter/PlaylistPlayer.py       |  9 +++++-
9  usr/lib/enigma2/python/Screens/InfoBarGenerics.py              | 34 +++++++++++++---------
10  2 files changed, 28 insertions(+), 15 deletions(-)
11
12 diff --git a/usr/lib/enigma2/python/Plugins/Extensions/MediaCenter/PlaylistPlayer.py b/usr/lib/enigma2/python/Plugins/Extensions/MediaCenter/PlaylistPlayer.py
13 index 315eb13..38a02bc 100644
14 --- a/usr/lib/enigma2/python/Plugins/Extensions/MediaCenter/PlaylistPlayer.py
15 +++ b/usr/lib/enigma2/python/Plugins/Extensions/MediaCenter/PlaylistPlayer.py
16 @@ -4,6 +4,7 @@ from Screens.ChoiceBox import ChoiceBox
17  from Screens.HelpMenu import HelpableScreen
18  from Screens.MessageBox import MessageBox
19  from Screens.Screen import Screen
20 +from Screens.InfoBarGenerics import PlayerBase
21  from ServiceReference import ServiceReference
22  from Tools.Directories import resolveFilename, SCOPE_CONFIG
23  #plugin imports
24 @@ -11,7 +12,10 @@ from Tools.Log import Log
25  from MediaCore import MediaCore, mediaCore
26  from DatabasePlaylist import DatabasePlaylist
27  
28 -class PlaylistPlayer(Screen, HelpableScreen):
29 +# when playing audio content no dedicated player class is used
30 +# so here we must inherit from PlayerBase to not break the 
31 +# previous service handling
32 +class PlaylistPlayer(Screen, HelpableScreen, PlayerBase):
33         def __init__(self, session, playlist_string, type):
34                 Screen.__init__(self, session)
35                 HelpableScreen.__init__(self)
36 @@ -24,6 +28,9 @@ class PlaylistPlayer(Screen, HelpableScreen):
37  
38                 self.onClose.append(self.__onClose)
39  
40 +               if type == MediaCore.TYPE_AUDIO:
41 +                       PlayerBase.__init__(self)
42 +
43         def _initPlaylist(self, playlist_id):
44                 if playlist_id > 0:
45                         self._playlist = DatabasePlaylist.get(id=playlist_id)
46 diff --git a/usr/lib/enigma2/python/Screens/InfoBarGenerics.py b/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
47 index 22c8ad8..5c68236 100644
48 --- a/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
49 +++ b/usr/lib/enigma2/python/Screens/InfoBarGenerics.py
50 @@ -869,7 +869,25 @@ class InfoBarRdsDecoder:
51                         self.RassSlidePicChanged()
52                 self.rds_display.show()
53  
54 -class InfoBarSeek:
55 +class PlayerBase:
56 +       def __init__(self):
57 +               self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
58 +
59 +               if not isinstance(self, InfoBarChannelSelection):
60 +                       self.onFirstExecBegin.append(self.__registerPlayer)
61 +
62 +       def __registerPlayer(self):
63 +               self.prev_player = self.session.current_player
64 +               self.session.current_player = self
65 +               self.onClose.append(self.__unRegisterPlayer)
66 +
67 +       def __unRegisterPlayer(self):
68 +               self.session.current_player = self.prev_player
69 +               self.session.nav.playService(self.lastservice)
70 +
71 +# Since we dont want to change any existing player class, here we assume that each player inherits from InfoBarSeek.
72 +# If this is not the case the player explicitely have to inherit from PlayerBase and must call the init function!
73 +class InfoBarSeek(PlayerBase):
74         """handles actions like seeking, pause"""
75  
76         SEEK_STATE_PLAY = (0, 0, 0, ">")
77 @@ -933,19 +951,7 @@ class InfoBarSeek:
78  
79                 self.__seekableStatusChanged()
80  
81 -               self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
82 -
83 -               if not isinstance(self, InfoBarChannelSelection):
84 -                       self.onFirstExecBegin.append(self.__registerPlayer)
85 -
86 -       def __registerPlayer(self):
87 -               self.prev_player = self.session.current_player
88 -               self.session.current_player = self
89 -               self.onClose.append(self.__unRegisterPlayer)
90 -
91 -       def __unRegisterPlayer(self):
92 -               self.session.current_player = self.prev_player
93 -               self.session.nav.playService(self.lastservice)
94 +               PlayerBase.__init__(self)
95  
96         def makeStateForward(self, n):
97                 return (0, n, 0, ">> %dx" % n)
98 -- 
99 1.9.1
100