Skip to content

Commit 09bce1e

Browse files
committed
fixup! Don't seek past last 5 seconds.
1 parent 7c670d2 commit 09bce1e

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
@@ -492,7 +492,8 @@ def skipByStep(self, direction="positive", without_osd=False):
492492

493493
def skipByOffset(self, offset, without_osd=False):
494494
if offset is not None:
495-
self.seekByOffset(offset, without_osd=without_osd)
495+
if not self.seekByOffset(offset, without_osd=without_osd):
496+
return
496497

497498
if self.useAutoSeek:
498499
self.delayedSeek()
@@ -729,19 +730,19 @@ def seekByOffset(self, offset, auto_seek=False, without_osd=False):
729730
:param without_osd: indicates whether this seek was done with or without OSD
730731
:return:
731732
"""
733+
lastSelectedOffset = self.selectedOffset
734+
# If we are seeking forward and already past 5 seconds from end, don't seek at all
735+
if lastSelectedOffset > self.duration - 5000 and offset > 0:
736+
return False
737+
732738
self._seeking = True
733739
self._seekingWithoutOSD = without_osd
734-
lastSelectedOffset = self.selectedOffset
735740
self.selectedOffset += offset
736741
# Don't skip past 5 seconds from end
737742
if self.selectedOffset > self.duration - 5000:
738-
# If we are seeking forward and already past 5 seconds from end, don't seek at all
739-
if lastSelectedOffset > self.duration - 5000:
740-
self.selectedOffset = lastSelectedOffset
741-
else:
742-
# offset = +100, at = 80000, duration = 80007, realoffset = 2
743-
self._forcedLastSkipAmount = self.duration - 5000 - lastSelectedOffset
744-
self.selectedOffset = self.duration - 5000
743+
# offset = +100, at = 80000, duration = 80007, realoffset = 2
744+
self._forcedLastSkipAmount = self.duration - 5000 - lastSelectedOffset
745+
self.selectedOffset = self.duration - 5000
745746
# Don't skip back past 1 (0 is handled specially so seeking to 0 will not do a seek)
746747
elif self.selectedOffset < 1:
747748
# offset = -100, at = 5, realat = -95, realoffset = 1 - 5 = -4
@@ -753,6 +754,7 @@ def seekByOffset(self, offset, auto_seek=False, without_osd=False):
753754
if auto_seek:
754755
self.resetAutoSeekTimer()
755756
self.bigSeekHideTimer.reset()
757+
return True
756758

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

0 commit comments

Comments
 (0)