Skip to content

Commit

Permalink
Improve behavior when no playable items found
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Aug 20, 2024
1 parent a9ff992 commit 948e980
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,10 @@ void play(final BaseItemDto item, final int pos, final boolean shuffle) {
@Override
public void onResponse(List<BaseItemDto> response) {
if (!getActive()) return;
if (response.isEmpty()) {
Timber.e("No items to play - ignoring play request.");
return;
}

if (item.getType() == BaseItemKind.MUSIC_ARTIST) {
mediaManager.getValue().playNow(requireContext(), response, 0, shuffle);
Expand All @@ -1196,7 +1200,6 @@ public void onResponse(List<BaseItemDto> response) {
}
}
});

}

void play(final List<BaseItemDto> items, final int pos, final boolean shuffle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class SdkPlaybackHelper(
) {
getScope(context).launch {
runCatching {
getItems(mainItem, allowIntros, shuffle)
val items = getItems(mainItem, allowIntros, shuffle)
if (items.isEmpty() && !mainItem.mediaSources.isNullOrEmpty()) listOf(mainItem)
else items
}.fold(
onSuccess = { items -> outerResponse.onResponse(items) },
onFailure = { exception ->
Expand Down

0 comments on commit 948e980

Please sign in to comment.