properly handle negative time values
[enigma2.git] / lib / python / Components / Converter / ServicePosition.py
index dfb792addd185543164c1c43207265e293bc8b88..94d712223210c60e5d62e057032a3dd05d0de77f 100644 (file)
@@ -1,6 +1,7 @@
 from Converter import Converter
 from Poll import Poll
 from enigma import iPlayableService
+from Components.Element import cached
 
 class ServicePosition(Converter, Poll, object):
        TYPE_LENGTH = 0,
@@ -27,6 +28,7 @@ class ServicePosition(Converter, Poll, object):
                s = self.source.service
                return s and s.seek()
        
+       @cached
        def getPosition(self):
                seek = self.getSeek()
                if seek is None:
@@ -36,6 +38,7 @@ class ServicePosition(Converter, Poll, object):
                        return 0
                return pos[1]
        
+       @cached
        def getLength(self):
                seek = self.getSeek()
                if seek is None:
@@ -45,11 +48,13 @@ class ServicePosition(Converter, Poll, object):
                        return 0
                return length[1]
        
+       @cached
        def getCutlist(self):
                service = self.source.service
                cue = service and service.cueSheet()
                return cue and cue.getCutList()
        
+       @cached
        def getText(self):
                seek = self.getSeek()
                if seek is None:
@@ -63,7 +68,14 @@ class ServicePosition(Converter, Poll, object):
                                l = self.length - self.position
                        
                        l /= 90000
-                       return "%d:%02d" % (l/60, l%60)
+                       
+                       if l > 0:
+                               sign = ""
+                       else:
+                               l = -l
+                               sign = "-"
+                       
+                       return sign + "%d:%02d" % (l/60, l%60)
 
        position = property(getPosition)
        length = property(getLength)