Skip to content

Commit 40454b0

Browse files
committed
fixup! Don't seek past last 5 seconds.
1 parent 0b9f2f8 commit 40454b0

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/windows/seekdialog.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ def skipByStep(self, direction="positive", without_osd=False):
485485

486486
def skipByOffset(self, offset, without_osd=False):
487487
if offset is not None:
488-
self.seekByOffset(offset, without_osd=without_osd)
488+
if not self.seekByOffset(offset, without_osd=without_osd):
489+
return
489490

490491
if self.useAutoSeek:
491492
self.delayedSeek()
@@ -720,19 +721,19 @@ def seekByOffset(self, offset, auto_seek=False, without_osd=False):
720721
:param without_osd: indicates whether this seek was done with or without OSD
721722
:return:
722723
"""
724+
lastSelectedOffset = self.selectedOffset
725+
# If we are seeking forward and already past 5 seconds from end, don't seek at all
726+
if lastSelectedOffset > self.duration - 5000 and offset > 0:
727+
return False
728+
723729
self._seeking = True
724730
self._seekingWithoutOSD = without_osd
725-
lastSelectedOffset = self.selectedOffset
726731
self.selectedOffset += offset
727732
# Don't skip past 5 seconds from end
728733
if self.selectedOffset > self.duration - 5000:
729-
# If we are seeking forward and already past 5 seconds from end, don't seek at all
730-
if lastSelectedOffset > self.duration - 5000:
731-
self.selectedOffset = lastSelectedOffset
732-
else:
733-
# offset = +100, at = 80000, duration = 80007, realoffset = 2
734-
self._forcedLastSkipAmount = self.duration - 5000 - lastSelectedOffset
735-
self.selectedOffset = self.duration - 5000
734+
# offset = +100, at = 80000, duration = 80007, realoffset = 2
735+
self._forcedLastSkipAmount = self.duration - 5000 - lastSelectedOffset
736+
self.selectedOffset = self.duration - 5000
736737
# Don't skip back past 1 (0 is handled specially so seeking to 0 will not do a seek)
737738
elif self.selectedOffset < 1:
738739
# offset = -100, at = 5, realat = -95, realoffset = 1 - 5 = -4
@@ -744,6 +745,7 @@ def seekByOffset(self, offset, auto_seek=False, without_osd=False):
744745
if auto_seek:
745746
self.resetAutoSeekTimer()
746747
self.bigSeekHideTimer.reset()
748+
return True
747749

748750
def seekMouse(self, action, without_osd=False, preview=False):
749751
x = self.mouseXTrans(action.getAmount1())

0 commit comments

Comments
 (0)