aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Converter/ServicePosition.py
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-07-10 16:20:36 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-07-10 16:20:36 +0000
commit2cc6286f24b7cde25c468b2b4a817e5fa7a9cceb (patch)
tree106d69466c4c861d1f286b651968322da7c5ea5c /lib/python/Components/Converter/ServicePosition.py
parenta3d7b6118dfb093fd4b19f819a9c8a679287b8e8 (diff)
downloadenigma2-2cc6286f24b7cde25c468b2b4a817e5fa7a9cceb.tar.gz
enigma2-2cc6286f24b7cde25c468b2b4a817e5fa7a9cceb.zip
add service position converter
Diffstat (limited to 'lib/python/Components/Converter/ServicePosition.py')
-rw-r--r--lib/python/Components/Converter/ServicePosition.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py
new file mode 100644
index 00000000..92c7b59b
--- /dev/null
+++ b/lib/python/Components/Converter/ServicePosition.py
@@ -0,0 +1,80 @@
+from Converter import Converter
+from Poll import Poll
+from enigma import iPlayableService
+
+class ServicePosition(Converter, Poll, object):
+ TYPE_LENGTH = 0,
+ TYPE_POSITION = 1,
+ TYPE_REMAINING = 2,
+ TYPE_GAUGE = 3
+
+ def __init__(self, type, *args, **kwargs):
+ Poll.__init__(self)
+ Converter.__init__(self)
+ if type == "Length":
+ self.type = self.TYPE_LENGTH
+ elif type == "Position":
+ self.type = self.TYPE_POSITION
+ elif type == "Remaining":
+ self.type = self.TYPE_REMAINING
+ elif type == "Gauge":
+ self.type = self.TYPE_GAUGE
+
+ self.poll_interval = 500
+ self.poll_enabled = self.type != self.TYPE_LENGTH
+
+ def getSeek(self):
+ s = self.source.service
+ return s and s.seek()
+
+ def getPosition(self):
+ seek = self.getSeek()
+ if seek is None:
+ return None
+ pos = seek.getPlayPosition()
+ if pos[0]:
+ return 0
+ return pos[1] / 90000
+
+ def getLength(self):
+ seek = self.getSeek()
+ if seek is None:
+ return None
+ length = seek.getLength()
+ if length[0]:
+ return 0
+ return length[1] / 90000
+
+ def getCutlist(self):
+ service = self.source.service
+ cue = service and service.cueSheet()
+ return cue and cue.getCutList()
+
+ def getText(self):
+ seek = self.getSeek()
+ if seek is None:
+ return ""
+ else:
+ if self.type == self.TYPE_LENGTH:
+ l = self.length
+ elif self.type == self.TYPE_POSITION:
+ l = self.position
+ elif self.type == self.TYPE_REMAINING:
+ l = self.length - self.position
+ return "%d:%02d" % (l/60, l%60)
+
+ position = property(getPosition)
+ length = property(getLength)
+ cutlist = property(getCutlist)
+ text = property(getText)
+
+ def changed(self, *args):
+ cutlist_refresh = len(args) and args[0] in [iPlayableService.evCuesheetChanged, iPlayableService.evStart, iPlayableService.evEnd]
+ time_refresh = not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd]
+
+ if cutlist_refresh:
+ if self.type == self.TYPE_GAUGE:
+ self.downstream_elements.cutlist_changed()
+
+ if time_refresh:
+ self.downstream_elements.changed()