add audio track selection
[enigma2.git] / Navigation.py
1 from enigma import *
2 import RecordTimer
3
4 import NavigationInstance
5 import ServiceReference
6
7 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
8 class Navigation:
9         def __init__(self):
10                 if NavigationInstance.instance is not None:
11                         raise NavigationInstance.instance
12                 
13                 NavigationInstance.instance = self
14                 self.ServiceHandler = eServiceCenter.getInstance()
15
16                 import Navigation as Nav
17                 Nav.navcore = self
18                 
19                 self.pnav = pNavigation()
20                 self.pnav.m_event.get().append(self.callEvent)
21                 self.event = [ ]
22                 self.currentlyPlayingService = None
23                 
24                 self.RecordTimer = RecordTimer.RecordTimer()
25
26         def callEvent(self, i):
27                 for x in self.event:
28                         x(i)
29         
30         def playService(self, ref):
31                 self.currentlyPlayingServiceReference = None
32                 if not self.pnav.playService(ref):
33                         self.currentlyPlayingServiceReference = ref
34                         return 0
35                 return 1
36         
37         def getCurrentlyPlayingServiceReference(self):
38                 return self.currentlyPlayingServiceReference
39         
40         def recordService(self, ref):
41                 print "recording service: %s" % (str(ref))
42                 if isinstance(ref, ServiceReference.ServiceReference):
43                         ref = ref.ref
44                 service = self.pnav.recordService(ref)
45                 
46                 if service is None:
47                         print "record returned non-zero"
48                         return None
49                 else:
50                         return service
51         
52         def enqueueService(self, ref):
53                 return self.pnav.enqueueService(ref)
54         
55         def getCurrentService(self):
56                 service = self.pnav.getCurrentService()
57                 
58                 if service is None:
59                         return None
60                 
61                 return service
62         
63         def stopService(self):
64                 self.pnav.stopService()
65         
66         def getPlaylist(self):
67                 playlist = ePlaylistPtr()
68                 if self.pnav.getPlaylist(playlist):
69                         return None
70                 return playlist
71         
72         def pause(self, p):
73                 return self.pnav.pause(p)
74         
75         def recordWithTimer(self, begin, end, ref, epg, description):
76                 if isinstance(ref, eServiceReference):
77                         ref = ServiceReference.ServiceReference(ref)
78                 entry = RecordTimer.RecordTimerEntry(begin, end, ref, epg, description)
79                 self.RecordTimer.record(entry)
80                 return entry
81         
82         def shutdown(self):
83                 self.RecordTimer.shutdown()