Fix playlist play/shuffle buttons not working

This commit is contained in:
Damontecres 2026-03-11 14:00:06 -04:00
parent 8aa64c6fef
commit 9c53abf152
No known key found for this signature in database
2 changed files with 34 additions and 2 deletions

View file

@ -53,7 +53,14 @@ abstract class MusicViewModel(
musicService.setQueue(pager, startIndex, shuffled) musicService.setQueue(pager, startIndex, shuffled)
} }
else -> {} BaseItemKind.PLAYLIST -> {
val pager = getPagerForPlaylist(api, item.id)
musicService.setQueue(pager, startIndex, shuffled)
}
else -> {
Timber.w("Unknown item type to play for music: %s", item.type)
}
} }
} }
} }
@ -85,7 +92,14 @@ abstract class MusicViewModel(
musicService.addAllToQueue(pager, 0) musicService.addAllToQueue(pager, 0)
} }
else -> {} BaseItemKind.PLAYLIST -> {
val pager = getPagerForPlaylist(api, item.id)
musicService.addAllToQueue(pager, 0)
}
else -> {
Timber.w("Unknown item type to queue for music: %s", item.type)
}
} }
} }
} }

View file

@ -236,3 +236,21 @@ suspend fun ViewModel.getPagerForArtist(
) )
return ApiRequestPager(api, request, GetItemsRequestHandler, viewModelScope).init() return ApiRequestPager(api, request, GetItemsRequestHandler, viewModelScope).init()
} }
suspend fun ViewModel.getPagerForPlaylist(
api: ApiClient,
playlistId: UUID,
): ApiRequestPager<GetItemsRequest> {
val request =
GetItemsRequest(
parentId = playlistId,
recursive = true,
includeItemTypes = listOf(BaseItemKind.AUDIO),
fields = DefaultItemFields,
sortBy =
listOf(
ItemSortBy.DEFAULT,
),
)
return ApiRequestPager(api, request, GetItemsRequestHandler, viewModelScope).init()
}