+
+class ServicePositionGauge(PerServiceBase):
+ def __init__(self, navcore):
+ PerServiceBase.__init__(self, navcore,
+ {
+ iPlayableService.evStart: self.newService,
+ iPlayableService.evEnd: self.stopEvent,
+ iPlayableService.evCuesheetChanged: self.newCuesheet
+ })
+ self.instance = None
+
+ 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 None
+
+ 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()
+
+ def GUIcreate(self, parent):
+ self.instance = ePositionGauge(parent)
+ self.newService()
+
+ def GUIdelete(self):
+ self.instance = None
+
+ 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)