add possibility to select between different list styles via context menu
[enigma2.git] / lib / python / Components / Converter / ServicePosition.py
index 94d712223210c60e5d62e057032a3dd05d0de77f..089ca6c12d5b47f3c611c0bb789c5972a18a0fae 100644 (file)
@@ -4,30 +4,36 @@ from enigma import iPlayableService
 from Components.Element import cached
 
 class ServicePosition(Converter, Poll, object):
 from Components.Element import cached
 
 class ServicePosition(Converter, Poll, object):
-       TYPE_LENGTH = 0,
-       TYPE_POSITION = 1,
-       TYPE_REMAINING = 2,
+       TYPE_LENGTH = 0
+       TYPE_POSITION = 1
+       TYPE_REMAINING = 2
        TYPE_GAUGE = 3
        TYPE_GAUGE = 3
-       
+       TYPE_POSITION_DETAILED = 4
+
        def __init__(self, type):
                Poll.__init__(self)
                Converter.__init__(self, type)
        def __init__(self, type):
                Poll.__init__(self)
                Converter.__init__(self, type)
+
+               self.poll_interval = 500
+
                if type == "Length":
                        self.type = self.TYPE_LENGTH
                elif type == "Position":
                        self.type = self.TYPE_POSITION
                if type == "Length":
                        self.type = self.TYPE_LENGTH
                elif type == "Position":
                        self.type = self.TYPE_POSITION
+               elif type == "PositionDetailed":
+                       self.type = self.TYPE_POSITION_DETAILED
+                       self.poll_interval = 100
                elif type == "Remaining":
                        self.type = self.TYPE_REMAINING
                elif type == "Gauge":
                        self.type = self.TYPE_GAUGE
 
                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
                self.poll_enabled = self.type != self.TYPE_LENGTH
-       
+
        def getSeek(self):
                s = self.source.service
                return s and s.seek()
        def getSeek(self):
                s = self.source.service
                return s and s.seek()
-       
+
        @cached
        def getPosition(self):
                seek = self.getSeek()
        @cached
        def getPosition(self):
                seek = self.getSeek()
@@ -37,7 +43,7 @@ class ServicePosition(Converter, Poll, object):
                if pos[0]:
                        return 0
                return pos[1]
                if pos[0]:
                        return 0
                return pos[1]
-       
+
        @cached
        def getLength(self):
                seek = self.getSeek()
        @cached
        def getLength(self):
                seek = self.getSeek()
@@ -47,13 +53,13 @@ class ServicePosition(Converter, Poll, object):
                if length[0]:
                        return 0
                return length[1]
                if length[0]:
                        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 getCutlist(self):
                service = self.source.service
                cue = service and service.cueSheet()
                return cue and cue.getCutList()
-       
+
        @cached
        def getText(self):
                seek = self.getSeek()
        @cached
        def getText(self):
                seek = self.getSeek()
@@ -62,30 +68,34 @@ class ServicePosition(Converter, Poll, object):
                else:
                        if self.type == self.TYPE_LENGTH:
                                l = self.length
                else:
                        if self.type == self.TYPE_LENGTH:
                                l = self.length
-                       elif self.type == self.TYPE_POSITION:
+                       elif self.type in [self.TYPE_POSITION, self.TYPE_POSITION_DETAILED]:
                                l = self.position
                        elif self.type == self.TYPE_REMAINING:
                                l = self.length - self.position
                                l = self.position
                        elif self.type == self.TYPE_REMAINING:
                                l = self.length - self.position
-                       
-                       l /= 90000
-                       
+
+                       if self.type != self.TYPE_POSITION_DETAILED:
+                               l /= 90000
+
                        if l > 0:
                                sign = ""
                        else:
                                l = -l
                                sign = "-"
                        if l > 0:
                                sign = ""
                        else:
                                l = -l
                                sign = "-"
-                       
-                       return sign + "%d:%02d" % (l/60, l%60)
+
+                       if self.type != self.TYPE_POSITION_DETAILED:
+                               return sign + "%d:%02d" % (l/60, l%60)
+                       else:
+                               return sign + "%d:%02d:%03d" % ((l/60/90000), (l/90000)%60, (l%90000)/90)
 
        position = property(getPosition)
        length = property(getLength)
        cutlist = property(getCutlist)
        text = property(getText)
 
        position = property(getPosition)
        length = property(getLength)
        cutlist = property(getCutlist)
        text = property(getText)
-       
+
        def changed(self, what):
                cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged]
                time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged]
        def changed(self, what):
                cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged]
                time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged]
-               
+
                if cutlist_refresh:
                        if self.type == self.TYPE_GAUGE:
                                self.downstream_elements.cutlist_changed()
                if cutlist_refresh:
                        if self.type == self.TYPE_GAUGE:
                                self.downstream_elements.cutlist_changed()