Merge pull request #1041 from croneter/fix-resume

Fix resume for Kodi on low powered devices, e.g. Raspberry Pi
This commit is contained in:
croneter 2019-11-03 14:34:11 +01:00 committed by GitHub
commit cca78faa42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@ from . import app
LOG = getLogger('PLEX.playback') 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
############################################################################### ###############################################################################
@ -586,7 +587,7 @@ def threaded_playback(kodi_playlist, startpos, offset):
# PKC needs to quit # PKC needs to quit
return return
i += 1 i += 1
if i > 200: if i > TRY_TO_SEEK_FOR:
LOG.error('Could not seek to %s', offset) LOG.error('Could not seek to %s', offset)
return return
i = 0 i = 0
@ -594,10 +595,12 @@ def threaded_playback(kodi_playlist, startpos, offset):
while 'error' in answ: while 'error' in answ:
# Kodi sometimes returns {u'message': u'Failed to execute method.', # Kodi sometimes returns {u'message': u'Failed to execute method.',
# u'code': -32100} if user quickly switches videos # u'code': -32100} if user quickly switches videos
i += 1 if app.APP.monitor.waitForAbort(0.1):
if i > 10: # PKC needs to quit
LOG.error('Failed to seek to %s', offset) return
i += 1
if i > TRY_TO_SEEK_FOR:
LOG.error('Failed to seek to %s. Error: %s', offset, answ)
return return
app.APP.monitor.waitForAbort(0.1)
answ = js.seek_to(offset * 1000) answ = js.seek_to(offset * 1000)
LOG.debug('Seek to offset %s successful', offset) LOG.debug('Seek to offset %s successful', offset)