+
+class ServicePositionGauge(PerServiceBase, GUIComponent):
+ def __init__(self, navcore):
+ GUIComponent.__init__(self)
+ PerServiceBase.__init__(self, navcore,
+ {
+ iPlayableService.evStart: self.newService,
+ iPlayableService.evEnd: self.stopEvent,
+ iPlayableService.evCuesheetChanged: self.newCuesheet
+ })
+ self.instance = None
+ self.__seek_position = 0
+
+ def newService(self):
+ if self.get() is None:
+ self.disablePolling()
+ else:
+ self.enablePolling(interval=500)
+ self.newCuesheet()
+
+ def get(self):
+ service = self.navcore.getCurrentService()
+ seek = service and service.seek()
+ if seek is None:
+ return (0, 0)
+
+ len = seek.getLength()
+ pos = seek.getPlayPosition()
+
+ if len[0] or pos[0]:
+ return (0, 0)
+ return (len[1], pos[1])
+
+ def poll(self):
+ data = self.get()
+ if data is None:
+ return
+
+ if self.instance is not None:
+ self.instance.setLength(data[0])
+ self.instance.setPosition(data[1])
+
+ def stopEvent(self):
+ self.disablePolling()
+
+ GUI_WIDGET = ePositionGauge
+
+ def postWidgetCreate(self, instance):
+ self.newService()
+ self.setSeekPosition(self.__seek_position)
+
+ def newCuesheet(self):
+ service = self.navcore.getCurrentService()
+ cue = service and service.cueSheet()
+ cutlist = (cue and cue.getCutList()) or [ ]
+ if self.instance is not None:
+ self.instance.setInOutList(cutlist)
+
+ def getSeekEnable(self):
+ return self.__seek_enable
+
+ def setSeekEnable(self, val):
+ self.__seek_enable = val
+ if self.instance is not None:
+ self.instance.enableSeekPointer(val)
+
+ seek_pointer_enabled = property(getSeekEnable, setSeekEnable)
+
+ def getSeekPosition(self):
+ return self.__seek_position
+
+ def setSeekPosition(self, pos):
+ print "set seek position:", pos
+ self.__seek_position = pos
+ if self.instance is not None:
+ print "set instance."
+ self.instance.setSeekPosition(pos)
+
+ seek_pointer_position = property(getSeekPosition, setSeekPosition)