Skip to content

Commit

Permalink
Improve playlist playback handling via context menu
Browse files Browse the repository at this point in the history
- Avoids unnecessary routing and loss of window history
  • Loading branch information
MoojMidge committed Dec 13, 2024
1 parent 4ca0d01 commit c4fe9d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
class AbstractProvider(object):
RESULT_CACHE_TO_DISC = 'cache_to_disc' # (bool)
RESULT_FALLBACK = 'fallback' # (bool)
RESULT_FORCE_PLAY = 'force_play' # (bool)
RESULT_FORCE_RESOLVE = 'force_resolve' # (bool)
RESULT_UPDATE_LISTING = 'update_listing' # (bool)

Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/items/menu_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def shuffle_playlist(context, playlist_id):
return (
context.localize('playlist.play.shuffle'),
context.create_uri(
(PATHS.ROUTE, PATHS.PLAY,),
(PATHS.PLAY,),
{
'playlist_id': playlist_id,
'order': 'shuffle',
'action': 'list',
'action': 'play',
},
run=True,
),
Expand Down
12 changes: 4 additions & 8 deletions resources/lib/youtube_plugin/kodion/plugin/xbmc/xbmc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,13 @@ def run(self, provider, context, focused=None):
show_fanart=show_fanart,
)
uri = result.get_uri()
result = xbmcplugin.addDirectoryItem(handle,
url=uri,
listitem=item)
if route:
if options.get(provider.RESULT_FORCE_PLAY):
playlist_player = context.get_playlist_player()
playlist_player.play_item(item=uri, listitem=item)
else:
xbmcplugin.setResolvedUrl(handle,
succeeded=result,
listitem=item)

xbmcplugin.setResolvedUrl(
handle, succeeded=True, listitem=item
)
else:
result, post_run_action = self.uri_action(context, uri)

Expand Down
7 changes: 3 additions & 4 deletions resources/lib/youtube_plugin/youtube/helper/yt_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def _play_playlist(provider, context):
return (
process_items_for_playlist(context, video_items, action, video_id),
{
provider.RESULT_CACHE_TO_DISC: False,
provider.RESULT_FORCE_RESOLVE: True,
provider.RESULT_UPDATE_LISTING: True,
provider.RESULT_CACHE_TO_DISC: action == 'list',
provider.RESULT_FORCE_RESOLVE: action != 'list',
provider.RESULT_UPDATE_LISTING: action != 'list',
},
)

Expand Down Expand Up @@ -426,5 +426,4 @@ def process_items_for_playlist(context, items, action=None, play_from=None):
return items
if action == 'play':
playlist_player.play_playlist_item(playlist_position + 1)
return False
return items[playlist_position]

0 comments on commit c4fe9d0

Please sign in to comment.