class OpenView(QtCore.QObject):
nextSignal = QtCore.pyqtSignal([int, str])
def __init__(self, vis):
super(OpenView, self).__init__()
self.nextSignal.connect(self.update_next)
threading.Thread(target=self._on_update_thread).start()
def _on_update_thread(self):
while not self.is_done:
# Get the next frame, for instance, reading a frame from the file.
if not self.is_ready or not self.is_playing:
time.sleep(0.2)
else: # ready and playing
self.nextSignal.emit(0, 'ignored')
time.sleep(0.05)
def update_next(self, ignored_int, ignored_str):
print('播放中...')
pass
实际运行
[2022-05-07 17:38:52.961103 MainThread]-播放中... 用时 24 ms