add CMoviePlayer
[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 enigma import *
16
17 import time
18
19 class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
20         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
21         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection):
22
23         def __init__(self, session):
24                 Screen.__init__(self, session)
25
26                 self["actions"] = ActionMap( [ "InfobarActions" ],
27                         {
28                                 "showMovies": self.showMovies,
29                         })
30                 
31                 for x in InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
32                         InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
33                         InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
34                         x.__init__(self)
35
36                 self["CurrentTime"] = Clock()
37
38         def showMovies(self):
39                 self.session.openWithCallback(self.movieSelected, MovieSelection)
40         
41         def movieSelected(self, service):
42                 if service is not None:
43                         self.session.open(MoviePlayer, service)
44
45 class MoviePlayer(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
46                 InfoBarMenu, \
47                 InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection):
48                 
49         def __init__(self, session, service):
50                 Screen.__init__(self, session)
51                 
52                 self["actions"] = ActionMap( [ "MoviePlayerActions" ],
53                         {
54                                 "leavePlayer": self.leavePlayer
55                         })
56                 
57                 for x in InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection:
58                         x.__init__(self)
59
60                 self["CurrentTime"] = Clock()
61                 # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
62                 
63                 self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
64                 self.session.nav.playService(service)
65
66         def leavePlayer(self):
67                 self.session.openWithCallback(self.leavePlayerConfirmed, MessageBox, "Stop playing this movie?")
68         
69         def leavePlayerConfirmed(self, answer):
70                 if answer == True:
71                         self.session.nav.playService(self.lastservice)
72                         self.close()