def __serviceStarted(self): logger.info("self.is_closing: %s", self.is_closing) if not self.service_started and not self.is_closing: self.service_started = True self.setAudioTrack() self.setSubtitleState(True) self.downloadCuesheet() if self.config_plugins_plugin.movie_ignore_first_marks.value: self.cut_list = removeFirstMarks(self.cut_list) if self.config_plugins_plugin.movie_resume_at_last_pos.value: self.resume_point = getCutListLast(self.cut_list) if self.resume_point > 0: seconds = ptsToSeconds(self.resume_point) logger.debug("resume_point: %s", seconds) Notifications.AddNotificationWithCallback( self.__serviceStartedCallback, MessageBox, _("Do you want to resume playback at position: %d:%02d:%02d?" ) % (seconds / 3600, seconds % 3600 / 60, seconds % 60), timeout=10, type=MessageBox.TYPE_YESNO, default=False, ) else: self.__serviceStartedCallback(False) else: self.__serviceStartedCallback(False)
def getPosition(self): position = 0 seek = self.getSeek() if seek and self.service_started: pos = seek.getPlayPosition() if not pos[0] and pos[1] > 0: position = pos[1] logger.info("position: %ss (%s)", ptsToSeconds(position), position) return position
def setSkipDistance(self): if self.skip_first and self.config_event_start: logger.debug("position: %s, event_start: %s", ptsToSeconds(self.getPosition()), self.event_start) if abs(self.getPosition() - self.event_start) <= secondsToPts(60): self.skip_distance = self.skip_distance_short else: self.skip_distance = self.skip_distance_long logger.debug("skip_distance: %s", self.skip_distance)
def getSeekLength(self): length = 0 seek = self.getSeek() if seek is not None: seek_len = seek.getLength() logger.debug("seek.getLength(): %s", seek_len) if not seek_len[0]: length = seek_len[1] logger.info("length: %ss (%s)", ptsToSeconds(length), length) return length
def getLength(self): length = 0 if self.service.type == SID_DVB: length = self.__length if self.recording_start_time and self.event_start_time > self.recording_start_time: length += self.event_start_time - self.recording_start_time length = secondsToPts(length) else: length = self.getSeekLength() logger.info("length: %ss (%s)", ptsToSeconds(length), length) return length
def skipBackward(self): logger.info("...") self.reset_skip_timer.start(SKIP_TIMEOUT, True) self.setSkipDistance() if not self.skip_first and self.skip_forward: self.skip_index = len( self.skip_distance) - 1 if self.skip_index >= len( self.skip_distance) - 1 else self.skip_index + 1 self.skip_forward = False self.skip_first = False distance = secondsToPts(self.skip_distance[self.skip_index]) position = self.getPosition() length = self.getSeekLength() if position - distance < 0: distance = position logger.debug("distance: %s, position: %s, length: %s", ptsToSeconds(distance), ptsToSeconds(position), ptsToSeconds(length)) if not self.block_skip_timer.isActive(): self.doSeekRelative(-distance) self.block_skip_timer.start(BLOCK_TIMEOUT, True)
def skipForward(self): logger.info("...") self.reset_skip_timer.start(SKIP_TIMEOUT, True) self.setSkipDistance() if not self.skip_first and ( not self.skip_forward or (self.config_skip_first_long and self.skip_distance == self.skip_distance_long and self.skip_index == 0)): self.skip_index = len( self.skip_distance) - 1 if self.skip_index >= len( self.skip_distance) - 1 else self.skip_index + 1 self.skip_forward = True self.skip_first = False distance = secondsToPts(self.skip_distance[self.skip_index]) position = self.getPosition() length = self.getSeekLength() - secondsToPts(1) if position + distance > length: distance = max(0, length - position) logger.debug("distance: %s, position: %s, length: %s", ptsToSeconds(distance), ptsToSeconds(position), ptsToSeconds(length)) if distance > 0 and not self.block_skip_timer.isActive(): self.doSeekRelative(distance) self.block_skip_timer.start(BLOCK_TIMEOUT, True)
def __init__(self, path): self.path = path self.meta_path = path + ".meta" self.xmeta_path = path + ".xmeta" self.meta_list = self.readMeta(self.meta_path) self.meta = self.list2dict(self.meta_list, self.meta_keys) if self.meta: self.meta["length"] = ptsToSeconds(self.meta["length"]) self.xmeta_list = self.readMeta(self.xmeta_path) self.xmeta = self.list2dict(self.xmeta_list, self.xmeta_keys) if self.meta and not self.xmeta: self.xmeta["recording_start_time"] = self.meta["rec_time"] self.xmeta["recording_stop_time"] = 0 self.xmeta["recording_margin_before"] = config.recording.margin_before.value * 60 self.xmeta["recording_margin_after"] = config.recording.margin_after.value * 60
def getProgress(recording, path, event_start_time, length, cuts): logger.debug("path: %s", path) if recording: last = time() - event_start_time else: # get last position from cut file cut_list = unpackCutList(cuts) logger.debug("cut_list: %s", cut_list) last = ptsToSeconds(getCutListLast(cut_list)) logger.debug("last: %s", last) progress = 0 if length > 0 and last > 0: last = min(last, length) progress = int(round(float(last) / float(length), 2) * 100) logger.debug("progress: %s, path: %s, length: %s, recording: %s", progress, path, length, recording) return progress
def __serviceStarted(self): if not self.is_closing: print( "MVC: InfoBarSupport: __serviceStarted: new service started, trying to download cuts" ) self.downloadCuesheet() if config.usage.on_movie_start.value == "beginning" and config.MVC.movie_jump_first_mark.value: self.jumpToFirstMark() else: if self.ENABLE_RESUME_SUPPORT: last = getCutListLast(verifyCutList(self.cut_list)) if last > 0: self.resume_point = last l = ptsToSeconds(last) val = config.usage.on_movie_start.value if val == "ask" or val == "ask yes" or val == "ask no": Notifications.AddNotificationWithCallback( self.playLastCallback, MessageBox, _("Do you want to resume this playback?") + "\n" + (_("Resume position at %s") % ("%d:%02d:%02d" % (l / 3600, l % 3600 / 60, l % 60))), timeout=10, default=not (val == "ask no")) elif val == "resume": Notifications.AddNotificationWithCallback( self.playLastCallback, MessageBox, _("Resuming playback"), timeout=2, type=MessageBox.TYPE_INFO) elif config.MVC.movie_jump_first_mark.value: self.jumpToFirstMark() elif config.MVC.movie_jump_first_mark.value: self.jumpToFirstMark()
def getCutListLengthInSeconds(cut_list): return ptsToSeconds(getCutListLength(cut_list))
def getCutListLastInSeconds(cut_list): return ptsToSeconds(getCutListLast(cut_list))