CI mmi is now working every time (for support alphacrypt parental control or other...
[vuplus_dvbapp] / lib / python / Screens / InfoBar.py
1 from Screen import Screen
2
3 from Screens.MovieSelection import MovieSelection
4 from Screens.ChannelSelection import ChannelSelectionRadio
5 from Screens.MessageBox import MessageBox
6 from Screens.Ci import CiHandler
7 from ServiceReference import ServiceReference
8
9 from Components.Clock import Clock
10 from Components.ActionMap import ActionMap, HelpableActionMap
11 from Components.ServicePosition import ServicePosition, ServicePositionGauge
12
13 from Tools.Notifications import AddNotificationWithCallback
14
15 from Screens.InfoBarGenerics import InfoBarShowHide, \
16         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
17         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarSeek, InfoBarInstantRecord, \
18         InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, \
19         InfoBarSubserviceSelection, InfoBarTuner, InfoBarShowMovies, InfoBarTimeshift,  \
20         InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView, \
21         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions
22
23 from Screens.HelpMenu import HelpableScreen, HelpMenu
24
25 from enigma import *
26
27 import time
28
29 class InfoBar(InfoBarShowHide,
30         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
31         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
32         HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish,
33         InfoBarSubserviceSelection, InfoBarTuner, InfoBarTimeshift, InfoBarSeek,
34         InfoBarSummarySupport, InfoBarTimeshiftState, InfoBarTeletextPlugin, InfoBarExtensions, Screen):
35
36         def __init__(self, session):
37                 Screen.__init__(self, session)
38
39                 CiHandler.setSession(session)
40
41                 self["actions"] = HelpableActionMap(self, "InfobarActions",
42                         {
43                                 "showMovies": (self.showMovies, _("Play recorded movies...")),
44                                 "showRadio": (self.showRadio, _("Show the radio player..."))
45                         })
46                 
47                 for x in HelpableScreen, \
48                                 InfoBarShowHide, \
49                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
50                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
51                                 InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
52                                 InfoBarTuner, InfoBarTimeshift, InfoBarSeek, InfoBarSummarySupport, InfoBarTimeshiftState, \
53                                 InfoBarTeletextPlugin, InfoBarExtensions:
54                         x.__init__(self)
55
56                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
57                 self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
58
59                 self["CurrentTime"] = Clock()
60                 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
61
62         def showRadio(self):
63                 self.session.open(ChannelSelectionRadio)
64
65         def showMovies(self):
66                 self.session.openWithCallback(self.movieSelected, MovieSelection)
67
68         def movieSelected(self, service):
69                 if service is not None:
70                         self.session.open(MoviePlayer, service)
71
72 class MoviePlayer(InfoBarShowHide, \
73                 InfoBarMenu, \
74                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications,
75                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarSimpleEventView,
76                 InfoBarSummarySupport, InfoBarTeletextPlugin, Screen):
77                 
78         def __init__(self, session, service):
79                 Screen.__init__(self, session)
80                 
81                 self["actions"] = HelpableActionMap(self, "MoviePlayerActions",
82                         {
83                                 "leavePlayer": (self.leavePlayer, _("leave movie player..."))
84                         })
85                 
86                 for x in HelpableScreen, InfoBarShowHide, InfoBarMenu, \
87                                 InfoBarServiceName, InfoBarSeek, InfoBarShowMovies, \
88                                 InfoBarAudioSelection, InfoBarNotifications, InfoBarSimpleEventView, \
89                                 InfoBarServiceNotifications, InfoBarPVRState, InfoBarCueSheetSupport, \
90                                 InfoBarSummarySupport, InfoBarTeletextPlugin:
91                         x.__init__(self)
92
93                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
94                 self["ElapsedTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_POSITION)
95                 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
96                 
97                 # TYPE_LENGTH?
98                 
99                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
100                 self.session.nav.playService(service)
101
102         def leavePlayer(self):
103                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
104         
105         def leavePlayerConfirmed(self, answer):
106                 if answer == True:
107                         self.session.nav.playService(self.lastservice)
108                         self.close()
109                         
110         def showMovies(self):
111                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
112                 self.session.openWithCallback(self.movieSelected, MovieSelection, ref)
113
114         def movieSelected(self, service):
115                 if service is not None:
116                         self.session.nav.playService(service)