Improve behavior when no playable items found

This commit is contained in:
Niels van Velzen 2024-08-20 13:25:25 +02:00 committed by Niels van Velzen
parent 1199fa5253
commit 1f789ac00f
2 changed files with 7 additions and 2 deletions

View File

@ -1186,6 +1186,10 @@ public class FullDetailsFragment extends Fragment implements RecordingIndicatorV
@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);
@ -1196,7 +1200,6 @@ public class FullDetailsFragment extends Fragment implements RecordingIndicatorV
}
}
});
}
void play(final List<BaseItemDto> items, final int pos, final boolean shuffle) {

View File

@ -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 ->