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