Enable resume for playback initiated by Companion
This commit is contained in:
parent
3aa5ee0408
commit
a95e07d32b
2 changed files with 21 additions and 6 deletions
|
@ -362,7 +362,7 @@ def process_indirect(key, offset, resolve=True):
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
def play_xml(playqueue, xml):
|
def play_xml(playqueue, xml, offset=None):
|
||||||
"""
|
"""
|
||||||
Play all items contained in the xml passed in. Called by Plex Companion.
|
Play all items contained in the xml passed in. Called by Plex Companion.
|
||||||
"""
|
"""
|
||||||
|
@ -375,9 +375,24 @@ def play_xml(playqueue, xml):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
startpos = 0
|
startpos = 0
|
||||||
# New thread to release this one sooner (e.g. harddisk spinning up)
|
thread = Thread(target=threaded_playback,
|
||||||
thread = Thread(target=Player().play,
|
args=(playqueue.kodi_pl, startpos, offset))
|
||||||
args=(playqueue.kodi_pl, None, False, startpos))
|
|
||||||
thread.setDaemon(True)
|
|
||||||
LOG.info('Done play_xml, starting Kodi player at position %s', startpos)
|
LOG.info('Done play_xml, starting Kodi player at position %s', startpos)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
|
def threaded_playback(kodi_playlist, startpos, offset):
|
||||||
|
"""
|
||||||
|
Seek immediately after kicking off playback is not reliable.
|
||||||
|
"""
|
||||||
|
player = Player()
|
||||||
|
player.play(kodi_playlist, None, False, startpos)
|
||||||
|
if offset:
|
||||||
|
i = 0
|
||||||
|
while not player.isPlaying():
|
||||||
|
sleep(100)
|
||||||
|
i += 1
|
||||||
|
if i > 100:
|
||||||
|
LOG.error('Could not seek to %s', offset)
|
||||||
|
return
|
||||||
|
js.seek_to(int(offset))
|
||||||
|
|
|
@ -124,4 +124,4 @@ def update_playqueue_from_PMS(playqueue,
|
||||||
return
|
return
|
||||||
playqueue.repeat = 0 if not repeat else int(repeat)
|
playqueue.repeat = 0 if not repeat else int(repeat)
|
||||||
playqueue.plex_transient_token = transient_token
|
playqueue.plex_transient_token = transient_token
|
||||||
play_xml(playqueue, xml)
|
play_xml(playqueue, xml, offset)
|
||||||
|
|
Loading…
Reference in a new issue