Fixes to how context menu playback is started

This commit is contained in:
tomkat83 2016-11-06 13:46:16 +01:00
parent de184c8e03
commit 462724275d
2 changed files with 15 additions and 5 deletions

View file

@ -203,7 +203,7 @@ class ContextMenu(object):
""" """
For using direct paths: Initiates playback using the PMS For using direct paths: Initiates playback using the PMS
""" """
window('plex_customplaylist', value='true') window('plex_contextplay', value='true')
params = { params = {
'filename': '/library/metadata/%s' % self.item_id, 'filename': '/library/metadata/%s' % self.item_id,
'id': self.item_id, 'id': self.item_id,

View file

@ -86,7 +86,10 @@ class PlaybackUtils():
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
############### ORGANIZE CURRENT PLAYLIST ################ ############### ORGANIZE CURRENT PLAYLIST ################
homeScreen = xbmc.getCondVisibility('Window.IsActive(home)') contextmenu_play = window('plex_contextplay') == 'true'
window('plex_contextplay', clear=True)
homeScreen = (xbmc.getCondVisibility('Window.IsActive(home)') or
contextmenu_play)
kodiPl = self.pl.playlist kodiPl = self.pl.playlist
# Can return -1 # Can return -1
startPos = max(kodiPl.getposition(), 0) startPos = max(kodiPl.getposition(), 0)
@ -136,13 +139,17 @@ class PlaybackUtils():
############### -- ADD MAIN ITEM ONLY FOR HOMESCREEN ############## ############### -- ADD MAIN ITEM ONLY FOR HOMESCREEN ##############
if homeScreen and not seektime and not sizePlaylist: if ((homeScreen and not seektime and not sizePlaylist) or
contextmenu_play):
# Extend our current playlist with the actual item to play # Extend our current playlist with the actual item to play
# only if there's no playlist first # only if there's no playlist first
log.info("Adding main item to playlist.") log.info("Adding main item to playlist.")
self.pl.addtoPlaylist( self.pl.addtoPlaylist(
dbid, dbid,
PF.KODITYPE_FROM_PLEXTYPE[API.getType()]) PF.KODITYPE_FROM_PLEXTYPE[API.getType()])
if seektime:
# Start from contextmenu only
window('plex_customplaylist.seektime', value=str(seektime))
# Ensure that additional parts are played after the main item # Ensure that additional parts are played after the main item
self.currentPosition += 1 self.currentPosition += 1
@ -196,14 +203,17 @@ class PlaybackUtils():
self.setProperties(playurl, listitem) self.setProperties(playurl, listitem)
############### PLAYBACK ################ ############### PLAYBACK ################
if homeScreen and seektime and window('plex_customplaylist') != "true": if (homeScreen and seektime and window('plex_customplaylist') != "true"
and not contextmenu_play):
log.info("Play as a widget item.") log.info("Play as a widget item.")
API.CreateListItemFromPlexItem(listitem) API.CreateListItemFromPlexItem(listitem)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
elif ((introsPlaylist and window('plex_customplaylist') == "true") or elif ((introsPlaylist and window('plex_customplaylist') == "true") or
(homeScreen and not sizePlaylist)): (homeScreen and not sizePlaylist) or
contextmenu_play):
# Playlist was created just now, play it. # Playlist was created just now, play it.
# Contextmenu plays always need this
log.info("Play playlist.") log.info("Play playlist.")
xbmcplugin.endOfDirectory(int(sys.argv[1]), True, False, False) xbmcplugin.endOfDirectory(int(sys.argv[1]), True, False, False)
xbmc.Player().play(kodiPl, startpos=startPos) xbmc.Player().play(kodiPl, startpos=startPos)