favs only (as default)
[enigma2.git] / lib / python / Screens / InfoBar.py
1 from Screen import Screen
2
3 from Screens.MovieSelection import MovieSelection
4 from Screens.MessageBox import MessageBox
5
6 from Components.Clock import Clock
7 from Components.ActionMap import ActionMap
8 from Components.ServicePosition import ServicePosition
9
10 from Screens.InfoBarGenerics import InfoBarVolumeControl, InfoBarShowHide, \
11         InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
12         InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarPVR, InfoBarInstantRecord, \
13         InfoBarAudioSelection
14
15 from Screens.HelpMenu import HelpableScreen, HelpMenu
16
17 from enigma import *
18
19 import time
20
21 class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
22         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
23         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection,
24         HelpableScreen):
25
26         def __init__(self, session):
27                 Screen.__init__(self, session)
28
29                 self["actions"] = ActionMap( [ "InfobarActions" ],
30                         {
31                                 "showMovies": self.showMovies,
32                         })
33                 
34                 for x in HelpableScreen, \
35                                 InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
36                                 InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
37                                 InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
38                         x.__init__(self)
39
40                 self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
41
42                 self["CurrentTime"] = Clock()
43
44         def showMovies(self):
45                 self.session.openWithCallback(self.movieSelected, MovieSelection)
46
47         def movieSelected(self, service):
48                 if service is not None:
49                         self.session.open(MoviePlayer, service)
50
51 class MoviePlayer(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
52                 InfoBarMenu, \
53                 InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection):
54                 
55         def __init__(self, session, service):
56                 Screen.__init__(self, session)
57                 
58                 self["actions"] = ActionMap( [ "MoviePlayerActions" ],
59                         {
60                                 "leavePlayer": self.leavePlayer
61                         })
62                 
63                 for x in InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection:
64                         x.__init__(self)
65
66                 self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
67                 
68                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
69                 self.session.nav.playService(service)
70
71         def leavePlayer(self):
72                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, _("Stop playing this movie?"))
73         
74         def leavePlayerConfirmed(self, answer):
75                 if answer == True:
76                         self.session.nav.playService(self.lastservice)
77                         self.close()