def __run(self): """ Do the work """ log.debug('Show sync info thread started') # cache local variables because it's faster total = self.total dialog = DialogProgressBG('dialoglogProgressBG') thread_stopped = self.thread_stopped dialog.create("%s %s: %s %s" % (lang(39714), self.item_type, str(total), lang(39715))) player = Player() total = 2 * total totalProgress = 0 while thread_stopped() is False and not player.isPlaying(): with LOCK: get_progress = GET_METADATA_COUNT process_progress = PROCESS_METADATA_COUNT viewName = PROCESSING_VIEW_NAME totalProgress = get_progress + process_progress try: percentage = int(float(totalProgress) / float(total) * 100.0) except ZeroDivisionError: percentage = 0 dialog.update(percentage, message="%s %s. %s %s: %s" % (get_progress, lang(39712), process_progress, lang(39713), viewName)) # Sleep for x milliseconds sleep(200) dialog.close() log.debug('Show sync info thread terminated')
def threaded_playback(kodi_playlist, startpos, offset): """ Seek immediately after kicking off playback is not reliable. """ player = Player() player.play(kodi_playlist, None, False, startpos) if offset and offset != '0': i = 0 while not player.isPlaying(): sleep(100) i += 1 if i > 100: LOG.error('Could not seek to %s', offset) return js.seek_to(int(offset))