servicemp3.cpp: more simple/flexible streaming detection
[enigma2.git] / lib / python / Components / Sources / RecordState.py
1 from Source import Source
2 from Components.Element import cached
3 from enigma import iRecordableService
4
5 class RecordState(Source):
6         def __init__(self, session):
7                 Source.__init__(self)
8                 self.records_running = 0
9                 self.session = session
10                 session.nav.record_event.append(self.gotRecordEvent)
11                 self.gotRecordEvent(None, None) # get initial state
12
13         def gotRecordEvent(self, service, event):
14                 prev_records = self.records_running
15                 if event in (iRecordableService.evEnd, iRecordableService.evStart, None):
16                         recs = self.session.nav.getRecordings()
17                         self.records_running = len(recs)
18                         if self.records_running != prev_records:
19                                 self.changed((self.CHANGED_ALL,))
20
21         def destroy(self):
22                 session.nav.record_event.remove(self.gotRecordEvent)
23                 Source.destroy(self)
24
25         @cached
26         def getBoolean(self):
27                 return self.records_running and True or False
28         boolean = property(getBoolean)
29
30         @cached
31         def getValue(self):
32                 return self.records_running
33         value = property(getValue)