show radio (rds) text when available... feel free to make it nicer
[enigma2.git] / lib / python / Components / Sources / RadioText.py
1 from Components.PerServiceDisplay import PerServiceBase
2 from Components.Element import cached
3 from enigma import iPlayableService
4 from Source import Source
5
6 class RadioText(PerServiceBase, Source, object):
7         def __init__(self, navcore):
8                 Source.__init__(self)
9                 PerServiceBase.__init__(self, navcore,
10                         {
11                                 iPlayableService.evStart: self.gotEvent,
12                                 iPlayableService.evUpdatedRadioText: self.gotEvent,
13                                 iPlayableService.evEnd: self.gotEvent
14                         }, with_event=True)
15
16         @cached
17         def getText(self):
18                 service = self.navcore.getCurrentService()
19                 info = service and service.radioText()
20                 return info and info.getRadioText()
21
22         radiotext = property(getText)
23
24         def gotEvent(self, what):
25                 if what in [iPlayableService.evStart, iPlayableService.evEnd]:
26                         self.changed((self.CHANGED_CLEAR,))
27                 else:
28                         self.changed((self.CHANGED_ALL,))