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