Merge pull request #1047 from croneter/fix-resume

Fix Kodi playback jumping to the beginning of a video that just started
This commit is contained in:
croneter 2019-11-07 07:06:11 +01:00 committed by GitHub
commit 4947b561ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,7 @@ LOG = getLogger('PLEX.playback')
# Do we need to return ultimately with a setResolvedUrl? # Do we need to return ultimately with a setResolvedUrl?
RESOLVE = True RESOLVE = True
TRY_TO_SEEK_FOR = 300 # =30 seconds TRY_TO_SEEK_FOR = 300 # =30 seconds
IGNORE_SECONDS_AT_START = 15
############################################################################### ###############################################################################
@ -590,6 +591,13 @@ def threaded_playback(kodi_playlist, startpos, offset):
if i > TRY_TO_SEEK_FOR: if i > TRY_TO_SEEK_FOR:
LOG.error('Could not seek to %s', offset) LOG.error('Could not seek to %s', offset)
return return
try:
if offset == 0 and app.APP.player.getTime() < IGNORE_SECONDS_AT_START:
LOG.debug('Avoiding small jump to the very start of the video')
return
except RuntimeError:
# RuntimeError: XBMC is not playing any media file
pass
i = 0 i = 0
answ = js.seek_to(offset * 1000) answ = js.seek_to(offset * 1000)
while 'error' in answ: while 'error' in answ: